C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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