Browse Source

fix domain取不到的提示

Michael Wang 6 năm trước cách đây
mục cha
commit
342184d78b
1 tập tin đã thay đổi với 15 bổ sung6 xóa
  1. 15 6
      src/features/Login/Login.vue

+ 15 - 6
src/features/Login/Login.vue

@@ -20,7 +20,7 @@
       <div class="content">
         <div style="display:flex;">
           <a
-            v-if="this.$route.params.domain !== 'cugr.ecs.qmth.com.cn'"
+            v-if="schoolDomain !== 'cugr.ecs.qmth.com.cn'"
             :class="['qm-big-text', 'login-type', loginType === 'STUDENT_CODE' && 'active-type']"
             @click="loginType='STUDENT_CODE'"
             style="border-top-left-radius: 6px"
@@ -119,7 +119,6 @@ export default {
   name: "Login",
   data() {
     return {
-      logoPath: "/api/ecs_core/org/logo?domain=" + this.$route.params.domain,
       productName: "",
       loginType: "STUDENT_CODE",
       errorInfo: "",
@@ -147,7 +146,7 @@ export default {
     };
   },
   async created() {
-    if (this.$route.params.domain === "cugr.ecs.qmth.com.cn") {
+    if (this.schoolDomain === "cugr.ecs.qmth.com.cn") {
       this.loginType = "STUDENT_IDENTITY_NUMBER";
     }
     this.$Message.config({
@@ -159,7 +158,7 @@ export default {
     try {
       const res = await this.$http.get(
         "/api/ecs_core/org/propertyNoSession/OE_STUDENT_SYS_NAME?domainName=" +
-          this.$route.params.domain
+          this.schoolDomain
       );
       const productName = res.data;
       this.productName = productName || "远程教育网络考试";
@@ -248,7 +247,7 @@ export default {
       const response = await this.$http.post("/api/ecs_core/auth/login", {
         ...repPara,
         accountType: this.loginType,
-        domain: this.$route.params.domain
+        domain: this.schoolDomain
       });
       let data = response.data;
       if (
@@ -266,7 +265,7 @@ export default {
         //缓存用户信息
         window.sessionStorage.setItem("token", data.token);
         window.localStorage.setItem("key", data.key);
-        window.localStorage.setItem("domain", this.$route.params.domain);
+        window.localStorage.setItem("domain", this.schoolDomain);
 
         try {
           const student = (await this.$http.get(
@@ -321,6 +320,16 @@ export default {
     }
   },
   computed: {
+    logoPath() {
+      return "/api/ecs_core/org/logo?domain=" + this.schoolDomain;
+    },
+    schoolDomain() {
+      const domain = this.$route.params.domain;
+      if (!domain || !domain.includes("qmth.com.cn")) {
+        this.$Message.error("机构地址出错,请关闭程序后再登录。");
+      }
+      return domain;
+    },
     usernameInputPlaceholder() {
       if (this.loginType === "STUDENT_CODE") {
         return "请输入学号";