chao 8 bulan lalu
induk
melakukan
03604a544f
1 mengubah file dengan 54 tambahan dan 0 penghapusan
  1. 54 0
      js/Desktop/Onload.js

+ 54 - 0
js/Desktop/Onload.js

@@ -482,6 +482,60 @@ U.MD.D.getuser = function () {
                 }
             }, [], { "type": "GET", "withCredentials": true });
         }
+    }else if(Object.keys(userInfo).length === 0 && U.UF.C.queryString('code').length === 32){
+        $("#U_MD_HomeC_Pop")[0].close()
+        console.log('新华跳转',U.UF.C.queryString('code'))
+        let url = "https://cloud.cocorobo.cn/api/getTeacherInfoByCode"
+        var myHeaders = new Headers();
+        // myHeaders.append("User-Agent", "Apifox/1.0.0 (https://apifox.com)");
+        myHeaders.append("Content-Type", "application/json");
+        myHeaders.append("Access-Control-Allow-Origin","*")
+
+        var raw = JSON.stringify({
+        "code": U.UF.C.queryString('code')
+        });
+
+        var requestOptions = {
+            method: 'POST',
+            headers: myHeaders,
+            body: raw,
+            redirect: 'follow'
+        };
+
+        fetch(url, requestOptions)
+        .then(response => response.text())
+        .then(result => {
+            console.log(result)
+            if(result.code == 200){
+                US.userInfo = {
+                    username:result.data.realName,
+                    userid:result.data.userUniqueId,
+                    type:1,
+                    userpassword:"",
+                    cclassid:"",
+                    create_at:""
+                }
+                U.A.Request(US.Config.pbl + "batchRegistrationSzdjg3", [data.realName, "", '16ace517-b5c7-4168-a9bb-a9e0035df840', data.schoolName || "", "", "", 1, data.userUniqueId,diqu,diquId], function (res) {
+                    console.log(res);
+                    let loginData = {
+                        method: 'POST',
+                        headers: myHeaders,
+                        body: JSON.stringify({
+                            openid: data.userId,
+                            edu: true
+                        }),
+                        redirect: 'follow'
+                    }
+                    fetch("https://beta.api.cocorobo.cn/api/user",loginData).then(loginRes=>loginRes.text())
+                    .then(loginR=>{
+                        // US.userInfo = loginR.value[0][0]; //记录用户数据
+                        console.log("login",loginR,US.userInfo)
+                    })
+                    
+                }, [], { "type": "POST", "withCredentials": true })
+            }
+        })
+        .catch(error => console.log('error', error));
     } else if(Object.keys(userInfo).length !== 0){
         if(US.Config.type == '2'){
             $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/easyBg.png")'