Browse Source

fix: 防止重复发起获取用户信息的请求

lsc 1 week ago
parent
commit
47a305edff
1 changed files with 7 additions and 2 deletions
  1. 7 2
      szdjg/Onload.js

+ 7 - 2
szdjg/Onload.js

@@ -320,6 +320,7 @@ let LoginState = false
 let CookieS = ''
 let CookieCheckTimes = 0
 let isPanL = false
+let _loginInFlight = false
 U.MD.D.getuser = function () {
     // $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gif/longhuaBg.gif")'
     var userInfo = US.userInfo;
@@ -328,8 +329,10 @@ U.MD.D.getuser = function () {
         LoginState = true
 
         var _cookie = U.UF.Cookie.get("cocorobo");
-        if (Object.keys(userInfo).length === 0 && _cookie) {
+        if (Object.keys(userInfo).length === 0 && _cookie && !_loginInFlight) {
+            _loginInFlight = true;
             U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
+                _loginInFlight = false; 
                 if (res.value && res.value[0] && res.value[0][0]) {
                     var _user = res.value[0][0];
                     U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + _user.userid, [], function (res) {
@@ -709,11 +712,13 @@ U.MD.D.getuser = function () {
     }else if(LoginState && !CookieS){
         CookieS = _cookie
         U.UF.Cookie.set("cocoroboLoginType=2");
-    }else if(LoginState && _cookie && !isPanL){
+    }else if(LoginState && _cookie && !isPanL && !_loginInFlight){
         CookieCheckTimes++
         if (CookieCheckTimes % 5 !== 0) return;
         isPanL = true
+        _loginInFlight = true;
         U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
+            _loginInFlight = false;   
             if (res.value && res.value[0] && res.value[0][0]) {
                 isPanL = false
             }else if(res.status && res.status.status != 0){