文件
mashangyoujiu/Public/vip/js/forgetpwd.js

82 行
2.1 KiB
JavaScript
可执行文件

$('.close').on('touchstart',function () {
window.history.go(-1);
})
$('.getcode').on('touchstart',function () {
var reg = /^1[34578]\d{9}$/;
var phone = $('#phone').val();
if(phone.length==0){
alertMsg('请输入手机号',600);
return;
}
if(!reg.test(phone)){
alertMsg('手机号码不正确',1000);
return;
}
$.post("/index.php/Vip/Set/getCode",{
mobile:phone
},function (data) {
if(data.success==1){
alertMsg(data.msg,1000);
resetCode();
}else {
alertMsg(data.msg,1000);
}
})
})
$(".next").on('touchstart',function(){
var reg = /^1[34578]\d{9}$/;
var phone = $('#phone').val();
var code = $('#code').val();
if(phone.length==0){
alertMsg('请输入手机号',1000);
return;
}
if(!reg.test(phone)){
alertMsg('手机号码不正确',1000);
return;
}
if(code==''){
alertMsg('请输入验证码',1000);
return;
}
$.post("/index.php/Vip/Set/verifyCode",{
code:code
},function (data) {
if(data.success==1){
window.location.replace("/index.php/Vip/Set/resetpwd.html?verifyCode="+data.verifyCode);
}else {
alertMsg(data.msg,1000);
}
})
})
//手机验证码倒计时
function resetCode() {
$('.getcode').hide();
$('.recode>span').html('60');
$('.recode').show();
var second = 60;//倒计时60秒能重新发送
var second1 = 300;//验证码300秒过期
var timer = null;
var timer1 = null;
timer1 = setInterval(function () {
second1 -= 1;
if(second1 <= 0){
clearInterval(timer1);
$.ajax({
url:"/index.php/Vip/Login/clearsession"
});
}
},1000);
timer = setInterval(function() {
second -= 1;
if(second > 0) {
$('.recode>span').html(second);
} else {
clearInterval(timer);
$('.getcode').show();
$('.recode').hide();
}
}, 1000);
}