小程序收取短信的倒计时方法

小程序的收取短信的倒计时方法?
//page中添加属性(事件)
mobileInputEvent: function (e) {
this.setData({
mobile: e.detail.value
})
},
verifyCodeEvent: function (e) {
if (this.data.buttonDisable) return false;
var that = this;
var c = 60;
var intervalId = setInterval(function () {
c = c - 1;
that.setData({
verifyCodeTime: c + 's后重发',
buttonDisable: true
})
if (c == 0) {
clearInterval(intervalId);
that.setData({
verifyCodeTime: '获取验证码',
buttonDisable: false
})
}
}, 1000)
var mobile = this.data.mobile;
var regMobile = /^1\d{10}$/;
if (!regMobile.test(mobile)) {
wx.showToast({
title: '手机号有误!'
})
return false;
}
app.sendVerifyCode(function () { }, mobile);//获取短信验证码接口
}
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页