var maxErrorNum = 5; /** * PC登录 **/ $(document).ready(function() { $(".input_bar").click(function(){ var it = $(this).parents("li").find("input.txt"); if(it.val() == ""){ $(this).hide(); it.focus(); } }); $("input.txt").blur(function(){ if($(this).val() == ""){ $(this).parents("li").find(".input_bar").show(); } }).keyup(function(){ $(this).next(".input_bar").hide(); }).focus(function(){ $(this).next(".input_bar").hide(); }); var username = GetCookie("username"); var passwd = GetCookie("passwdNew") || GetCookie("passwdNew")=="" ? decryptPwd(GetCookie("passwdNew")) : GetCookie("passwd"); var ck = GetCookie("checkbox"); var $chkTerms = $('#chk-terms'); var checked_loginterms = localStorage.getItem("loginTerms");//登录条款 var $linkDemo = $(document.getElementById('link-demo') || document.getElementById('experie')); if($chkTerms.length && +checked_loginterms){//默认勾选条款 $chkTerms[0].checked = true; } if(username) { $("input[name=username]").val(username); $($(".input_bar")[0]).hide(); try{$($(".clean_input")[0]).show();}catch(e){} if(passwd) { $("input[name=passwd]").val(passwd); $($(".input_bar")[1]).hide(); $("input[name=remeber]").attr("checked","checked"); try{$($(".clean_input")[1]).show();$(".eye_passwd").show();}catch(e){} } else { $('input[name="passwd"]')[0].focus(); $(".input_bar")[1].click(); try{$($(".clean_input")[1]).hide();$(".eye_passwd").hide();}catch(e){} } } else { $('input[name=username]')[0].focus(); try{$(".input_bar")[0].click();}catch(e){} try{$(".clean_input")[0].hide();}catch(e){} } $("input").each(function(){ $(this).bind("keyup",function(e){ var _this = this; if($(_this).val() == ""){ try{ $(_this).parents("li").find(".clean_input").hide(); $(_this).parents("li").find(".eye_passwd").hide(); }catch(e){} } else { try{ $(_this).parents("li").find(".clean_input").show(); $(_this).parents("li").find(".eye_passwd").show(); }catch(e){} } if(e.keyCode==13){ setLogin(); } }); }); $("#login").click(function(){ setLogin(); }); function writecookieAjax(customer_type,dealerv2) { var token = GetCookie("token"); $.ajax({ type: "GET", url:window.GPSDATA_URL+"SystemService?method=wc&token="+token+"&_t="+ Date.now(), dataType:'json', dataType: "jsonp", success:function(data){ //console.log(data); try{ var lang = GetCookie("lang"); //语言 _hmt.push(['_trackEvent', lang , "点击", "登录"]); }catch(e){} var router = ""; //获取返回原有界面的参数 if(location.href.indexOf("router") != -1){ router = location.href.split("router=")[1]; } if(customer_type==1)//如果是经销商 { SetCookie("dealerv2",dealerv2?1:0); var countDealer2 = +GetCookie("count_dealer2");//点击新版入口超3次,则默认跳转到新版 var url = ( dealerv2 || countDealer2 > 3) ? "/dealer2/"+(router?router:"") : "/dealer/#home"; window.location.href = url; } else { //window.location.href = '/page/'; var url = '/V2/index.jsp'+(router?"#/"+router:""); window.location.href = url; } localStorage.setItem("webtitle",document.title); } }); } var isLoading = false; function setLogin(){ if(isLoading) return; var un= $.trim($('input[name=username]').val()), pd= $.trim($('input[name=passwd]').val()), isdemo = $linkDemo.data('clicked') == '1'; if(!un){ $(".tips").eq(0).html(lg.accountNull).show();//"请输入您的用户名!" $('input[name=username]').focus(); return false; } if(!pd){ alert(lg.inputPwd); $('input[name=passwd]').focus(); return false; } if(!isdemo && $chkTerms.length){//非点击demo 有条款框时才验证勾选(也即:点demo时,不验证条款) if($chkTerms[0].checked){ localStorage.setItem("loginTerms",1); }else{ alert(lg.agreeTerms); return false; } } if(typeof slideVerify != "undefined"){ //兼容其他定制域名 if($("#verifyBox").css("display") == "none"){ var errorCount = GetCookie("errorCount") || 0; if(errorCount>=maxErrorNum){ //超过3次显示验证码 $("#verifyBox").show(); return; } } else if(!slideVerify.slideFinishState){ alert(lg.slideVerifyError); return; } } if(!isdemo){ SetCookie("username",un); if($("#remeber").is(":checked")){ SetCookie("checkbox","on"); SetCookie("passwdNew",encryptPwd(pd)); DelCookie("passwd"); }else{ SetCookie("checkbox","off"); SetCookie("passwdNew",""); DelCookie("passwd"); } pd = hex_md5(pd); } isLoading = true; //$('input[name=passwd]').val(pd); $.ajax({ type:"POST", url:'/LoginService?method=login&username='+encodeURIComponent(un)+'&passwd='+pd+'&logintype=webcustomer&_t='+ Date.now() +'&tzOffset='+timezoneOffset(), //data:'&username='+un+'&passwd='+pd+'&logintype='+lt, dataType:'json', contentType:'application/json', success:function(data){ isLoading = false; if(data.errorcode==0){ writecookieAjax(data.customer_type,data.dealerv2); SetCookie("errorCount",0); }else{ var domain = document.domain; var indiaIndex=domain.indexOf("indiatracks.com"); if(indiaIndex >= 0 && data.errorcode == 20001){ alert("Due to new update, if login fail, please try account with prefix \"in\"."); }else{ alert(lg[data.errorcode]); } var errorCount = GetCookie("errorCount") || 0; SetCookie("errorCount",parseInt(errorCount)+1); window.location.href = "/"; } }, complete: function(){ isLoading = false; }, error: function(){ isLoading = false; } }); }; function getInfo() { if(typeof notGetCustom != "undefined") return; $.get('/api2/tool/custom/get',function(res){ if(res.record && res.record.showdemo == "1" && $linkDemo[0]) $linkDemo.show(); if(res.record && res.record.showapplink == "1" && $("#appLink")) $("#appLink").show(); if(res.record && res.record.showreleasenote == "1" && $("#releaseNote")) $("#releaseNote").show(); if(res.record && res.record.showretrievepassword == "1" && $("#findPass")) $("#findPass").show(); }) } getInfo() });