var isvalidSend = true;
//点击 <发送验证码> 按钮
function bindSmsCode() {
$("#btnSendSmsAuthCode").on("click", function () {
if (!isvalidSend) {
return;
}
var self = this;
//手机号验证
sendCode(phone);
});
};
//辅助方法-发送验证码
function sendCode(_phonenum) {
isvalidSend = false;
_Ajax('xx',
{
Mobile: _phonenum,
}, function (res) {
if (发送失败判断) {
isvalidSend = true;
return;
}
countDown();
}, function (a, b, c) {
isvalidSend = true;return;
});
};
//辅助方法-验证码倒计时
function countDown() {
var startTime = 60;
var boxtime;
var showBtn = $('#btnSendSmsAuthCode');
function time() {
startTime--;
if (startTime == 0) {
clearInterval(boxtime);
startTime = 60;
showBtn.val("发送验证码");
isvalidSend = true;
return;
}
showBtn.val("重新发送(" + startTime + ")");
}
boxtime = window.setInterval(time, 1000);
};