C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

83 linhas
1.8 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: '../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. send() {
  43. var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
  44. if (phoneReg.test(this.data.phone)) {
  45. this.setData({
  46. flag: false,
  47. retry: true
  48. })
  49. Http.get({
  50. url: config.api.sendValidationCode,
  51. data: {
  52. phone: this.data.phone,
  53. code: this.data.yzm,
  54. type: 1,
  55. appid: app.globalData.appId
  56. }
  57. })
  58. .then(res => {
  59. console.log(res)
  60. var timer = setInterval(() => {
  61. this.data.time--
  62. this.setData({
  63. time: this.data.time
  64. })
  65. if (this.data.time == 0) {
  66. clearInterval(timer)
  67. this.setData({
  68. flag: true,
  69. retry: false,
  70. time: 60
  71. })
  72. }
  73. }, 1000)
  74. })
  75. .catch(error => {
  76. wx.showToast({
  77. title: '请输入有效手机号',
  78. })
  79. })
  80. }
  81. }
  82. })