You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

385 lines
8.9 KiB

var g_warnTel=0;
var g_can_click=1;
var g_can_send=1;
var g_success=0;
var g_finalTel;
var g_wrongCount=0;
var _phone=0;
var _code=0;
$(".log-btn").addClass("off");
$(".next").addClass("off");
function reg()
{
$(".login").css({
"opacity":"0",
"z-index":"-100",
"transition-duration": "1s",
"transition-delay": "0s"
});
$(".find_password").css({
"opacity":"1",
"z-index":"999",
"transition-duration": "1s",
"transition-delay": "0s"
});
}
$('#pc_tel').keyup(function(event) {
if($.trim($('#pc_tel').val()).length>2&&$.trim($('#pc_tel').val()).length<13) $(".next").removeClass("off");
else $(".next").addClass("off");
if($.trim($('#pc_tel').val()).length>12)
$('.pc_tel-err').removeClass('hide').text('最多12个字哦ヽ(•̀ω•́ )ゝ');
});
$('#veri-code').keyup(function(event) {
$('.tel-warn').addClass('hide');
checkBtn();
});
function checkBtn()
{
var phone = $.trim($('#tel').val());
var code2 = $.trim($('#veri-code').val());
if(!g_can_send)
{
if (checkPhone((phone))&&code2.length==6) {
_phone=phone;
_code=code2;
if(g_wrongCount<2) check_verCode(phone,code2,2);
else {
easyVer();
$(".wrap").css({
"opacity":"0",
"transition-duration": "1s",
"transition-delay": "0s"
});
if(device.mobile()){document.body.style.zoom="1.2";}
show_easyVer();
}
} else {
$(".log-btn").addClass("off");
}
}
else if(!g_count&&code2.length>3) $('.error').removeClass('hide').text('请先发送验证码同学 Ծ‸ Ծ');
}
function checkPhoneCode(pCode){
if (pCode == '') {
$('.error').removeClass('hide').text('Where is your 验证码╭(°A°`)╮');
return false;
} else if(pCode.length!=6){
$('.error').removeClass('hide').text('这真的是你的验证码吗同学 Ծ‸ Ծ');
}
else {
$('.error').addClass('hide');
return true;
}
}
// 登录点击事件
$(".log-btn").on("click",function sendBtn(){
if(g_can_click==1||g_success)
{
var phone = $.trim($('#tel').val());
var pcode = $.trim($('#veri-code').val());
if(!checkPhone(phone) || !checkPhoneCode(pcode)) return false;
if($('input[name="agree"]').val()=='0')
{
alert('啊咧~ 暂不支持非永久登录┐(´-`)┌');
return false;
}
$.ajax({
url: '/etc/clever-login/record_usr.php',
type: 'post',
dataType: 'json',
async: true,
data: {"tel":g_finalTel,"fp":fp,"ip":ip},
success:function(data){
if (data.code == '0') {
//正常登录
window.location.href="/login/goBack.php";
return true;
}
else if(data.code=='1'){
//转注册界面
reg();
}
else{
$('.tel-warn').removeClass('hide').text('登录失败');
$(".lang-btn").addClass("off");
}
},
error:function(){
alert('嘀~ 与服务器失联啦 ( ´◔‸◔`)');
}
});
return false;
}
});
// next点击事件
$(".next").on("click",function sendBtn(){
var name = $.trim($('#pc_tel').val());
if(name.length>2&&name.length<13)
{
$.ajax({
url: '/etc/clever-login/record_usrName.php',
type: 'post',
dataType: 'json',
async: true,
data: {"tel":g_finalTel,"name":name},
success:function(data){
if (data.code == '0') {
//正常登录
alert('注册成功啦!!');
window.location.href="/login/goBack.php";
return true;
}
else{
$('.pc_tel-err').removeClass('hide').text('注册失败啦!!');
$(".lang-btn").addClass("off");
}
},
error:function(){
alert('嘀~ 与服务器失联啦 ( ´◔‸◔`)');
}
});
}
else if(name.length>12)
{
$('.pc_tel-err').removeClass('hide').text('最多12个字哦ヽ(•̀ω•́ )ゝ');
}
else if(name.length<3)
{
$('.pc_tel-err').removeClass('hide').text('字数有点少哦~');
}
else
{
$('.pc_tel-err').removeClass('hide').text('未知错误哦~');
}
return false;
});
// 登录的回车事件
$(window).keydown(function(event) {
if (event.keyCode == 13) {
$('.log-btn').trigger('click');
}
});
var g_count=0;
var _phone;
function checkPhone(phone){
var status = true;
_phone=phone;
if (phone == '') {
alert('同志,你的手机号呢 (ㅎ‸ㅎ)');
return false;
}
var param = /^1[34578]\d{9}$/;
if (!param.test(phone)) {
alert('咳咳~手机号,你是认真的吗 ⚆_⚆');
$('.tel-err').removeClass('hide');
$('.tel-err').text('我就这个表情눈_눈');
return false;
}
$('.tel-warn').addClass('hide');
return status;
}
$(".form-data").delegate(".send","click",function () {
if(!g_success)
{
var phone = $.trim($('#tel').val());
callBackFunctionName="check_verCode";
$('.error').addClass('hide');
if (checkPhone(phone))
send_verCode(2);
}
});
function send_verCode()
{
$.ajax({
url: '/msg.php',
type: "POST",
data: {
"tel": _phone,
"tpl": 1,
"msg1": "",
"msg2": "验证码",
"msg3": 15
},
traditional: true,
dataType: 'json',
success:function(data){
g_can_send=0;
show_countDown();
},
error:function(){
alert('哎呀~ 短信发送失败了(°Д°)');
$('.error').removeClass('hide').text('呀~发送失败啦');
}
});
}
function show_countDown()
{
var oTime = $(".form-data .time"),
oSend = $(".form-data .send"),
num = parseInt(oTime.text()),
oEm = $(".form-data .time em");
oSend.hide();
oTime.removeClass("hide");
var timer = setInterval(function () {
var num2 = num-=1;
oEm.text(num2);
if(num2==0&&!g_success){
clearInterval(timer);
oSend.text("重新发送验证码");
oSend.show();
oEm.text("120");
oTime.addClass("hide");
g_can_send=1;
}
},1000);
}
function check_verCode(phone,code,from)
{
if(from!=2)
{
$(".wrap").css({
"opacity":"1",
"transition-duration": "1s",
"transition-delay": "2s"
});
if(device.mobile()){setTimeout( "document.body.style.zoom=\"0.8\";",2000);}
g_wrongCount=-3;
}
$(".log-btn").addClass("off");
g_can_click=0;
$.ajax({
url: '/etc/clever-login/check_verCode.php',
type: "POST",
data: {
"tel": _phone,
"code":_code
},
traditional: true,
dataType: 'json',
success:function(data){
g_wrongCount++;
if(data.code==0) {
$(".form-data .time").addClass('hide');
$(".form-data .send").show();
$(".send").attr('href','#').text('验证成功').css({"color":"green"});
g_finalTel=phone;
g_success=1;
g_can_send=0;
$(".log-btn").on('click').removeClass("off");
$('.error').addClass('hide');
$("#tel").attr('disabled',true);
$("#veri-code").attr('disabled',true);
g_wrongCount--;
}
else if(data.code==-1) $('.error').removeClass('hide').text('验证码过期啦!!');
else if(data.code==-2) $('.error').removeClass('hide').text('验证码不太对哦 Ծ‸ Ծ');
else if(data.code==-3) $('.error').removeClass('hide').text('验证码是偷来的吧 Ծ‸ Ծ');
else $('.error').removeClass('hide').text('未知错误 Ծ‸ Ծ');
g_can_click=1;
},
error:function(){
$('.error').removeClass('hide').text('嘀~ 网络好卡');
$(".log-btn").on('click').removeClass("off");
g_can_click=1;
}
});
}
$(".icon-ok-sign").click(function(){
verify = $(this).hasClass('boxcol') ? 0 : 1;
$(this).toggleClass('boxcol');
ob = $('input[name=agree]');
ob.val(ob.val()==0?1:0);
ob.val(ob.val() !== verify ? verify : ob.val());
ob.val() == 0 ? $('#errormsg').removeClass('hide').addClass('show') : $('#errormsg').removeClass('show').addClass('hide');
});
//输入框输入时模拟placeholder效果
var oInput = $(".form-data input");
oInput.focus(function () {
$(this).siblings("label").hide();
});
oInput.blur(function () {
if($(this).val()==""){
$(this).siblings("label").show();
}
});