|
|
|
@ -1,5 +1,9 @@ |
|
|
|
|
$(function(){ |
|
|
|
|
var tab = 'account_number'; |
|
|
|
|
var usr = ''; |
|
|
|
|
var code = ''; |
|
|
|
|
var hash = ''; |
|
|
|
|
var timer; |
|
|
|
|
// 选项卡切换
|
|
|
|
|
$(".account_number").click(function () { |
|
|
|
|
$('.tel-warn').addClass('hide'); |
|
|
|
@ -7,8 +11,9 @@ $(function(){ |
|
|
|
|
checkBtn(); |
|
|
|
|
$(this).addClass("on"); |
|
|
|
|
$(".message").removeClass("on"); |
|
|
|
|
$(".form2").addClass("hide"); |
|
|
|
|
$(".form1").removeClass("hide"); |
|
|
|
|
$("#num2").addClass("hide"); |
|
|
|
|
$("#num").removeClass("hide"); |
|
|
|
|
$("#lab_num").html('邮箱'); |
|
|
|
|
}); |
|
|
|
|
// 选项卡切换
|
|
|
|
|
$(".message").click(function () { |
|
|
|
@ -17,8 +22,9 @@ $(function(){ |
|
|
|
|
checkBtn(); |
|
|
|
|
$(this).addClass("on"); |
|
|
|
|
$(".account_number").removeClass("on"); |
|
|
|
|
$(".form2").removeClass("hide"); |
|
|
|
|
$(".form1").addClass("hide"); |
|
|
|
|
$("#num").addClass("hide"); |
|
|
|
|
$("#num2").removeClass("hide"); |
|
|
|
|
$("#lab_num").html('手机号'); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -50,213 +56,95 @@ $(function(){ |
|
|
|
|
// 按钮是否可点击
|
|
|
|
|
function checkBtn() |
|
|
|
|
{ |
|
|
|
|
$(".log-btn").off('click'); |
|
|
|
|
if (tab == 'account_number') { |
|
|
|
|
var inp = $.trim($('#num').val()); |
|
|
|
|
var pass = $.trim($('#pass').val()); |
|
|
|
|
if (inp != '' && pass != '') { |
|
|
|
|
if (!$('.code').hasClass('hide')) { |
|
|
|
|
code = $.trim($('#veri').val()); |
|
|
|
|
if (code == '') { |
|
|
|
|
$(".log-btn").addClass("off"); |
|
|
|
|
} else { |
|
|
|
|
$(".log-btn").removeClass("off"); |
|
|
|
|
sendBtn(); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$(".log-btn").removeClass("off"); |
|
|
|
|
sendBtn(); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$(".log-btn").addClass("off"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
var phone = $.trim($('#num2').val()); |
|
|
|
|
var code2 = $.trim($('#veri-code').val()); |
|
|
|
|
if (phone != '' && code2 != '') { |
|
|
|
|
$(".log-btn").removeClass("off"); |
|
|
|
|
sendBtn(); |
|
|
|
|
} else { |
|
|
|
|
$(".log-btn").addClass("off"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function checkAccount(username){ |
|
|
|
|
if (username == '') { |
|
|
|
|
$('.num-err').removeClass('hide').find("em").text('请输入账户'); |
|
|
|
|
return false; |
|
|
|
|
} else { |
|
|
|
|
$('.num-err').addClass('hide'); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function checkPass(pass){ |
|
|
|
|
if (pass == '') { |
|
|
|
|
$('.pass-err').removeClass('hide').text('请输入密码'); |
|
|
|
|
return false; |
|
|
|
|
} else { |
|
|
|
|
$('.pass-err').addClass('hide'); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function checkCode(code){ |
|
|
|
|
if (code == '') { |
|
|
|
|
// $('.tel-warn').removeClass('hide').text('请输入验证码');
|
|
|
|
|
return false; |
|
|
|
|
} else { |
|
|
|
|
// $('.tel-warn').addClass('hide');
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function checkPhone(phone){ |
|
|
|
|
var status = true; |
|
|
|
|
if (phone == '') { |
|
|
|
|
$('.num2-err').removeClass('hide').find("em").text('请输入手机号'); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
var param = /^1[34578]\d{9}$/; |
|
|
|
|
if (!param.test(phone)) { |
|
|
|
|
// globalTip({'msg':'手机号不合法,请重新输入','setTime':3});
|
|
|
|
|
$('.num2-err').removeClass('hide'); |
|
|
|
|
$('.num2-err').text('手机号不合法,请重新输入'); |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
function checkTo(phone){ |
|
|
|
|
if(tab == 'account_number'){ |
|
|
|
|
|
|
|
|
|
var status = true; |
|
|
|
|
if (phone == '') { |
|
|
|
|
$('.num-err').removeClass('hide').find("em").text('请输入邮箱'); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
var param = /^([A-Za-z0-9_\-\.\u4e00-\u9fa5])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,8})$/; |
|
|
|
|
if (!param.test(phone)) { |
|
|
|
|
// globalTip({'msg':'手机号不合法,请重新输入','setTime':3});
|
|
|
|
|
$('.num-err').removeClass('hide'); |
|
|
|
|
$('.num-err').text('邮箱不合法,请重新输入'); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var status = true; |
|
|
|
|
if (phone == '') { |
|
|
|
|
$('.num-err').removeClass('hide').find("em").text('请输入手机号'); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
var param = /^1[34578]\d{9}$/; |
|
|
|
|
if (!param.test(phone)) { |
|
|
|
|
// globalTip({'msg':'手机号不合法,请重新输入','setTime':3});
|
|
|
|
|
$('.num-err').removeClass('hide'); |
|
|
|
|
$('.num-err').text('手机号不合法,请重新输入'); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
$.ajax({ |
|
|
|
|
url: '/checkPhone', |
|
|
|
|
type: 'post', |
|
|
|
|
dataType: 'json', |
|
|
|
|
async: false, |
|
|
|
|
data: {phone:phone,type:"login"}, |
|
|
|
|
success:function(data){ |
|
|
|
|
if (data.code == '0') { |
|
|
|
|
$('.num2-err').addClass('hide'); |
|
|
|
|
// console.log('aa');
|
|
|
|
|
// return true;
|
|
|
|
|
} else { |
|
|
|
|
$('.num2-err').removeClass('hide').text(data.msg); |
|
|
|
|
// console.log('bb');
|
|
|
|
|
status = false; |
|
|
|
|
// return false;
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
error:function(){ |
|
|
|
|
status = false; |
|
|
|
|
// return false;
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return status; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function checkPhoneCode(pCode){ |
|
|
|
|
function checkCode(pCode){ |
|
|
|
|
if (pCode == '') { |
|
|
|
|
$('.error').removeClass('hide').text('请输入验证码'); |
|
|
|
|
return false; |
|
|
|
|
} else { |
|
|
|
|
$('.error').addClass('hide'); |
|
|
|
|
|
|
|
|
|
$.get('/api/verCode.php?type='+((tab == 'account_number')?'email':'tel')+'&usr='+usr+'&code='+code, function(data){ |
|
|
|
|
if(data.code == 200){ |
|
|
|
|
|
|
|
|
|
hash = data.hash; |
|
|
|
|
if(data.isExist){ |
|
|
|
|
$('.lang-btn').html('登录'); |
|
|
|
|
}else{ |
|
|
|
|
$('.lang-btn').html('注册'); |
|
|
|
|
} |
|
|
|
|
var oTime = $(".form-data .time"), |
|
|
|
|
oSend = $(".form-data .send"), |
|
|
|
|
oEm = $(".form-data .time em"); |
|
|
|
|
clearInterval(timer); |
|
|
|
|
oSend.text("验证成功"); |
|
|
|
|
oSend.css("color", 'green'); |
|
|
|
|
oSend.show(); |
|
|
|
|
oEm.text("120"); |
|
|
|
|
oTime.addClass("hide"); |
|
|
|
|
$(".log-btn").removeClass("off"); |
|
|
|
|
$('.error').addClass('hide') |
|
|
|
|
}else{ |
|
|
|
|
$('.error').removeClass('hide').text('验证码错误!'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 登录点击事件
|
|
|
|
|
function sendBtn(){ |
|
|
|
|
if (tab == 'account_number') { |
|
|
|
|
$(".log-btn").click(function(){ |
|
|
|
|
// var type = 'phone';
|
|
|
|
|
var inp = $.trim($('#num').val()); |
|
|
|
|
var pass = $.md5($.trim($('#pass').val())); |
|
|
|
|
if (checkAccount(inp) && checkPass(pass)) { |
|
|
|
|
var ldata = {userinp:inp,password:pass}; |
|
|
|
|
if (!$('.code').hasClass('hide')) { |
|
|
|
|
code = $.trim($('#veri').val()); |
|
|
|
|
if (!checkCode(code)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
ldata.code = code; |
|
|
|
|
} |
|
|
|
|
$.ajax({ |
|
|
|
|
url: '/dologin', |
|
|
|
|
type: 'post', |
|
|
|
|
dataType: 'json', |
|
|
|
|
async: true, |
|
|
|
|
data: ldata, |
|
|
|
|
success:function(data){ |
|
|
|
|
if (data.code == '0') { |
|
|
|
|
// globalTip({'msg':'登录成功!','setTime':3,'jump':true,'URL':'http://www.ui.cn'});
|
|
|
|
|
globalTip(data.msg); |
|
|
|
|
} else if(data.code == '2') { |
|
|
|
|
$(".log-btn").off('click').addClass("off"); |
|
|
|
|
$('.pass-err').removeClass('hide').find('em').text(data.msg); |
|
|
|
|
$('.pass-err').find('i').attr('class', 'icon-warn').css("color","#d9585b"); |
|
|
|
|
$('.code').removeClass('hide'); |
|
|
|
|
$('.code').find('img').attr('src','/verifyCode?'+Math.random()).click(function(event) { |
|
|
|
|
$(this).attr('src', '/verifyCode?'+Math.random()); |
|
|
|
|
});; |
|
|
|
|
return false; |
|
|
|
|
} else if(data.code == '3') { |
|
|
|
|
$(".log-btn").off('click').addClass("off"); |
|
|
|
|
$('.img-err').removeClass('hide').find('em').text(data.msg); |
|
|
|
|
$('.img-err').find('i').attr('class', 'icon-warn').css("color","#d9585b"); |
|
|
|
|
$('.code').removeClass('hide'); |
|
|
|
|
$('.code').find('img').attr('src','/verifyCode?'+Math.random()).click(function(event) { |
|
|
|
|
$(this).attr('src', '/verifyCode?'+Math.random()); |
|
|
|
|
}); |
|
|
|
|
return false; |
|
|
|
|
} else if(data.code == '1'){ |
|
|
|
|
$(".log-btn").off('click').addClass("off"); |
|
|
|
|
$('.num-err').removeClass('hide').find('em').text(data.msg); |
|
|
|
|
$('.num-err').find('i').attr('class', 'icon-warn').css("color","#d9585b"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
error:function(){ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
$(".log-btn").click(function(){ |
|
|
|
|
// var type = 'phone';
|
|
|
|
|
var phone = $.trim($('#num2').val()); |
|
|
|
|
var pcode = $.trim($('#veri-code').val()); |
|
|
|
|
if (checkPhone(phone) && checkPass(pcode)) { |
|
|
|
|
$.ajax({ |
|
|
|
|
url: '/plogin', |
|
|
|
|
type: 'post', |
|
|
|
|
dataType: 'json', |
|
|
|
|
async: true, |
|
|
|
|
data: {phone:phone,code:pcode}, |
|
|
|
|
success:function(data){ |
|
|
|
|
if (data.code == '0') { |
|
|
|
|
// globalTip({'msg':'登录成功!','setTime':3,'jump':true,'URL':'http://www.ui.cn'});
|
|
|
|
|
globalTip(data.msg); |
|
|
|
|
} else if(data.code == '1') { |
|
|
|
|
$(".log-btn").off('click').addClass("off"); |
|
|
|
|
$('.num2-err').removeClass('hide').text(data.msg); |
|
|
|
|
return false; |
|
|
|
|
} else if(data.code == '2') { |
|
|
|
|
$(".log-btn").off('click').addClass("off"); |
|
|
|
|
$('.error').removeClass('hide').text(data.msg); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
error:function(){ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
$(".log-btn").off('click').addClass("off"); |
|
|
|
|
// $('.tel-warn').removeClass('hide').text('登录失败');
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
$.get('/api/checkAccount.php?hash='+hash, function(data){ |
|
|
|
|
if(data.code == 200){ |
|
|
|
|
tips.success({message: '登录/注册成功!'}) |
|
|
|
|
window.location.href="https://www.eee.dog/"; |
|
|
|
|
}else{ |
|
|
|
|
tips.warning({message: '登录/注册失败!'}) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 登录的回车事件
|
|
|
|
@ -268,42 +156,61 @@ $(function(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".form-data").delegate(".send","click",function () { |
|
|
|
|
var phone = $.trim($('#num2').val()); |
|
|
|
|
if (checkPhone(phone)) { |
|
|
|
|
$.ajax({ |
|
|
|
|
url: '/getcode', |
|
|
|
|
type: 'post', |
|
|
|
|
dataType: 'json', |
|
|
|
|
async: true, |
|
|
|
|
data: {phone:phone,type:"login"}, |
|
|
|
|
success:function(data){ |
|
|
|
|
if (data.code == '0') { |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
error:function(){ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if(tab == 'account_number'){ |
|
|
|
|
var to = $.trim($('#num').val()); |
|
|
|
|
}else{ |
|
|
|
|
var to = $.trim($('#num2').val()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (checkTo(to)) { |
|
|
|
|
var oTime = $(".form-data .time"), |
|
|
|
|
oSend = $(".form-data .send"), |
|
|
|
|
num = parseInt(oTime.text()), |
|
|
|
|
oEm = $(".form-data .time em"); |
|
|
|
|
$(this).hide(); |
|
|
|
|
oTime.removeClass("hide"); |
|
|
|
|
var timer = setInterval(function () { |
|
|
|
|
timer = setInterval(function () { |
|
|
|
|
var num2 = num-=1; |
|
|
|
|
oEm.text(num2); |
|
|
|
|
if(num2==0){ |
|
|
|
|
clearInterval(timer); |
|
|
|
|
oSend.text("重新发送验证码"); |
|
|
|
|
oSend.css("color", 'red'); |
|
|
|
|
oSend.show(); |
|
|
|
|
oEm.text("120"); |
|
|
|
|
oTime.addClass("hide"); |
|
|
|
|
} |
|
|
|
|
},1000); |
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
url: '/api/'+((tab == 'account_number')?'email':'sms')+'Code.php', |
|
|
|
|
type: 'get', |
|
|
|
|
dataType: 'json', |
|
|
|
|
async: true, |
|
|
|
|
data: {email: to, tel: to}, |
|
|
|
|
success:function(data){ |
|
|
|
|
if (data.code == '200') { |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
clearInterval(timer); |
|
|
|
|
oSend.text("重新发送验证码"); |
|
|
|
|
oSend.css("color", 'red'); |
|
|
|
|
oSend.show(); |
|
|
|
|
oEm.text("120"); |
|
|
|
|
oTime.addClass("hide"); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
error:function(){ |
|
|
|
|
clearInterval(timer); |
|
|
|
|
oSend.text("重新发送验证码"); |
|
|
|
|
oSend.css("color", 'red'); |
|
|
|
|
oSend.show(); |
|
|
|
|
oEm.text("120"); |
|
|
|
|
oTime.addClass("hide"); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|