小程序验证码倒计时
var countdown = 60;
var settime = function (that) {
if (countdown == 0) {
that.setData({
is_show: true
})
countdown = 60;
return;
} else {
that.setData({
is_show: false,
last_time: countdown
})
countdown--;
}
setTimeout(function () {
settime(that)
}, 1000)
}
Page({
/**
* 页面的初始数据
*/
data: {
last_time: '',
is_show: true
},
clickVerify: function () {
var that = this;
// 将获取验证码按钮隐藏60s,60s后再次显示
that.setData({
is_show: (!that.data.is_show) //false
})
settime(that);
}
})