C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

102 行
2.2 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. retry: false,
  10. time: 60,
  11. couponChannelId: null,
  12. couponId:null
  13. },
  14. onLoad: function (options) {
  15. var that = this;
  16. console.log(options);
  17. that.setData({
  18. couponChannelId: options.couponChannelId,
  19. couponId: options.couponId,
  20. })
  21. },
  22. getYZM(e) {
  23. this.setData({
  24. phone: e.detail.value.phone,
  25. yzm: e.detail.value.yzm
  26. })
  27. },
  28. next() {
  29. var that = this
  30. console.log(that.data.yzm)
  31. Http.get({
  32. url: config.api.validationCode,
  33. data: {
  34. phone: that.data.phone,
  35. code: that.data.yzm,
  36. type: 1,
  37. appid: app.globalData.appId
  38. }
  39. })
  40. .then(res => {
  41. wx.redirectTo({
  42. url: '/pages/coupon/detail/index?couponChannelId=' + that.data.couponChannelId + '&couponId=' + that.data.couponId + "&flag=pay",
  43. })
  44. })
  45. .catch(error => {
  46. wx.showToast({
  47. title: error.data,
  48. })
  49. })
  50. },
  51. //计时器
  52. timerInfo() {
  53. var timer = setInterval(() => {
  54. this.data.time--
  55. this.setData({
  56. time: this.data.time
  57. })
  58. if (this.data.time == 0) {
  59. clearInterval(timer)
  60. this.setData({
  61. flag: true,
  62. retry: false,
  63. time: 60
  64. })
  65. }
  66. }, 1000)
  67. },
  68. send() {
  69. var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
  70. if (phoneReg.test(this.data.phone)) {
  71. this.setData({
  72. retry: true
  73. })
  74. Http.get({
  75. url: config.api.sendValidationCode,
  76. data: {
  77. phone: this.data.phone,
  78. code: this.data.yzm,
  79. type: 1,
  80. appid: app.globalData.appId
  81. }
  82. })
  83. .then(res => {
  84. console.log(res)
  85. that.timerInfo()
  86. if (res.code == 200) {
  87. console.log(res)
  88. } else {
  89. wx.showToast({
  90. title: res.message
  91. })
  92. }
  93. })
  94. .catch(error => {
  95. wx.showToast({
  96. title: '请输入有效手机号',
  97. })
  98. })
  99. }
  100. }
  101. })