浏览代码

调整集成登录跳转逻辑

natasha 8 月之前
父节点
当前提交
843d8153b9
共有 3 个文件被更改,包括 67 次插入31 次删除
  1. 1 0
      src/components/login/LoginNav.vue
  2. 1 1
      src/utils/request.js
  3. 65 30
      src/views/login/index.vue

+ 1 - 0
src/components/login/LoginNav.vue

@@ -232,6 +232,7 @@ export default {
       Cookies.remove("session_id");
       Cookies.remove("session_id");
       Cookies.remove("user_code");
       Cookies.remove("user_code");
       Cookies.remove("user_type");
       Cookies.remove("user_type");
+      Cookies.remove("GCLSCode");
       sessionStorage.removeItem("useragent_root_close");
       sessionStorage.removeItem("useragent_root_close");
       removeToken();
       removeToken();
       this.userShow = false;
       this.userShow = false;

+ 1 - 1
src/utils/request.js

@@ -47,7 +47,7 @@ service.interceptors.response.use(
    */
    */
   response => {
   response => {
     const res = response.data
     const res = response.data
-    console.log(res)
+    // console.log(res)
     let msg = null
     let msg = null
     // if the custom code is not 20000, it is judged as an error.
     // if the custom code is not 20000, it is judged as an error.
     if (res.status == 0 || res.status == -2) {
     if (res.status == 0 || res.status == -2) {

+ 65 - 30
src/views/login/index.vue

@@ -139,6 +139,7 @@
 <script>
 <script>
 //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
 //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
 //例如:import 《组件名称》from ‘《组件路径》';
 //例如:import 《组件名称》from ‘《组件路径》';
+import Cookies from "js-cookie";
 import Login from "@/components/login/login";
 import Login from "@/components/login/login";
 import Registration from "@/components/login/registration";
 import Registration from "@/components/login/registration";
 import LoginNav2 from "@/components/login/LoginNav2";
 import LoginNav2 from "@/components/login/LoginNav2";
@@ -394,18 +395,25 @@ export default {
             removeToken();
             removeToken();
           } else {
           } else {
             this.userMessage = userInfor;
             this.userMessage = userInfor;
-            if (
-              userInfor.popedom_code_list.indexOf(2000001) > -1 ||
-              userInfor.user_type == "STUDENT"
-            ) {
-              this.isPc = false;
+            console.log(Cookies.get("GCLSCode"));
+            if (Cookies.get("GCLSCode")) {
               this.$message.warning(this.$t("Key247") + "....");
               this.$message.warning(this.$t("Key247") + "....");
-              location.href = `/GCLS-Learn/#/EnterSys`;
+              location.href = `/GCLS-LC/#/EnterSys`;
             } else {
             } else {
-              this.isPc = true;
-              this.LoginOrRegistration = "";
-              this.getChildSysList();
+              if (
+                userInfor.popedom_code_list.indexOf(2000001) > -1 ||
+                userInfor.user_type == "STUDENT"
+              ) {
+                this.isPc = false;
+                this.$message.warning(this.$t("Key247") + "....");
+                location.href = `/GCLS-Learn/#/EnterSys`;
+              } else {
+                this.isPc = true;
+                this.LoginOrRegistration = "";
+                this.getChildSysList();
+              }
             }
             }
+
             this.getLangList();
             this.getLangList();
           }
           }
         });
         });
@@ -434,14 +442,15 @@ export default {
       var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
       var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
 
 
       if (
       if (
-        bIsIpad ||
-        bIsIphoneOs ||
-        bIsMidp ||
-        bIsUc7 ||
-        bIsUc ||
-        bIsAndroid ||
-        bIsCE ||
-        bIsWM
+        (bIsIpad ||
+          bIsIphoneOs ||
+          bIsMidp ||
+          bIsUc7 ||
+          bIsUc ||
+          bIsAndroid ||
+          bIsCE ||
+          bIsWM) &&
+        !Cookies.get("GCLSCode")
       ) {
       ) {
         location.href = "/GCLS-Mobile/#/";
         location.href = "/GCLS-Mobile/#/";
       } else {
       } else {
@@ -463,7 +472,17 @@ export default {
         getContent(MethodName, user_code, user_type, session_id, {})
         getContent(MethodName, user_code, user_type, session_id, {})
           .then((res) => {
           .then((res) => {
             if (res.child_sys_list && res.child_sys_list.length > 0) {
             if (res.child_sys_list && res.child_sys_list.length > 0) {
-              this.projectList = res.child_sys_list;
+              // this.projectList = res.child_sys_list;
+              if (Cookies.get("GCLSCode")) {
+                _this.projectList = [];
+                res.child_sys_list.forEach((item) => {
+                  if (item.key === "GCLS-LC" || item.key === "GCLS-Personal") {
+                    _this.projectList.push(item);
+                  }
+                });
+              } else {
+                _this.projectList = res.child_sys_list;
+              }
             } else {
             } else {
               // this.$message.warning("您没有任何权限,请联系您所在机构的管理员");
               // this.$message.warning("您没有任何权限,请联系您所在机构的管理员");
               this.$message.warning(this.$t("Key652"));
               this.$message.warning(this.$t("Key652"));
@@ -529,20 +548,26 @@ export default {
             : "";
             : "";
           this.$message.success(this.$t("Key442"));
           this.$message.success(this.$t("Key442"));
           setI18nLang(this.language_type).then(() => {
           setI18nLang(this.language_type).then(() => {
-            if (isShare) {
-              location.href = isShare;
-            } else if (localStorage.getItem("testLink")) {
-              location.href = localStorage.getItem("testLink");
-              localStorage.removeItem("testLink");
-            } else if (
-              res.popedom_code_list.indexOf(2000001) > -1 ||
-              res.user_type == "STUDENT"
-            ) {
+            console.log(Cookies.get("GCLSCode"));
+            if (Cookies.get("GCLSCode")) {
               this.$message.warning(this.$t("Key247") + "....");
               this.$message.warning(this.$t("Key247") + "....");
-              location.href = `/GCLS-Learn/#/EnterSys`;
+              location.href = `/GCLS-LC/#/EnterSys`;
             } else {
             } else {
-              this.LoginOrRegistration = "";
-              this.getChildSysList();
+              if (isShare) {
+                location.href = isShare;
+              } else if (localStorage.getItem("testLink")) {
+                location.href = localStorage.getItem("testLink");
+                localStorage.removeItem("testLink");
+              } else if (
+                res.popedom_code_list.indexOf(2000001) > -1 ||
+                res.user_type == "STUDENT"
+              ) {
+                this.$message.warning(this.$t("Key247") + "....");
+                location.href = `/GCLS-Learn/#/EnterSys`;
+              } else {
+                this.LoginOrRegistration = "";
+                this.getChildSysList();
+              }
             }
             }
           });
           });
         })
         })
@@ -642,11 +667,21 @@ export default {
     // this.code = this.$route.query.code;
     // this.code = this.$route.query.code;
     if (this.code) {
     if (this.code) {
       this.getLoginClever(this.code);
       this.getLoginClever(this.code);
+      Cookies.set("GCLSCode", this.code);
+    } else {
+      Cookies.remove("GCLSCode");
     }
     }
     this.getinstitutionList();
     this.getinstitutionList();
   },
   },
   //生命周期 - 挂载完成(可以访问DOM元素)
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {
   mounted() {
+    this.code = window.location.search.split("?")[1]?.split("=")[1]; // 获取识别码
+    // this.code = this.$route.query.code;
+    if (this.code) {
+      Cookies.set("GCLSCode", this.code);
+    } else {
+      Cookies.remove("GCLSCode");
+    }
     this.browserRedirect();
     this.browserRedirect();
   },
   },
   //生命周期-创建之前
   //生命周期-创建之前