var _gaq = _gaq || []; _gaq.push(['_setaccount', 'ua-27017864-1']); _gaq.push(['_trackpageview']); var loginuser=''; if(loginuser){ var loginuser = eval("(" + jsonescape(loginuser) + ")"); } var pageneedcaptcha = false; $(function(){ if($('#useremail').val()!='') { $("#email_desc").hide(); } else { $("#email_desc").show(); } if($('#userpassword').val()!='') { $("#password_desc").hide(); } else { $("#password_desc").show(); } checkemail(); $('#imgslide01').doimages({ imgs:$("#imgslide01 img"), thumbs:$("#imgslide02 >a"), num:0, thumbsclass:"curimg", auto:true, bgobj:$('#zmjsimgslide-0'), bgcolor:['#cad3d9','#c3dcdf','#dfcec3'], time:3000 }); $(document).keydown(function(event){ if(event.which == 13){ login(); } }) $('#useremail').live('keyup',function(){ if($(this).val()!='') { $("#email_desc").hide(); } }).focus(function(){ $("#label_user").addclass("label-true"); }); $('#userpassword').live('keyup',function(){ if($(this).val()!='') { $("#password_desc").hide(); } }).focus(function(){ $("#label_pwd").addclass("label-pwd-true"); }); /* $("#useremail, #email_desc").focusin(function(){ $("#label_user").addclass("label-true"); $("#email_desc").empty(); $("#useremail").focus(); }).focusout(function(){ $("#label_user").removeclass("label-true"); checkemail(); }); $("#userpassword, #password_desc").focusin(function(){ $("#label_pwd").addclass("label-pwd-true"); $("#password_desc").empty(); $("#userpassword").focus(); }).focusout(function(){ $("#label_pwd").removeclass("label-pwd-true"); checkpassword(); }); */ }); function checkemail(){ $("#email_desc").hide(); var useremail = $.trim($("#useremail").val()); if(useremail.length == 0){ $("#email_desc").show(); $("#errortips1").hide(); $("#tips_user").hide(); return -1; }else{ var regexp = /^([a-za-z0-9_\-\.])+\@([a-za-z0-9_\-\.])+\.([a-za-z]{2,3})$/; if(!regexp.test(useremail)){ $("#tips_user").removeclass("true").addclass("error").show(); $("#errortips1").text("邮箱格式不正确").show(); return -2; }else{ $("#tips_user").removeclass("error").addclass("true").show(); $("#errortips1").hide(); $.post("/logincheck",{useremail:useremail, r:math.random()}, function(data){ if(data == 1){ if(!pageneedcaptcha){ pageneedcaptcha = true; showcaptcha(); } }else{ if(pageneedcaptcha){ pageneedcaptcha = false; hidecaptcha(); } } }) return 1; } } } function checkpassword(){ $("#password_desc").hide(); var userpassword = $.trim($("#userpassword").val()); if(userpassword.length == 0){ $("#password_desc").show(); $("#errortips2").hide(); return -1; }else if(userpassword.length < 6 || userpassword.length > 16){ $("#tips_pwd").removeclass("true").addclass("error").show(); $("#errortips2").text("密码为6~16个字母、数字或符号,区分大小写!").show(); return -2; }else{ $("#tips_pwd").hide(); $("#errortips2").hide(); return 1; } } function showcaptcha(){ $(".validateimg").attr("src","/captcha/image.html?r="+math.random()); $("#validatecode").slidedown(1000,function(){}); } function hidecaptcha(){ $("#validatecode,#errortips3").slideup(1000,function(){}); } function login(){ var checkemailresult = checkemail(); if(checkemailresult == -1){ $("#tips_user").removeclass("true").addclass("error").show(); $("#errortips1").text("邮箱不能为空").show(); $("#useremail").focus(); return; } var checkpasswordresult = checkpassword(); if(checkpassword() == -1){ $("#tips_pwd").removeclass("true").addclass("error").show(); $("#errortips2").text("密码不能为空").show(); $("#userpassword").focus(); return; } if(checkemailresult != 1 || checkpasswordresult != 1){ return; } var useremail = $.trim($("#useremail").val()); var userpassword = $.trim($("#userpassword").val()); var userkeeplogin = $("#rememberpwd").val(); var captcha = $.trim($("#captcha").val()); $.post("/ajaxlogin", {useremail:useremail, userpassword:userpassword, userkeeplogin:userkeeplogin, pageneedcaptcha:pageneedcaptcha, captcha:captcha, r:math.random()}, function(data){ switch(data.status){ case 1: switch(0){ case 2: location.href = "http://www.zhimei.com/pin/forward_bind"; break; case 3: location.href = "http://www.zhimei.com"; break; case 4: location.href = "http://www.zhimei.com"; break; default: location.href = "http://www.zhimei.com/home"; } break; case 2: $("#errortips3").text("邮箱或者密码错误").show(); break; case 3: $("#errortips3").text("验证码错误").show(); break; case 4: $("#errortips3").text("帐号或密码错误,请重试").show(); break; case 5: $("#errortips3").text("该帐号已被冻结").show(); break; case 6: pageneedcaptcha = !0; $("#errortips3").text(data.desc).show(); showcaptcha(); break; default: return false; } },'json') }