C端小程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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