Browse Source

1

Signed-off-by: lcw <1324309909@qq.com>
lcw 2 years ago
parent
commit
c29c3e4fd9
1 changed files with 42 additions and 47 deletions
  1. 42 47
      js/Desktop/Onload.js

+ 42 - 47
js/Desktop/Onload.js

@@ -22,7 +22,7 @@ U.MD.D.IsUseStudio = true;
 //本地存储类
 U.MD.D.LocalStorage = null;
 
-US.userInfo = {};
+US.userinfo = {};
 //#endregion
 
 //#region onload处理
@@ -200,9 +200,6 @@ U.MD.D.asynCrossDomain = function (cb) {
         cb(); //回调处理
     }
     U.MD.D.getuser(); //用户登录
-    setInterval(() => {
-        U.MD.D.getuser(); //用户登录
-    }, 2000)
 }
 
 /**
@@ -244,7 +241,7 @@ U.MD.D.thirdPartyLoad = function () {
  * 写入访问用户信息
  */
 U.MD.D.visitLog = function () {
-    U.A.Request(US.USER, ["AddToLoginLog", US.userInfo.userid || US.EMPTYGUID, US.city.userAllLocation || ""], function () { }); //访问日志添加消息
+    U.A.Request(US.USER, ["AddToLoginLog", US.userInfo.UserId || US.EMPTYGUID, US.city.userAllLocation || ""], function () { }); //访问日志添加消息
 }
 
 //#endregion
@@ -281,54 +278,52 @@ U.MD.D.error = function (errorMessage, scripturi, linenumber, columnnumber, erro
     return true; //不让浏览器弹出错误报告,浏览器会弹出一个comfirm的错误。
 }
 
-
-/**
- * 用户登录处理
- */
 U.MD.D.getuser = function () {
-    var userInfo = US.userInfo;
-    if (Object.keys(userInfo).length === 0) {
-        var _cookie = U.UF.Cookie.get("cocorobo");
-        if (Object.keys(userInfo).length === 0 && _cookie) {
-            U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
-                if (res.value && res.value[0] && res.value[0][0]) {
-                    US.userInfo = res.value[0][0];
-                    U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + US.userInfo.userid, [], function (res) {
-                        if (res.value && res.value[0] && res.value[0][0]) {
-                            US.userInfo = res.value[0][0]; //记录用户数据
-                            U.MD.O.P.connect(); //登录成功后连接socket服务同步协同编辑
-                            if ($("#U_MD_HomeC_Pop")[0]) {
-                                $("#U_MD_HomeC_Pop")[0].close(); //关闭登陆
-                            }
-                            U.A.Request(US.Config.pbl + "selectUser?userid=" + US.userInfo.userid, [], function (res) {//US.user.userid
-                                if (res.value == null || res.value[0].length == 0) {
-                                    U.MD.D.isLogin();
-                                    U.MD.D.I.openApplication("my")
-                                }
-                                else {
-                                    US.userInfo = res.value[0][0];
-                                    $(".login")[0].style.display = "none";
-                                    $(".register")[0].style.display = "none";
-                                    $(".userName")[0].style.display = "block";
-                                    $(".userName")[0].innerHTML = US.userInfo.username;
-                                    $(".avatar")[0].style.display = "block";
-                                    $(".exit")[0].style.display = "block";
+    setInterval(() => {
+        var userInfo = US.userinfo;
+        if (Object.keys(userInfo).length === 0) {
+            var _cookie = U.UF.Cookie.get("cocorobo");
+            if (Object.keys(userInfo).length === 0 && _cookie) {
+                U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
+                    if (res.value && res.value[0] && res.value[0][0]) {
+                        // US.userInfo = res.value[0][0]; //记录用户数据
+                        US.user = res.value[0][0];
+                        U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + US.user.userid, [], function (res) {
+                            if (res.value && res.value[0] && res.value[0][0]) {
+                                US.userinfo = res.value[0][0]; //记录用户数据
+                                if ($("#U_MD_HomeC_Pop")[0]) {
+                                    $("#U_MD_HomeC_Pop")[0].close(); //关闭登陆
                                 }
-                            }, [], { "type": "GET", "withCredentials": true });
-                        }
-                    }, [], { "type": "GET", "withCredentials": true });
-                }
-            }, [], { "type": "GET", "withCredentials": true });
+
+                                U.A.Request(US.Config.pbl + "selectUser?userid=" + US.user.userid, [], function (res) {//US.user.userid
+                                    if (res.value == null || res.value[0].length == 0) {
+                                        U.MD.D.isLogin();
+                                        U.MD.D.I.openApplication("my")
+                                    } else {
+                                        US.userinfo = res.value[0][0];
+                                        $(".login")[0].style.display = "none";
+                                        $(".register")[0].style.display = "none";
+                                        $(".userName")[0].style.display = "block";
+                                        $(".userName")[0].innerHTML = US.userinfo.username;
+                                        $(".avatar")[0].style.display = "block";
+                                        $(".exit")[0].style.display = "block";
+                                    }
+                                }, [], { "type": "GET", "withCredentials": true });
+                            }
+                        }, [], { "type": "GET", "withCredentials": true });
+                    }
+                }, [], { "type": "GET", "withCredentials": true });
+            }
         }
-    }
-}
+    }, 2000)
 
+    // US.user = {"userid":"a77e9404-efec-11e9-96f9-028edca3b798","identity":2};
+    // US.userinfo = {"userid":"a77e9404-efec-11e9-96f9-028edca3b798","username":"xjw","userpassword":"123456","sessionid":"","type":1,"organizeid":"45facc0a-1211-11ec-80ad-005056b86db5","state":1,"create_at":"2022-04-26T08:26:09.000Z"};
+    // $(".userName")[0].innerHTML = US.userinfo.username;
+}
 
-/**
- * 弹出登录判断
- */
 U.MD.D.isLogin = function () {
-    var userInfo = US.userInfo;
+    var userInfo = US.userinfo;
     if (!userInfo || Object.keys(userInfo).length === 0) {
         $(".userName")[0].style.display = "none";
         setTimeout(() => {