// pages/forgetpwd/forgetpwd.js const Http = require('../../../utils/http.js') const app = getApp() Page({ data: { phone: '', yzm: '', flag: true, retry: false, time: 60 }, getYZM(e) { this.setData({ phone: e.detail.value.phone, yzm: e.detail.value.yzm }) }, next() { console.log(this.data.yzm) Http.getResquest('/wxMsgValidationcode/hasvalidationcode', '', '加载中', { phone: this.data.phone, code: this.data.yzm, type: 1, appid: app.globalData.appId }, (res) => { console.log(res) if (res.code == 200) { //wx.navigateTo({ // url: `../setpwd/setpwd?phone=${this.data.phone}&code=${this.data.yzm}` //}) } else { wx.showToast({ title: res.res, }) } }) }, send() { var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/; if (phoneReg.test(this.data.phone)) { this.setData({ flag: false, retry: true }) Http.getResquest('/wxMsgValidationcode/sendvalidationcode', '', '加载中', { phone: this.data.phone, type: 1, appid: app.globalData.appId }, (res) => { console.log(res) var timer = setInterval(() => { this.data.time-- this.setData({ time: this.data.time }) if (this.data.time == 0) { clearInterval(timer) this.setData({ flag: true, retry: false, time:60 }) } }, 1000) }) } else { wx.showToast({ title: '请输入有效手机号', }) } } })