lsc 6 months ago
parent
commit
808495fb7f
1 changed files with 61 additions and 35 deletions
  1. 61 35
      js/Desktop/Onload.js

+ 61 - 35
js/Desktop/Onload.js

@@ -652,42 +652,68 @@ U.MD.D.addLoginTime = function(){
 }
 
 U.MD.D.getuser2 = function (userid, cid) {
-    U.A.Request(US.Config.pbl + "selectUser?userid=" + userid, [], function (res) { //US.userInfo.userid
-        if ($("#U_MD_HomeC_Pop")[0]) {
-            $("#U_MD_HomeC_Pop")[0].close(); //关闭登陆
-        }
-        loginPan(res.value[0][0], userid)
+    let loginData = JSON.stringify({
+        openid: userid,
+        edu: true
+    })
+    var requestOptionsLogin = {
+        method: 'POST',
+        headers: myHeaders,
+        body: loginData,
+        redirect: 'follow'
+     };
+     
+     fetch("https://beta.api.cocorobo.cn/api/user", requestOptionsLogin)
+        .then(response => response.text())
+        .then(result => {
+            let a = JSON.parse(result)
+            if(a.length>0){
+                let userId = a[0][0].userid
+                US.userInfo.userid = userId
+                U.A.Request(US.Config.pbl + "selectUser?userid=" + userid, [], function (res) { //US.userInfo.userid
+                    if ($("#U_MD_HomeC_Pop")[0]) {
+                        $("#U_MD_HomeC_Pop")[0].close(); //关闭登陆
+                    }
+                    loginPan(res.value[0][0], userid)
+            
+                    US.userInfo = res.value[0][0];
+                    $(".avatar")[0].style.display = "block";
+                    if (res.value[0][0].type === 1 && $(".U_PBL_Check")[0] && res.value[0][0].org != '150e3120-9195-11ed-b13d-005056b86db5') {
+                        $(".U_PBL_Check")[0].style.display = "block";
+                    }
+                    $(".login")[0].style.display = "none";
+                    $(".register")[0].style.display = "none";
+                    $(".userName")[0].style.display = "block";
+                    $(".userName")[0].innerHTML = US.userInfo.username || US.userInfo.alias;
+                    $(".exit")[0].style.display = "block";
+                    let _vipbox = $('.U_MD_D_BD_vip_box')[0]
+                    _vipbox && (_vipbox.style.right = $(".U_MD_D_BD")[0].offsetWidth + 20 + 'px')
+                    if(res.value[0][0].type === 1 && res.value[0][0].org == 'c95e0a56-c205-11ed-8d51-005056b86db5'){
+                        U.MD.D.I.ModeCheck(2)
+                    }else{
+                        U.MD.D.I.initDesktopIcons($("#U_MD_D_K")[0], 1);
+                    }
+                    if(res.value[0][0].type === 1 && window.location.hash.indexOf('project') != -1){
+                        U.MD.D.I.openApplication("project")
+                    }
+                    if(res.value[0][0].type === 1 && window.location.hash.indexOf('study') != -1){
+                        U.MD.D.I.openApplication("study")
+                    }
+                    if(res.value[0][0].type === 2 && window.location.hash.indexOf('study') != -1){
+                        U.MD.D.I.openApplication("studentStudy")
+                    }
+                    U.MD.O.P.connect(); //登录成功后连接socket服务同步协同编辑
+                    U.MD.D.I.openInApplication("studyDetail", cid, 2, 2)
+                    U.MD.D.I.openInApplication("studyDetail", cid, 2, 2)
+                }, [], { "type": "GET", "withCredentials": true });
+            }
+            
+        })
+        .catch(error => {
+            LoginState = false
+            console.log('error', error)
+        });
 
-        US.userInfo = res.value[0][0];
-        $(".avatar")[0].style.display = "block";
-        if (res.value[0][0].type === 1 && $(".U_PBL_Check")[0] && res.value[0][0].org != '150e3120-9195-11ed-b13d-005056b86db5') {
-            $(".U_PBL_Check")[0].style.display = "block";
-        }
-        $(".login")[0].style.display = "none";
-        $(".register")[0].style.display = "none";
-        $(".userName")[0].style.display = "block";
-        $(".userName")[0].innerHTML = US.userInfo.username || US.userInfo.alias;
-        $(".exit")[0].style.display = "block";
-        let _vipbox = $('.U_MD_D_BD_vip_box')[0]
-        _vipbox && (_vipbox.style.right = $(".U_MD_D_BD")[0].offsetWidth + 20 + 'px')
-        if(res.value[0][0].type === 1 && res.value[0][0].org == 'c95e0a56-c205-11ed-8d51-005056b86db5'){
-            U.MD.D.I.ModeCheck(2)
-        }else{
-            U.MD.D.I.initDesktopIcons($("#U_MD_D_K")[0], 1);
-        }
-        if(res.value[0][0].type === 1 && window.location.hash.indexOf('project') != -1){
-            U.MD.D.I.openApplication("project")
-        }
-        if(res.value[0][0].type === 1 && window.location.hash.indexOf('study') != -1){
-            U.MD.D.I.openApplication("study")
-        }
-        if(res.value[0][0].type === 2 && window.location.hash.indexOf('study') != -1){
-            U.MD.D.I.openApplication("studentStudy")
-        }
-        U.MD.O.P.connect(); //登录成功后连接socket服务同步协同编辑
-        U.MD.D.I.openInApplication("studyDetail", cid, 2, 2)
-        U.MD.D.I.openInApplication("studyDetail", cid, 2, 2)
-    }, [], { "type": "GET", "withCredentials": true });
 }