<script>
var refer=‘https://www.juhe.cn/myData/index/checked/0‘;
var active =‘‘
$(document).ready(function(){
nslog(1200);
if(active!=‘‘)
{
nslog(1201);
layer.msg(‘账号激活成功‘, {icon: 1,time: 1500}, function(){});
}
$("#loginBtn").click(function(){
$(‘.sysError‘).css(‘display‘,‘none‘);
$(‘.errorTips‘).css(‘display‘,‘none‘);
$("#loginBtn").val(‘登录中...‘).prop("disabled",true);
var username = $("#username").val();
var userpass = $("#password").val();
var captcha = $("#captcha").val();
username = $.trim(username);
userpass = $.trim(userpass);
captcha = $.trim(captcha);
if(username.length <5){
showError(‘请输入正确格式的用户名!‘,$("#username"));
}
else if(userpass.length <6){
showError(‘请输入正确格式的密码!‘,$("#password"));
}
else if($(".loginListCode").css(‘display‘)==‘block‘ && captcha == ‘‘){
showError(‘请输入正确的验证码‘,$("#captcha"));
}
else{
$("#login_form").ajaxSubmit(function(e){
var obj = json_parse(e);
var code = obj.code;
//当用户登录错误且次数超过3次,显示验证码
if(code != ‘1‘ && $(".loginListCode").css(‘display‘)==‘none‘ && obj.errcount>2)
{
$(".loginListCode").css(‘display‘,‘block‘);
}
if(code == ‘1‘)
{
if(refer){
window.location.href = refer;
}else{
window.location.href = ‘/account‘;
}
}
else
{
if(code == ‘-1‘){//登录数据库验证,登录失败显示
$(‘.sysError‘).show().find(‘em‘).html(obj.info);
}else if(code == ‘-4‘){//未激活状态显示
if(!isEmail(obj.email))
{
var info =‘账户未激活且未绑定邮箱,‘+‘<a href="http://crm2.qq.com/page/portalpage/wpa.php?uin=800076065&f=1&ty=1&aty=0&a=&from=6" target="_blank">联系客服</a>‘;
}
else
{
var info = obj.info+‘或 <a id="resendEmail" href="javascript:;" username="‘+obj.username+‘" email="‘+obj.email+‘">重新发送邮件</a>‘;
}
$(‘.sysError‘).show().find(‘em‘).html(info);
}else if(code == ‘-6‘){//验证码错误显示
$(".loginListCode").css(‘display‘,‘block‘);
showError(obj.info,$("#captcha"));
}else if(code == ‘-3‘){//验证码错误显示
showError(obj.info,$("#username"));
}else{
var errcount = obj.errcount;
if(errcount>2){
$(".loginListCode").css(‘display‘,‘block‘);
}
$(‘.sysError‘).show().find(‘em‘).html(obj.info);
}
if($(".loginListCode").css(‘display‘)==‘block‘)
{
$("#captchaimg").click();
}
$("#loginBtn").val(‘登录‘).prop("disabled",false);
return false;
}
})
}
$(".sysError").on(‘click‘,‘#resendEmail‘,function(){
layer.closeAll();
layer.load(1,{shade:0.3});
var username = $(this).attr(‘username‘).trim();
var email = $(this).attr(‘email‘).trim();
if(username.length < 5 && !isEmail(email))
{
layer.msg(‘用户信息有误,请联系管理员‘,{icon:2,time:‘3000‘,shade:0.3,shadeClose:true});
return false;
}
else
{
$.post(‘/register/resendEmail‘,{username:username,email:email},function(e){
var obj = json_parse(e);
if(obj.code==‘1‘ ){
window.location.href = obj.acturl;
}
else
{
layer.closeAll()
layer.msg(obj.info,{icon:2,time:‘3000‘,shade:0.3,shadeClose:true});
}
})
}
})
})
//验证码刷新
$("#captchaimg").click(function(){
$("#vercodeImg").attr(‘src‘,‘/vercode?‘+new Date().getTime());
})
//bind keyCode=13 Event
document.onkeydown = function(e){
var ev = document.all ? window.event : e;
if(ev.keyCode==13) {
$("#loginBtn").click();
}
}
})
//错误显示
function showError(msg,selector)
{
selector.parent().find(‘.errorTips‘).find(‘em‘).html(msg)
selector.parent().find(‘.errorTips‘).fadeIn();
$("#loginBtn").val(‘登录‘).prop(‘disabled‘,false);
}
</script>