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.

78 linhas
1.6 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. flag: true,
  10. retry: false,
  11. time: 60
  12. },
  13. getYZM(e) {
  14. this.setData({
  15. phone: e.detail.value.phone,
  16. yzm: e.detail.value.yzm
  17. })
  18. },
  19. next() {
  20. console.log(this.data.yzm)
  21. Http.get({
  22. url: config.api.validationCode,
  23. data: {
  24. phone: this.data.phone,
  25. code: this.data.yzm,
  26. type: 1,
  27. appid: app.globalData.appId
  28. }
  29. })
  30. .then(function(res){
  31. },function(error){
  32. wx.showToast({
  33. title: error.data,
  34. })
  35. })
  36. },
  37. send() {
  38. var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
  39. if (phoneReg.test(this.data.phone)) {
  40. this.setData({
  41. flag: false,
  42. retry: true
  43. })
  44. Http.get({
  45. url: config.api.validationCode,
  46. data: {
  47. phone: this.data.phone,
  48. code: this.data.yzm,
  49. type: 1,
  50. appid: app.globalData.appId
  51. }
  52. })
  53. .then(function(res){
  54. console.log(res)
  55. var timer = setInterval(() => {
  56. this.data.time--
  57. this.setData({
  58. time: this.data.time
  59. })
  60. if (this.data.time == 0) {
  61. clearInterval(timer)
  62. this.setData({
  63. flag: true,
  64. retry: false,
  65. time: 60
  66. })
  67. }
  68. }, 1000)
  69. }, function(error){
  70. wx.showToast({
  71. title: '请输入有效手机号',
  72. })
  73. })
  74. }
  75. }
  76. })