C端小程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

73 satır
1.6 KiB

  1. // pages/forgetpwd/forgetpwd.js
  2. const Http = require('../../../utils/http.js')
  3. const app = getApp()
  4. Page({
  5. data: {
  6. phone: '',
  7. yzm: '',
  8. flag: true,
  9. retry: false,
  10. time: 60
  11. },
  12. getYZM(e) {
  13. this.setData({
  14. phone: e.detail.value.phone,
  15. yzm: e.detail.value.yzm
  16. })
  17. },
  18. next() {
  19. console.log(this.data.yzm)
  20. Http.getResquest('/wxMsgValidationcode/hasvalidationcode', '', '加载中', {
  21. phone: this.data.phone,
  22. code: this.data.yzm,
  23. type: 1,
  24. appid: app.globalData.appId
  25. }, (res) => {
  26. console.log(res)
  27. if (res.code == 200) {
  28. //wx.navigateTo({
  29. // url: `../setpwd/setpwd?phone=${this.data.phone}&code=${this.data.yzm}`
  30. //})
  31. } else {
  32. wx.showToast({
  33. title: res.res,
  34. })
  35. }
  36. })
  37. },
  38. send() {
  39. var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
  40. if (phoneReg.test(this.data.phone)) {
  41. this.setData({
  42. flag: false,
  43. retry: true
  44. })
  45. Http.getResquest('/wxMsgValidationcode/sendvalidationcode', '', '加载中', {
  46. phone: this.data.phone,
  47. type: 1,
  48. appid: app.globalData.appId
  49. }, (res) => {
  50. console.log(res)
  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. } else {
  67. wx.showToast({
  68. title: '请输入有效手机号',
  69. })
  70. }
  71. }
  72. })