PageSourceSearch

https://www.protrack365.com/page/js/login_v2.js?v=202609200856

js protrack365.com collected 2026-10-01 13:14:56 UTC 19,829 bytes, 640 lines download raw bytes

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">&times;</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.