75 lines
2.0 KiB
JavaScript
75 lines
2.0 KiB
JavaScript
//验证码
|
|
var wait=60;
|
|
document.getElementById("code_btn").disabled = false;
|
|
function time(o){
|
|
if (wait == 0){
|
|
o.removeAttribute("disabled");
|
|
o.value="获取验证码";
|
|
wait = 60;
|
|
} else {
|
|
o.setAttribute("disabled", true);
|
|
o.value="重新发送(" + wait + ")";
|
|
wait--;
|
|
setTimeout(function(){
|
|
time(o)
|
|
},
|
|
1000)
|
|
}
|
|
}
|
|
//获取验证码
|
|
document.getElementById("code_btn").onclick=function(){
|
|
var mobile=$(".mobile").val();
|
|
var obj=this;
|
|
$.get("/index.php/Member/Public/reg_mobile_code",{"mobile":mobile},function(data){
|
|
var status=data.status;
|
|
var info=data.info;
|
|
if(!status){
|
|
alert(info);
|
|
}else{
|
|
time(obj);
|
|
}
|
|
},"json")
|
|
|
|
}
|
|
|
|
//ajax提交表单
|
|
function save_form(obj,callback){
|
|
var action=$(obj).attr("action");
|
|
var method=$(obj).attr("method");
|
|
var data=$(obj).serializeArray();
|
|
$(obj).find("button[type='submit']").attr("disabled",true);
|
|
$.ajax({
|
|
url:action,
|
|
type:method,
|
|
async:true,
|
|
data:data,
|
|
dataType:'json',
|
|
success:function(result){
|
|
var status=result.status;
|
|
var info=result.info;
|
|
if(status){
|
|
if(callback){
|
|
callback(info);//回调函数
|
|
}else{
|
|
window.location.href=document.referrer;
|
|
}
|
|
}else{
|
|
alert(info);
|
|
$(obj).find("button[type='submit']").attr("disabled",false);
|
|
}
|
|
},
|
|
error:function(xhr,textStatus){
|
|
alert("程序出错,请联系管理员");
|
|
},
|
|
complete:function(){
|
|
$(obj).find("button[type='submit']").attr("disabled",false);
|
|
}
|
|
})
|
|
return false;
|
|
}
|
|
function save_form2(obj){
|
|
save_form(obj,function(data){
|
|
parent.location.reload();
|
|
});
|
|
return false;
|
|
}
|