num--;
$(".getAuthCode").val(num+"秒");
$(".getAuthCode").css("background-color","#D1D4DD");
setInt = setTimeout(countdown,1000);
if (num<=0) {
//移除失效的随机数
appcan.locStorage.remove("randomNum_login");
clearTimeout(setInt);
$(".getAuthCode").val("获取验证码").removeAttr("disabled");
$(".getAuthCode").removeAttr("style");
};
};
function RandomNumBoth(Min,Max){
var Range = Max - Min;
var Rand = Math.random();
var num = Min + Math.round(Rand * Range); //四舍五入
return num;
};
appcan.button(".getAuthCode", "btn-act",function() { //开始入口
var phoneNumber = trim($("#phoneNumber").val());
if(!phoneNumber || phoneNumber == ''){
appcan.window.alert({title:'提示',content:'请输入手机号',buttons:'确定'});
return false;
}else if(!/^(13[0-9]|14[0-9]|15[012356789]|17[012356789]|181|182|18[5-9])[0-9]{8}$/.test(phoneNumber)){
appcan.window.alert({title:'提示',content:'请输入正确的手机号',buttons:'确定'});
return false;
}
//初始化时间
num = 60;
this.disabled = true;
//倒计时开始
countdown();
//生成一个六位数的随机数并本地存储
var randomNum = RandomNumBoth(100000,999999);
appcan.locStorage.setVal("randomNum_login",randomNum);
//向用户发送短信通知验证码信息
var phoneNumber = trim($("#phoneNumber").val());
appcan.window.alert({title:'提示',content:randomNum,buttons:'确定'});
//sms。。。
});