C端小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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