微信小程序开发总结--发送验证码倒计时

var that = this

var count = 60;

var re=/^1[3|4|5|7|8][0-9]\d{4,8}$/;

if(!re.test(that.data.mobile))

{

wx.showModal({

title: "请输入正确的手机号"

});

return false;

}else{

if(that.data.isdisable==false){

that.sendcode()

wx.showModal({

title: "发送成功"

});

var timer = setInterval(function () {

count--;

if (count >= 1) {

that.setData({

verifyInfo: count + 's'

})

} else {

that.setData({

verifyInfo: '获取验证码'

})

clearInterval(timer);

that.data.isdisable = false;

}

}, 1000);

that.data.isdisable = true;

}

}

你可能感兴趣的:(微信小程序开发总结--发送验证码倒计时)