1var maxErrorNum = 5; 2// ç¹æ®blockï¼éæç¤º 3var blockAccountErrorCode = 40001 4/** 5 * PCç»å½ 6 **/ 7$(document).ready(function() { 8 9 var username = GetCookie("username"); 10 var passwd = GetCookie("passwdNew") || GetCookie("passwdNew")=="" ? decryptPwd(GetCookie("passwdNew")) : GetCookie("passwd"); 11 var rememberPassword = GetCookie("checkbox"); 12 var $chkTerms = $('#chk-terms'); 13 var checked_loginterms = localStorage.getItem("loginTerms");//ç»å½æ¡æ¬¾ 14 var $rowAccount = $(".row-account"); 15 var $rowPassword = $(".row-password"); 16 var $linkDemo = $(document.getElementById('link-demo') || document.getElementById('experie')); 17 var $imgPortrait = $('#img-portrait'); 18 var hasPortrait = $imgPortrait.length > 0; 19 20 if($chkTerms.length && +checked_loginterms){//é»è®¤å¾éæ¡æ¬¾ 21 $chkTerms[0].checked = true; 22 } 23 24 if(username){ 25 $("input[name=username]").val(username); 26 $($(".input_bar")[0]).hide(); 27 try{$rowAccount.addClass('show-clean');}catch(e){} 28 // $(".input_bar")[1].click(); 29 $(".input_bar").eq(1).click(); 30 31 if(rememberPassword == "on" && passwd){ 32 $("input[name=passwd]").val(passwd); 33 $($(".input_bar")[1]).hide(); 34 $('#span_chk_remember').addClass('checked'); 35 if( $("input[name=remeber]").length ){ 36 $("input[name=remeber]").attr("checked","checked"); 37 } 38 try{ 39 $rowPassword.addClass('show-clean'); 40 $rowPassword.addClass('show-viewpass'); 41 }catch(e){} 42 }else{ 43 $('input[name="passwd"]')[0].focus(); 44 try{ 45 $rowPassword.removeClass('show-clean'); 46 $(".eye_passwd").parent('li').removeClass('show-viewpass'); 47 }catch(e){} 48 } 49 }else{ 50 $('input[name=username]')[0].focus(); 51 try{$(".input_bar")[0].click();}catch(e){} 52 try{$rowAccount.removeClass('show-clean');}catch(e){} 53 } 54 55 //è¾å ¥æ¶ å³è¾¹å¾æ çæ¾ç¤ºæ§å¶ 56 $("input").each(function(){ 57 $(this).bind("keyup",function(e){ 58 fnIptChange($(this),e) 59 }); 60 }); 61 62 // æ¯å¦è½®è¯¢è·åäºç»´ç ä¿¡æ¯ 63 var qrTimeObj = null; 64 // æ¾ç¤ºäºç»´ç ç»å½ 65 $("#ewm-btn").click(function() { 66 showLoginQR(); 67 }); 68 // æ¾ç¤ºPCç»å½ 69 $("#pc-btn").click(function() { 70 showPC(); 71 });
72 // å·æ°äºç»´ç 73 $("#reloadQrBtn").click(function() { 74 showLoginQR(); 75 }); 76 77 function fnIptChange($ipt,e){ 78 // var $lis = $ipt.parents("li"); 79 var $li = $ipt.parent(); 80 $li.click(); 81 if($ipt.val() == ""){//æ å¼ 82 try{ 83 $li.find(".clean_input").parent('li').removeClass('show-clean');//hide clean 84 $li.find(".eye_passwd").parent('li').removeClass('show-viewpass');//hide viewpass 85 // $li.find(".input_bar").show();//label show 86 }catch(e){} 87 }else{//æå¼ 88 try{ 89 $li.find(".clean_input").parent('li').addClass('show-clean');//show clean 90 $li.find(".eye_passwd").parent('li').addClass('show-viewpass');//show viewpass 91 $li.find(".input_bar").hide();//label hide 92 }catch(e){} 93 } 94 // if(e && e.keyCode==13){ 95 // setLogin(); 96 // } 97 } 98 99 100//æ¸ é¤è¾å ¥ 101 $(".clean_input").click(function () { 102 var $li = $(this).parent("li"); 103 $li.removeClass('show-clean'); 104 $li.find("input").val("").focus(); 105 $rowPassword.removeClass('show-viewpass'); 106 if ($(this).parent("li").index() == 0) { // å¦ææ¯æ¸ é¤ç¨æ·åï¼åå¯ç 乿¸ é¤ 107 $rowPassword.find("input").val(""); 108 $rowPassword.removeClass('show-clean'); 109 $rowPassword.removeClass('show-viewpass'); 110 $($(".input_bar")[1]).show(); 111 resetPortrait(); 112 } 113 }); 114 115 //æ¥çå¯ç 116 $(".eye_passwd").click(function () { 117 var th = $(this), 118 target = th.parent("li").find("input"); 119 if (th.hasClass("close")) { //妿å½åæ¯ææ 120 th.removeClass("close"); 121 target.attr("type", "password"); 122 } else { //å½åæ¯éèç 123 th.addClass("close"); 124 target.attr("type", "text"); 125 } 126 }); 127 128 //è¾å ¥æ¡ä¸çæå ç¹å» 129 $(".input_bar").click(function(){ 130 var $ipt = $(this).parents("li").find("input.ipt"); 131 $(this).hide(); 132 $ipt.focus(); 133 fnIptChange($ipt); 134 }); 135 136 //è¾å ¥æ¡ä¸çæåæ¾ç¤º 137 $("input.ipt").blur(function(){ 138 if($(this).val() == ""){ 139 $(this).parents("li").find(".input_bar").show(); 140 } 141 }).keyup(function(){ 142 $(this).next(".input_bar").hide(); 143 }).focus(function(){ 144 $(this).next(".input_bar").hide(); 145 }); 146 147 $("#form-login").submit(function(){ 148 setLogin(); 149 }); 150 151 function writecookieAjax(params){ 152 var token = GetCookie("token"); 153 $.ajax({ 154 type: "GET", 155 url:window.GPSDATA_URL+"SystemService?method=wc&token="+token+"&_t="+ Date.now(), 156 dataType:'json', 157 dataType: "jsonp", 158 timeout: 10000, 159 success:function(data){ 160 loginSuccess(params) 161 try{ 162 var lang = GetCookie("lang"); //è¯è¨ 163 _hmt.push(['_trackEvent', lang , "ç¹å»", "ç»å½"]); 164 }catch(e){} 165 }, 166 complete: function(){ 167 hideLoading(); 168 }, 169 }); 170 171 setTimeout(function(){ 172 alert(lg.netError); 173 hideLoading(); 174 },10000) 175 } 176 177 var isLoading = false, 178 $btnSubmit = $('#btn-submit'), 179 showLoading = function(){ 180 isLoading = true; 181 $btnSubmit.addClass('loading'); 182 }, 183 hideLoading = function(){ 184 isLoading = false; 185 $btnSubmit.removeClass('loading'); 186 // $btnSubmit.addClass('redirecting'); 187 }; 188 189 function setLogin(){ 190 if(isLoading) return; 191 var un= $.trim($('input[name=username]').val()), 192 pd= $.trim($('input[name=passwd]').val()), 193 isdemo = $linkDemo.data('clicked') == '1'; 194 if(!un){ 195 alert(lg.accountNull); 196 //$(".tips").eq(0).html(lg.accountNull).show();//"请è¾å ¥æ¨çç¨æ·åï¼" 197 $('input[name=username]').focus(); 198 return false; 199 } 200 if(!pd){ 201 alert(lg.inputPwd); 202 $('input[name=passwd]').focus(); 203 return false; 204 } 205 206 if(!isdemo && $chkTerms.length){//éç¹å»demo ææ¡æ¬¾æ¡æ¶æéªè¯å¾éï¼ä¹å³ï¼ç¹demoæ¶ï¼ä¸éªè¯æ¡æ¬¾ï¼ 207 if($chkTerms[0].checked){ 208 localStorage.setItem("loginTerms",1); 209 }else{ 210 alert(lg.agreeTerms); 211 return false;
212 } 213 } 214 215 if(typeof slideVerify != "undefined"){ //å ¼å®¹å ¶ä»å®å¶åå 216 if($("#verifyBox").css("display") == "none"){ 217 var errorCount = GetCookie("errorCount") || 0; 218 if(errorCount>=maxErrorNum){ //è¶ è¿3次æ¾ç¤ºéªè¯ç 219 $("#verifyBox").show(); 220 return; 221 } 222 } else if(!slideVerify.slideFinishState){ 223 alert(lg.slideVerifyError); 224 return; 225 } 226 } 227 228 if(!isdemo){ 229 230 SetCookie("username",un); 231 232 SetCookie("checkbox", $('#span_chk_remember').hasClass('checked') ? "on" : "off"); 233 SetCookie("passwdNew",encryptPwd(pd)); 234 DelCookie("passwd"); 235 236 pd = hex_md5(pd); 237 } 238 showLoading(); 239 //$('input[name=passwd]').val(pd); 240 $.ajax({ 241 type:"POST", 242 url:'/LoginService?method=login&username='+encodeURIComponent(un)+'&passwd='+pd+'&logintype=webcustomer&_t='+ Date.now() +'&tzOffset='+timezoneOffset(), 243 //data:'&username='+un+'&passwd='+pd+'&logintype='+lt, 244 dataType:'json', 245 contentType:'application/json', 246 success:function(data){ 247 if(data.errorcode==0){ 248 writecookieAjax(data); 249 SetCookie("errorCount",0); 250 SetCookie("showOldVersion",data.showoldversion, 3650*24*60*60*1000 , "/", location.host); 251 SetCookie("isDemo",data.isdemo); 252 } else if(data.errorcode == blockAccountErrorCode) { 253 // ç»å½Blockè´¦å·æ¶èªå®ä¹é误æç¤º 254 showBlockConfirm() 255 var errorCount = GetCookie("errorCount") || 0; 256 SetCookie("errorCount",parseInt(errorCount)+1); 257 hideLoading(); 258 } else{ 259 alert(lg[data.errorcode]); 260 var errorCount = GetCookie("errorCount") || 0; 261 SetCookie("errorCount",parseInt(errorCount)+1); 262 window.location.href = "/"; 263 } 264 }, 265 complete: function(){ 266 }, 267 error: function(){ 268 hideLoading(); 269 } 270 }); 271 }; 272 273 // ç»å½æå 274 function loginSuccess(data) { 275 SetCookie("errorCount",0); 276 SetCookie("customerid",data.customerid); 277 savePortrait(data.account, data.portrait || ''); 278 delClientData('hasViewDescription'); 279 280 var router = ""; //è·åè¿ååæçé¢çåæ° 281 if(location.href.indexOf("router") != -1){ 282 router = location.href.split("router=")[1]; 283 } 284 if(data.customer_type==1) {//妿æ¯ç»éå 285 SetCookie("dealerv2",data.dealerv2?1:0); 286 var countDealer2 = +GetCookie("count_dealer2");//ç¹å»æ°çå ¥å£è¶ 3次ï¼åé»è®¤è·³è½¬å°æ°ç 287 var url = ( data.dealerv2 || countDealer2 > 3) ? "/dealer2/"+(router?router:"") : "/dealer/#home"; 288 window.location.href = url; 289 }else{ 290 var url = '/V2/index.jsp'+(router?"#/"+router:""); 291 window.location.href = url; 292 } 293 localStorage.setItem("webtitle",document.title); 294 } 295 296 // ç»å½Blockè´¦å·æ¶èªå®ä¹é误æç¤º 297 function showBlockConfirm() { 298 customConfirm({ 299 title: lg.tips, 300 message: lg.loginBlockTips.replace("{br}", "<br />"), 301 confirmText: lg.payNow, 302 cancelText: lg.contactUs 303 }, function(result) { 304 // 确认ç¹å» 305 if(result == "confirm") { 306 if(BLOCK_ACCOUNT_DETAIL_LINK && BLOCK_ACCOUNT_DETAIL_LINK.length !=0 ) { 307 window.open(BLOCK_ACCOUNT_DETAIL_LINK) 308 } 309 } else if (result == "cancel") { 310 if(BLOCK_ACCOUNT_CANCEL_LINK && BLOCK_ACCOUNT_CANCEL_LINK.length !=0 ) { 311 window.open(BLOCK_ACCOUNT_CANCEL_LINK) 312 } 313 } 314 }) 315 } 316 317 function getInfo() { 318 if(typeof notGetCustom != "undefined") return; 319 $.get('/api2/tool/custom/get',function(res){ 320 if(res.record && res.record.showdemo == "1" && $linkDemo[0]) $linkDemo.show(); 321 if(res.record && res.record.showapplink == "1" && $("#appLink")) $("#appLink").show(); 322 if(res.record && res.record.showreleasenote == "1" && $("#releaseNote")) $("#releaseNote").show(); 323 if(res.record && res.record.showretrievepassword == "1" && $("#findPass")) $("#findPass").show(); 324 }) 325 } 326 getInfo() 327 328 setInterval(function(){//å¤çï¼[æµè§å¨çº§è®°ä½å¯ç å¡«å½å¯ç æ¶ ä¸è§¦åinputäºä»¶]çé®é¢ 329 if($('#username_login').val()){ 330 $(".input_bar").eq(0).hide(); 331 } 332 // fnIptChange($('#username_login')); 333 fnIptChange($('#password_login')); 334 // console.log($('#password_login').val()) 335 },600); 336 337 var 338 savePortrait = function(account, portrait){ 339 var portraitClient = getClientData('loginPortrait'); 340 var portraitData = portraitClient ? JSON.parse(portraitClient) : {}; 341 portraitData[account] = portrait; 342 setClientData('loginPortrait',JSON.stringify(portraitData)); 343 }, 344 resetPortrait = function(){ 345 var defaultportrait = '/images/v2/img_portrait.png'; 346 setPortrait('',defaultportrait); 347 }, 348 showPortrait = function(account){ 349 var portraitClient = getClientData('loginPortrait'); 350 if(portraitClient){ 351 var portraitData = JSON.parse(portraitClient); 352 var portraitStr = portraitData[account]; 353 if(account && portraitStr){ 354 setPortrait(account,portraitStr); 355 }else{ 356 resetPortrait(); 357 } 358 } 359 }, 360 setPortrait = function(account,portrait){ 361 if(!hasPortrait){return;} 362 $imgPortrait.attr('src',portrait) 363 .attr('title',account); 364 }, 365 bindEvent = function(){ 366 $('#username_login').change(function(){//ç»å½å¤´åå¤ç 367 var account = $.trim(this.value); 368 showPortrait(account); 369 }); 370 }, 371 372 showPortrait = function(account){ 373 var portraitClient = getClientData('loginPortrait'); 374 if(portraitClient){ 375 var portraitData = JSON.parse(portraitClient); 376 var portraitStr = portraitData[account]; 377 if(account && portraitStr){ 378 $imgPortrait.attr('src',portraitStr) 379 .attr('title',account); 380 }else{ 381 resetPortrait(); 382 } 383 } 384 }, 385 init = function(){ 386 if(!hasPortrait){return;} 387 showPortrait(username); 388 bindEvent(); 389 }; 390 391 init(); 392 393 // æ«ç ç»å½ä¿¡æ¯è·å 394 var getLoginQR = function() { 395 $.get("/api2/tool/v1/qrcode/show",function(res) { 396 if (res.errorcode == 0) { 397 $("#loginQR>canvas").remove(); 398 $("#loginQR>img").remove(); 399 $(".ewm-status").hide(); 400 new QRCode(document.getElementById("loginQR"), { 401 text: res.record.qrcodeContent, 402 width: 180, 403 height: 180, 404 correctLevel: QRCode.CorrectLevel.M, 405 }); 406 407 $("#scanTips").text(lg.scanCodeTips.replace("{{name}}", res.record.appName)); 408 $("#loginQR").attr("title", ""); 409 410 getLoginStatus(res.record.clientKey); 411 } else { 412 413 } 414 }) 415 }, 416 // è·åç»å½ç¶æ 417 getLoginStatus = function(clientKey) { 418 // ä¸è½®è¯¢ 419 if (!clientKey) { 420 return ; 421 } 422 $.get("/api2/tool/v1/qrcode/check?clientKey="+clientKey, function(res) { 423 if(res.errorcode == 0) { 424 var status = res.record.status; 425 // æ«ç æå 426 if (status == 3) { 427 $(".ewm-status").show(); 428 $(".ewm-status-icon").attr("class", "ewm-status-icon ewm-status-success"); 429 $(".ewm-status-txt").text(lg.scanSuccessful); 430 $("#reloadQrBtn").hide(); 431 loopLoginStatus(clientKey); 432 } else if (status == 2) { 433 // æ«ç éªè¯å¤±è´¥ 434 scanLoginQrFail(lg.fail); 435 } else if (status == 4) { 436 // åæ¶ç»å½ 437 scanLoginQrFail(lg.canceled); 438 } else if (status == 6) { 439 // å·²è¿æ 440 scanLoginQrFail(lg.expired); 441 } else if (status == 5){ 442 // ç»å½æå 443 loginSuccess(res.record.data); 444 } else { 445 // çå¾ æ«ç 446 loopLoginStatus(clientKey); 447 } 448 } else { 449 450 } 451 }); 452 }, 453 // 失败 454 scanLoginQrFail = function(txt) { 455 $(".ewm-status").show(); 456 $(".ewm-status-icon").attr("class", "ewm-status-icon ewm-status-fail"); 457 $(".ewm-status-txt").text(txt); 458 $("#reloadQrBtn").show(); 459 }, 460 // 轮询 461 loopLoginStatus = function(clientKey) { 462 if (!clientKey) { 463 return ; 464 } 465 qrTimeObj = setTimeout(function() { 466 getLoginStatus(clientKey); 467 },2000); 468 }, 469 // æ¾ç¤ºäºç»´ç ç»å½ 470 showLoginQR = function() { 471 $("#form-login").hide(); 472 $("#ewm-btn").hide(); 473 $("#pc-btn").show(); 474 $(".ewm-box").show(); 475 if(qrTimeObj) { 476 clearTimeout(qrTimeObj) 477 } 478 // è·åäºç»´ç ä¿¡æ¯ 479 getLoginQR(); 480 }, 481 // æ¾ç¤ºPCç»å½ 482 showPC = function() { 483 $("#form-login").show(); 484 $("#ewm-btn").show(); 485 $("#pc-btn").hide(); 486 $(".ewm-box").hide(); 487 if(qrTimeObj) { 488 clearTimeout(qrTimeObj) 489 } 490 }; 491}); 492 493 494/** 495 * èªå®ä¹ Confirm å¼¹çªï¼ES5 å ¼å®¹çï¼ 496 * @param {Object} options 497 * @param {string} options.title - æ é¢ 498 * @param {string} options.message - å 容 499 * @param {string} [options.confirmText] - 确认æé®æå 500 * @param {string} [options.cancelText] - åæ¶æé®æå 501 * @param {Function} callback - åè°å½æ°ï¼åæ°ä¸º confirm/cancel/close 502 */ 503function customConfirm(options, callback) { 504 options = options || {}; 505 var title = options.title || lg.tips; 506 var message = options.message || ''; 507 var confirmText = options.confirmText || lg.ok; 508 var cancelText = options.cancelText || lg.cancel; 509 510 // 鲿¢éå¤å建 511 if (document.getElementById('customConfirmOverlay')) { 512 return; 513 } 514 515 // ========== æ³¨å ¥æ ·å¼ ========== 516 var style = document.createElement('style'); 517 style.id = 'customConfirmStyle'; 518 style.type = 'text/css'; 519 style.innerHTML = 520 '.modal-overlay {' + 521 'display: flex;' + 522 'position: fixed;' + 523 'top: 0;' + 524 'left: 0;' + 525 'width: 100%;' + 526 'height: 100%;' + 527 'background: rgba(0, 0, 0, 0.5);' + 528 'z-index: 9999;' + 529 'justify-content: center;' + 530 'align-items: center;' + 531 '}
531' + 532 '.modal-box {' + 533 'position: relative;' + 534 'background: white;' + 535 'padding: 20px;' + 536 'border-radius: 8px;' + 537 'width: 300px;' + 538 'margin: auto;' + 539 'box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);' + 540 '}' + 541 '.close-icon {' + 542 'position: absolute;' + 543 'top: 10px;' + 544 'right: 15px;' + 545 'font-size: 24px;' + 546 'color: #999;' + 547 'cursor: pointer;' + 548 'line-height: 1;' + 549 '}' + 550 '.close-icon:hover {' + 551 'color: #333;' + 552 '}' + 553 '#confirmTitle {' + 554 'margin: 0 0 16px 0;' + 555 'font-size: 18px;' + 556 'color: #333;' + 557 '}' + 558 '#confirmMessage {' + 559 'text-align: left;' + 560 'color: #555;' + 561 'line-height: 1.5;' + 562 'margin: 0;' + 563 'word-break: break-word;' + 564 '}' + 565 '.modal-buttons {' + 566 'margin-top: 24px;' + 567 'display: flex;' + 568 'justify-content: space-between;' + 569 'gap: 10px;' + 570 '}' + 571 '.btn {' + 572 'padding: 8px 16px;' + 573 'border: none;' + 574 'border-radius: 4px;' + 575 'cursor: pointer;' + 576 'flex: 1;' + 577 'font-size: 14px;' + 578 '}' + 579 '.btn-confirm {' + 580 'background-color: #E98D08;' + 581 'color: white;' + 582 '}' + 583 '.btn-cancel {' + 584 'background-color: #e0e0e0;' + 585 'color: #333;' + 586 '}'; 587 588 document.getElementsByTagName('head')[0].appendChild(style); 589 590 // ========== å建 DOM ========== 591 var overlay = document.createElement('div'); 592 overlay.id = 'customConfirmOverlay'; 593 overlay.className = 'modal-overlay'; 594 595 overlay.innerHTML = 596 '<div class="modal-box">' + 597 '<span class="close-icon" id="btnClose">×</span>' + 598 '<h3 id="confirmTitle">' + title + '</h3>' + 599 '<p id="confirmMessage">' + message + '</p>' + 600 '<div class="modal-buttons">' + 601 '<button id="btnCancel" class="btn btn-cancel">' + cancelText + '</button>' + 602 '<button id="btnConfirm" class="btn btn-confirm">' + confirmText + '</button>' + 603 '</div>' + 604 '</div>'; 605 606 document.body.appendChild(overlay); 607 608 // ========== å ³éå¹¶æ¸ ç ========== 609 function close(result) { 610 if (overlay && overlay.parentNode) { 611 overlay.parentNode.removeChild(overlay); 612 } 613 if (style && style.parentNode) { 614 style.parentNode.removeChild(style); 615 } 616 if (typeof callback === 'function') { 617 callback(result); 618 } 619 } 620 621 // ç»å®äºä»¶ 622 document.getElementById('btnConfirm').onclick = function () { 623 close("confirm"); 624 }; 625 document.getElementById('btnCancel').onclick = function () { 626 close("cancel"); 627 }; 628 document.getElementById('btnClose').onclick = function () { 629 close("close"); 630 }; 631 632 // ç¹å»é®ç½©å ³é 633 overlay.onclick = function (e) { 634 e = e || window.event; 635 var target = e.target || e.srcElement; 636 if (target === overlay) { 637 close("close"); 638 } 639 }; 640}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.