瀏覽代碼

登录页面根据后台配置展示

Michael Wang 5 年之前
父節點
當前提交
424e080fbd
共有 1 個文件被更改,包括 47 次插入22 次删除
  1. 47 22
      src/features/Login/Login.vue

+ 47 - 22
src/features/Login/Login.vue

@@ -17,7 +17,7 @@
       <div class="content">
         <div style="display:flex;">
           <a
-            v-if="!LOGIN_ID_DOMAINS.includes(domainInUrl)"
+            v-if="allowLoginType.includes('STUDENT_CODE')"
             :class="[
               'qm-big-text',
               'login-type',
@@ -29,6 +29,7 @@
             学号登录
           </a>
           <a
+            v-if="allowLoginType.includes('IDENTITY_NUMBER')"
             :class="[
               'qm-big-text',
               'login-type',
@@ -117,9 +118,9 @@ export default {
   name: "Login",
   data() {
     return {
-      LOGIN_ID_DOMAINS: ["cugr.ecs.qmth.com.cn", "cugbr.ecs.qmth.com.cn"],
+      // LOGIN_ID_DOMAINS: ["cugr.ecs.qmth.com.cn", "cugbr.ecs.qmth.com.cn"],
       domainInUrl: this.$route.params.domain,
-      productName: "",
+      QECSConfig: {},
       loginType: "STUDENT_CODE",
       errorInfo: "",
       loginForm: {
@@ -187,29 +188,12 @@ export default {
       window._hmt.push(["_trackEvent", "登录页面", "非64Bit OS"]);
     }
 
-    if (this.LOGIN_ID_DOMAINS.includes(this.schoolDomain)) {
-      this.loginType = "STUDENT_IDENTITY_NUMBER";
-    }
     this.$Message.config({
       duration: 15,
       size: "large",
       closable: true, // 没有影响到所有的组件。。。  https://github.com/iview/iview/issues/2962
     });
 
-    try {
-      const res = await fetch(
-        "/api/ecs_core/org/propertyNoSession/OE_STUDENT_SYS_NAME?domainName=" +
-          this.schoolDomain
-      );
-      if (res.ok) {
-        const productName = await res.text();
-        this.productName = productName || "远程教育网络考试";
-      } else {
-        this.productName = "远程教育网络考试";
-      }
-    } catch (e) {
-      this.productName = "远程教育网络考试";
-    }
     window.sessionStorage.removeItem("token");
     window.sessionStorage.clear();
     window.localStorage.removeItem("key");
@@ -444,7 +428,7 @@ export default {
         location.reload(true);
       }
     },
-    checkElectronConfig() {
+    async checkElectronConfig() {
       if (typeof nodeRequire != "undefined") {
         this.checkQECSConfigTimes = this.checkQECSConfigTimes || 1;
         if (this.checkQECSConfigTimes >= 10) {
@@ -462,6 +446,8 @@ export default {
           }, 1000);
           return;
         }
+        this.QECSConfig = window.QECSConfig;
+
         var that = this;
         var fs = window.nodeRequire("fs");
 
@@ -503,6 +489,39 @@ export default {
         }
       } else {
         this.disableLoginBtn = false;
+        try {
+          const fileSever =
+            location.hostname === "ecs.qmth.com.cn"
+              ? "https://ecs-static.qmth.com.cn"
+              : "https://ecs-test-static.qmth.com.cn";
+
+          const res = await fetch(
+            fileSever +
+              "/org_properties/byOrgDomain/" +
+              this.domainInUrl +
+              "/studentClientConfig.json"
+          );
+          if (res.ok) {
+            const json = await res.json();
+            this.QECSConfig = json;
+          } else {
+            this.$Message.error({
+              content: "获取远程配置文件出错,请重新刷新网页!",
+              duration: 15,
+              closable: true,
+            });
+          }
+        } catch (e) {
+          this.$Message.error({
+            content: "获取远程配置文件出错,请重新刷新网页!",
+            duration: 15,
+            closable: true,
+          });
+        }
+      }
+
+      if (this.allowLoginType === "IDENTITY_NUMBER") {
+        this.loginType = "STUDENT_IDENTITY_NUMBER";
       }
     },
     closeApp() {
@@ -511,7 +530,13 @@ export default {
   },
   computed: {
     logoPath() {
-      return "/api/ecs_core/org/logo?domain=" + this.domainInUrl;
+      return this.QECSConfig.LOGO_FILE_URL;
+    },
+    productName() {
+      return this.QECSConfig.OE_STUDENT_SYS_NAME || "远程教育网络考试";
+    },
+    allowLoginType() {
+      return this.QECSConfig.LOGIN_TYPE || [];
     },
     schoolDomain() {
       const domain = this.domainInUrl;