C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.9 KiB

  1. // pages/forgetpwd/forgetpwd.js
  2. let config = require('../../../config/config.js')
  3. let Http = require('../../../utils/HttpBasics')
  4. const app = getApp()
  5. Page({
  6. data: {
  7. phone: '',
  8. yzm: '',
  9. flag: true,
  10. retry: false,
  11. time: 60,
  12. couponId: null,
  13. },
  14. getYZM(e) {
  15. this.setData({
  16. phone: e.detail.value.phone,
  17. yzm: e.detail.value.yzm
  18. })
  19. },
  20. next() {
  21. var that = this
  22. console.log(that.data.yzm)
  23. Http.get({
  24. url: config.api.validationCode,
  25. data: {
  26. phone: that.data.phone,
  27. code: that.data.yzm,
  28. type: 1,
  29. appid: app.globalData.appId
  30. }
  31. })
  32. .then(res => {
  33. wx.redirectTo({
  34. url: '../coupon/detail/index?id=' + that.data.couponId + "&flag=pay",
  35. })
  36. })
  37. .catch(error => {
  38. wx.showToast({
  39. title: error.data,
  40. })
  41. })
  42. },
  43. send() {
  44. var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
  45. if (phoneReg.test(this.data.phone)) {
  46. this.setData({
  47. flag: false,
  48. retry: true
  49. })
  50. Http.get({
  51. url: config.api.sendValidationCode,
  52. data: {
  53. phone: this.data.phone,
  54. code: this.data.yzm,
  55. type: 1,
  56. appid: app.globalData.appId
  57. }
  58. })
  59. .then(res => {
  60. console.log(res)
  61. var timer = setInterval(() => {
  62. this.data.time--
  63. this.setData({
  64. time: this.data.time
  65. })
  66. if (this.data.time == 0) {
  67. clearInterval(timer)
  68. this.setData({
  69. flag: true,
  70. retry: false,
  71. time: 60
  72. })
  73. }
  74. }, 1000)
  75. })
  76. .catch(error => {
  77. wx.showToast({
  78. title: '请输入有效手机号',
  79. })
  80. })
  81. }
  82. }
  83. })