var app = getApp() const util = require('../../utils/utils.js'); let countTime = null//定时器 Page({ data: { currentTime: 60,//倒计时时间 number: '', }, onLoad: function (options) { console.log(options) let that = this that.setData({ number: options.number }) that.countDown() }, //重新获取验证码 getCodeno: util.throttle(function () { let that = this // 调用短信验证码接口 let data = { mobile: that.data.number, type: 2 } app.request('/verification-code', data, 'POST').then(res => { that.setData({ currentTime:60 }) if (res.status == 200) { that.countDown() } }) //60秒倒计时 }, 1000), //倒计时 countDown:function(){ let that=this let currentTime = that.data.currentTime countTime = setInterval(function () { currentTime-- that.setData({ currentTime: currentTime }) if (currentTime == 0) { clearInterval(countTime) } }, 1000) }, onReady: function () { }, onShow: function () { }, onHide: function () { }, onUnload: function () { }, onPullDownRefresh: function () { }, onReachBottom: function () { }, onShareAppMessage: function () { } })