zhangjie 3 ani în urmă
părinte
comite
82719c2d6b

+ 47 - 0
src/modules/login-new/api.js

@@ -0,0 +1,47 @@
+import { $post, $postParam } from "@/plugins/axios";
+
+export const login = datas => {
+  return $post("/api/admin/common/login", datas);
+};
+export const getSmsCode = datas => {
+  return $post("/api/admin/common/get_verify_code", datas);
+};
+export const getSmsCodeForBind = datas => {
+  return $post("/api/admin/common/get_verify_code_for_bind", datas);
+};
+export const logout = () => {
+  return $post("/api/admin/common/logout", {});
+};
+export const sysMenu = () => {
+  return $postParam("/api/admin/common/get_menu", {});
+};
+export const attachmentPreview = id => {
+  return $postParam("/api/admin/common/file/preview", { id });
+};
+export const attachmentDetail = id => {
+  return $postParam("/api/admin/common/file/get_one", { id });
+};
+export const attachmentDownload = ({ id, type }) => {
+  return $postParam("/api/admin/common/file/download", { id, type });
+};
+export const getEnums = type => {
+  return $postParam("/api/admin/common/get_enums", { type });
+};
+export const schoolList = () => {
+  return $postParam("/api/admin/common/school/list", {});
+};
+export const getSchoolInfo = code => {
+  return $postParam("/api/admin/common/school/query_by_school_code", { code });
+};
+export const getSysConfig = key => {
+  return $postParam("/api/admin/common/sys_config/get_one", { key });
+};
+export const getSysTime = () => {
+  return $postParam("/api/admin/common/get_system_time", {});
+};
+export const loginAuthen = datas => {
+  return $postParam("/api/report/wuda/open/user/authentication/login", datas);
+};
+export const logoutAuthen = datas => {
+  return $get("/api/report/wuda/open/user/authentication/logout", datas);
+};

+ 85 - 0
src/modules/login-new/fetchSmsMixins.js

@@ -0,0 +1,85 @@
+import { getSmsCode } from "./api";
+
+const wstorage = {
+  set(key, value, expire = null) {
+    window.localStorage.setItem(key, JSON.stringify({ value, expire }));
+  },
+  get(key, defaultVal = null) {
+    const lsvalue = JSON.parse(window.localStorage.getItem(key));
+    return lsvalue && (!lsvalue.expire || lsvalue.expire > new Date().getTime())
+      ? lsvalue.value
+      : defaultVal;
+  },
+  remove(key) {
+    window.localStorage.removeItem(key);
+  }
+};
+
+const codeWaitingTime = 60;
+
+export default {
+  data() {
+    return {
+      isFetchingCode: false,
+      codeContent: "获取验证码",
+      codeWaitingTime,
+      time: codeWaitingTime,
+      setT: null
+    };
+  },
+  methods: {
+    setWaitingTime() {
+      let codetime = wstorage.get(this.nameWaitTime);
+      if (codetime) {
+        let num = Math.floor((codetime.expire - new Date().getTime()) / 1000);
+        if (num > 0) {
+          this.time = num;
+          this.isFetchingCode = true;
+          this.changeContent();
+        }
+      }
+    },
+    fetchSmsCode() {
+      this.$refs.modalFormComp.validateField("phone", async valid => {
+        if (valid) return;
+        this.isFetchingCode = true;
+        const data = await getSmsCode(this.modalForm.phone).catch(() => {
+          this.isFetchingCode = false;
+        });
+        if (!data) return;
+        this.changeContent();
+      });
+    },
+    changeContent() {
+      if (!this.isFetchingCode) return;
+      this.codeContent = "倒计时" + this.time + "s";
+      const circleTime = time => {
+        this.setT = setInterval(() => {
+          if (time > 1) {
+            time--;
+            let expire = new Date().getTime() + time * 1000;
+            wstorage.set(
+              this.nameWaitTime,
+              {
+                time,
+                expire
+              },
+              expire
+            );
+            this.codeContent = "倒计时" + time + "s";
+          } else {
+            this.clearSetContent();
+          }
+        }, 1e3);
+      };
+      circleTime(this.time);
+    },
+    clearSetContent() {
+      this.time = this.codeWaitingTime;
+      wstorage.remove(this.nameWaitTime);
+      this.codeContent = "获取验证码";
+      this.isFetchingCode = false;
+      clearInterval(this.setT);
+    }
+  }
+};

+ 48 - 0
src/modules/login-new/router.js

@@ -0,0 +1,48 @@
+import LoginHome from "./views/LoginHome";
+import Login from "./views/Login";
+import SelectSchool from "./views/SelectSchool";
+import LoginAuthen from "./views/LoginAuthen";
+import LogoutAuthen from "./views/LogoutAuthen";
+
+export default {
+  path: "/login-home",
+  component: LoginHome,
+  children: [
+    {
+      path: "/login",
+      name: "Login",
+      component: Login,
+      meta: {
+        title: "登录",
+        noRequire: true
+      }
+    },
+    {
+      path: "/select-school",
+      name: "SelectSchool",
+      component: SelectSchool,
+      meta: {
+        title: "选择学校",
+        noRequire: true
+      }
+    },
+    {
+      path: "/login-authen/:code",
+      name: "LoginAuthen",
+      component: LoginAuthen,
+      meta: {
+        title: "第三方登录",
+        noRequire: true
+      }
+    },
+    {
+      path: "/logout-authen",
+      name: "LogoutAuthen",
+      component: LogoutAuthen,
+      meta: {
+        title: "第三方退出",
+        noRequire: true
+      }
+    }
+  ]
+};

+ 320 - 0
src/modules/login-new/views/Login.vue

@@ -0,0 +1,320 @@
+<template>
+  <div class="login login-box">
+    <div class="login-theme"><h2>知学知考-教研分析</h2></div>
+    <div class="login-body" @keyup.enter="submit('loginForm')">
+      <div class="login-title">
+        <img v-if="schoolLogo" :src="schoolLogo" alt="学校logo" />
+        <h1 v-else>知学知考-教研分析</h1>
+      </div>
+      <div class="login-form">
+        <el-form
+          v-if="IS_USERNAME_TYPE"
+          ref="loginForm"
+          :model="loginModel"
+          :rules="loginRules"
+        >
+          <el-form-item prop="loginName">
+            <el-input
+              v-model.trim="loginModel.loginName"
+              placeholder="请输入账号"
+              name="username"
+              clearable
+            >
+              <i class="icon icon-phone" slot="prefix"></i>
+            </el-input>
+          </el-form-item>
+          <el-form-item prop="password">
+            <el-input
+              type="password"
+              v-model.trim="loginModel.password"
+              placeholder="请输入密码"
+              clearable
+            >
+              <i class="icon icon-password" slot="prefix"></i>
+            </el-input>
+          </el-form-item>
+          <el-form-item prop="schoolCode"></el-form-item>
+          <el-form-item>
+            <el-button
+              class="login-submit-btn"
+              size="large"
+              type="info"
+              :disabled="isSubmit"
+              round
+              @click="submit('loginForm')"
+              >登录</el-button
+            >
+          </el-form-item>
+        </el-form>
+        <el-form v-else ref="loginForm" :model="loginModel" :rules="loginRules">
+          <el-form-item prop="mobileNumber">
+            <el-input
+              v-model.trim="loginModel.mobileNumber"
+              placeholder="请输入手机号"
+              name="mobileNumber"
+              clearable
+            >
+              <i class="icon icon-phone" slot="prefix"></i>
+            </el-input>
+          </el-form-item>
+          <el-form-item prop="code">
+            <div class="vlcode">
+              <div class="vlcode-right">
+                <el-button
+                  style="width:100%;"
+                  type="text"
+                  @click="fetchSmsCode"
+                  :disabled="isFetchingCode"
+                  >+{{ codeContent }}</el-button
+                >
+              </div>
+              <div class="vlcode-left">
+                <el-input
+                  v-model.trim="loginModel.code"
+                  placeholder="请输入手机验证码"
+                  name="code"
+                  clearable
+                >
+                  <i class="icon icon-checkcode" slot="prefix"></i>
+                </el-input>
+              </div>
+            </div>
+          </el-form-item>
+          <el-form-item prop="schoolCode"></el-form-item>
+          <el-form-item>
+            <el-button
+              class="login-submit-btn"
+              size="large"
+              type="info"
+              :disabled="isSubmit"
+              round
+              @click="submit('loginForm')"
+              >登录</el-button
+            >
+          </el-form-item>
+        </el-form>
+      </div>
+      <div class="login-action box-justify">
+        <div></div>
+        <el-button type="text" @click="switchLoginType">
+          <i>{{ switchBtnName }}</i>
+          <i class="el-icon-arrow-right"></i>
+        </el-button>
+      </div>
+    </div>
+
+    <!-- 修改密码 -->
+    <reset-pwd
+      :user-info="userInfo"
+      ref="ResetPwd"
+      @modified="resetPwdSuccess"
+    ></reset-pwd>
+  </div>
+</template>
+
+<script>
+import { password, phone, smscode } from "@/plugins/formRules";
+import { login, getSmsCode, getSchoolInfo } from "../api";
+import { Base64 } from "@/plugins/crypto";
+import ResetPwd from "@/modules/base/components/ResetPwd";
+import { ORG_CODE } from "@/constants/app";
+import fetchSmsMixins from "../fetchSmsMixins";
+
+export default {
+  name: "login",
+  components: { ResetPwd },
+  mixins: [fetchSmsMixins],
+  data() {
+    return {
+      nameWaitTime: "login",
+      smsCodeRequired: false,
+      loginModel: {
+        schoolCode: ORG_CODE,
+        loginName: "",
+        password: "",
+        code: "",
+        mobileNumber: ""
+      },
+      loginRules: {
+        code: smscode,
+        password,
+        loginName: [
+          {
+            required: true,
+            message: "请输入用户名",
+            trigger: "change"
+          }
+        ],
+        schoolCode: [
+          {
+            required: true,
+            message: "学校编码缺失",
+            trigger: "change"
+          }
+        ],
+        mobileNumber: phone
+      },
+      userInfo: {},
+      roles: [],
+      isSubmit: false,
+      schoolLogo: "",
+      loginType: "ACCOUNT"
+    };
+  },
+  mounted() {
+    this.$ls.clear();
+    this.setWaitingTime();
+    this.getSchool();
+  },
+  computed: {
+    IS_USERNAME_TYPE() {
+      return this.loginType === "ACCOUNT";
+    },
+    switchBtnName() {
+      return this.loginType === "ACCOUNT" ? "短信登录" : "账号登录";
+    }
+  },
+  methods: {
+    async getSchool() {
+      const data = await getSchoolInfo(ORG_CODE);
+      this.$ls.set("schoolLogo", data.logo);
+      this.$ls.set("schoolName", data.name);
+      this.schoolLogo = data.logo;
+    },
+    switchLoginType() {
+      this.loginType = this.loginType === "ACCOUNT" ? "PHONE" : "ACCOUNT";
+    },
+    async submit(name) {
+      const valid = await this.$refs[name].validate().catch(() => {});
+      if (!valid) return;
+
+      if (this.isSubmit) return;
+      this.isSubmit = true;
+      let datas = {
+        schoolCode: this.loginModel.schoolCode,
+        type: this.loginType
+      };
+      if (this.IS_USERNAME_TYPE) {
+        datas = {
+          ...datas,
+          loginName: this.loginModel.loginName,
+          password: Base64(this.loginModel.password)
+        };
+      } else {
+        datas = {
+          ...datas,
+          code: this.loginModel.code,
+          mobileNumber: this.loginModel.mobileNumber
+        };
+      }
+      const data = await login(datas).catch(() => {});
+      this.isSubmit = false;
+      if (!data) return;
+
+      if (data.orgInfo)
+        this.$ls.set("orgId", data.orgInfo.id, this.GLOBAL.authTimeout);
+      if (data.schoolInfo)
+        this.$ls.set("schoolId", data.schoolInfo.id, this.GLOBAL.authTimeout);
+      this.$ls.set("user", data, this.GLOBAL.authTimeout);
+
+      this.$ls.set("token", data.accessToken, this.GLOBAL.authTimeout);
+
+      // 强制修改密码和绑定手机号
+      if (
+        data.userLoginCheckResult &&
+        (!data.userLoginCheckResult.pwdCount ||
+          !data.userLoginCheckResult.mobileNumber)
+      ) {
+        this.userInfo = {
+          ...this.loginModel,
+          ...data.userLoginCheckResult
+        };
+        this.$refs.ResetPwd.open();
+        return;
+      }
+
+      if (data.roleList && data.roleList.includes("ADMIN")) {
+        this.$router.push({
+          name: "SelectSchool"
+        });
+      } else {
+        this.$router.push({
+          name: "Home"
+        });
+      }
+    },
+    resetPwdSuccess(data) {
+      if (data.orgInfo)
+        this.$ls.set("orgId", data.orgInfo.id, this.GLOBAL.authTimeout);
+      if (data.schoolInfo)
+        this.$ls.set("schoolId", data.schoolInfo.id, this.GLOBAL.authTimeout);
+      this.$ls.set("user", data, this.GLOBAL.authTimeout);
+
+      this.$ls.set("token", data.accessToken, this.GLOBAL.authTimeout);
+
+      if (data.roleList && data.roleList.includes("ADMIN")) {
+        this.$router.push({
+          name: "SelectSchool"
+        });
+      } else {
+        this.$router.push({
+          name: "Home"
+        });
+      }
+    },
+    // code valid
+    checkField(field) {
+      return new Promise((resolve, reject) => {
+        this.$refs.loginForm.validateField(field, unvalid => {
+          if (unvalid) {
+            reject();
+          } else {
+            resolve();
+          }
+        });
+      });
+    },
+    async fetchSmsCode() {
+      const validAll = [
+        this.checkField("mobileNumber"),
+        this.checkField("schoolCode")
+      ];
+
+      let result = true;
+      await Promise.all(validAll).catch(() => {
+        result = false;
+      });
+
+      if (!result) return;
+
+      this.isFetchingCode = true;
+      const data = await getSmsCode({
+        schoolCode: this.loginModel.schoolCode,
+        mobileNumber: this.loginModel.mobileNumber
+      }).catch(() => {
+        this.isFetchingCode = false;
+      });
+      if (!data) return;
+
+      if (data.mobileNumber) {
+        this.$message.success(
+          `已向手机尾号【${data.mobileNumber.slice(
+            -4
+          )}】成功发送短信,请在2分钟内进行验证!`
+        );
+        this.changeContent();
+      } else {
+        this.isFetchingCode = false;
+        this.$message.error("未绑定手机号,请先绑定!");
+        // this.userInfo = {
+        //   ...data,
+        //   loginName: this.loginModel.loginName,
+        //   schoolCode: this.loginModel.schoolCode,
+        //   password: this.loginModel.password
+        // };
+        // this.$refs.ResetPwd.open();
+      }
+    }
+  }
+};
+</script>

+ 52 - 0
src/modules/login-new/views/LoginAuthen.vue

@@ -0,0 +1,52 @@
+<template>
+  <div class="login-authen">
+    <h1 class="color-white text-center">
+      <i class="el-icon-loading"></i> 正在登录...
+    </h1>
+  </div>
+</template>
+
+<script>
+import { loginAuthen } from "../api";
+
+export default {
+  name: "login-authen",
+  data() {
+    return {
+      code: this.$route.params.code
+    };
+  },
+  mounted() {
+    this.login();
+  },
+  methods: {
+    async login() {
+      if (!this.code) {
+        this.$notify.error({
+          title: "非法操作",
+          message: "code丢失"
+        });
+        return;
+      }
+      const data = await loginAuthen({ code: this.code });
+      if (!data) return;
+
+      if (data.orgInfo) this.$ls.set("orgId", data.orgInfo.id);
+      if (data.schoolInfo) this.$ls.set("schoolId", data.schoolInfo.id);
+      this.$ls.set("user", data);
+
+      // 强制修改密码
+      // if (!data.user.pwdUpdateTime) {
+      //   this.$refs.ResetPwd.open();
+      //   return;
+      // }
+
+      this.$ls.set("token", data.accessToken);
+
+      this.$router.push({
+        name: "Home"
+      });
+    }
+  }
+};
+</script>

+ 25 - 0
src/modules/login-new/views/LoginHome.vue

@@ -0,0 +1,25 @@
+<template>
+  <div class="login-home">
+    <router-view></router-view>
+    <div class="login-footer">
+      <p>
+        <a href="http://www.qmth.com.cn" target="_blank"
+          >Copyright © 2022 启明泰和</a
+        >
+        <a href="https://beian.miit.gov.cn/" target="_blank"
+          >鄂ICP备12000033号-9</a
+        >
+      </p>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "login-home",
+  data() {
+    return {};
+  },
+  methods: {}
+};
+</script>

+ 19 - 0
src/modules/login-new/views/LogoutAuthen.vue

@@ -0,0 +1,19 @@
+<template>
+  <div class="logout-authen">
+    <h1 class="color-white text-center">
+      <i class="el-icon-loading"></i> 正在退出...
+    </h1>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "logout-authen",
+  data() {
+    return {};
+  },
+  created() {
+    window.location.href = "/api/report/wuda/open/user/authentication/logout";
+  }
+};
+</script>

+ 76 - 0
src/modules/login-new/views/SelectSchool.vue

@@ -0,0 +1,76 @@
+<template>
+  <div class="select-school login login-box">
+    <div class="login-theme"></div>
+    <div class="login-body">
+      <div class="login-title">
+        <h1>选择学校</h1>
+      </div>
+      <div class="school-form">
+        <el-form ref="modalFormComp" :model="modalForm" :rules="rules">
+          <el-form-item prop="schoolId">
+            <school-select
+              v-model="modalForm.schoolId"
+              style="width:100%;"
+              @change="schoolChange"
+            ></school-select>
+          </el-form-item>
+          <el-form-item>
+            <el-button style="width:100%;" type="primary" @click="confirm"
+              >进入学校</el-button
+            >
+          </el-form-item>
+          <el-form-item>
+            <el-button style="width:100%;" type="warning" @click="toAdmin"
+              >进入超管中心<i class="el-icon-arrow-right"></i
+            ></el-button>
+          </el-form-item>
+        </el-form>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "select-school",
+  data() {
+    return {
+      schools: [],
+      modalForm: { schoolId: "" },
+      curSchool: {},
+      rules: {
+        schoolId: [{ required: true, message: "请选择学校", trigger: "change" }]
+      }
+    };
+  },
+  created() {
+    this.$ls.remove("schoolId");
+    this.$ls.remove("schoolName");
+    this.$ls.remove("schoolLogo");
+  },
+  methods: {
+    schoolChange(school) {
+      this.curSchool = school;
+    },
+    toAdmin() {
+      this.$router.push({ name: "Admin" });
+    },
+    async confirm() {
+      const valid = await this.$refs.modalFormComp.validate().catch(() => {});
+      if (!valid) return;
+
+      this.$ls.set(
+        "schoolId",
+        this.modalForm.schoolId,
+        this.GLOBAL.authTimeout
+      );
+      this.$ls.set("schoolName", this.curSchool.name, this.GLOBAL.authTimeout);
+      this.$ls.set("schoolLogo", this.curSchool.logo, this.GLOBAL.authTimeout);
+
+      this.$router.push({
+        name: "Home"
+      });
+    }
+  }
+};
+</script>

+ 44 - 47
src/modules/login/api.js

@@ -1,47 +1,44 @@
-import { $post, $postParam } from "@/plugins/axios";
-
-export const login = datas => {
-  return $post("/api/admin/common/login", datas);
-};
-export const getSmsCode = datas => {
-  return $post("/api/admin/common/get_verify_code", datas);
-};
-export const getSmsCodeForBind = datas => {
-  return $post("/api/admin/common/get_verify_code_for_bind", datas);
-};
-export const logout = () => {
-  return $post("/api/admin/common/logout", {});
-};
-export const sysMenu = () => {
-  return $postParam("/api/admin/common/get_menu", {});
-};
-export const attachmentPreview = id => {
-  return $postParam("/api/admin/common/file/preview", { id });
-};
-export const attachmentDetail = id => {
-  return $postParam("/api/admin/common/file/get_one", { id });
-};
-export const attachmentDownload = ({ id, type }) => {
-  return $postParam("/api/admin/common/file/download", { id, type });
-};
-export const getEnums = type => {
-  return $postParam("/api/admin/common/get_enums", { type });
-};
-export const schoolList = () => {
-  return $postParam("/api/admin/common/school/list", {});
-};
-export const getSchoolInfo = code => {
-  return $postParam("/api/admin/common/school/query_by_school_code", { code });
-};
-export const getSysConfig = key => {
-  return $postParam("/api/admin/common/sys_config/get_one", { key });
-};
-export const getSysTime = () => {
-  return $postParam("/api/admin/common/get_system_time", {});
-};
-export const loginAuthen = datas => {
-  return $postParam("/api/report/wuda/open/user/authentication/login", datas);
-};
-export const logoutAuthen = datas => {
-  return $get("/api/report/wuda/open/user/authentication/logout", datas);
-};
+import { $get, $post, $postParam } from "@/plugins/axios";
+
+export const login = datas => {
+  return $post("/api/admin/common/login", datas);
+};
+export const getSmsCode = datas => {
+  return $post("/api/admin/common/get_verify_code", datas);
+};
+export const logout = () => {
+  return $post("/api/admin/common/logout", {});
+};
+export const sysMenu = () => {
+  return $postParam("/api/admin/common/get_menu", {});
+};
+export const attachmentPreview = id => {
+  return $postParam("/api/admin/common/file/preview", { id });
+};
+export const attachmentDetail = id => {
+  return $postParam("/api/admin/common/file/get_one", { id });
+};
+export const attachmentDownload = ({ id, type }) => {
+  return $postParam("/api/admin/common/file/download", { id, type });
+};
+export const getEnums = type => {
+  return $postParam("/api/admin/common/get_enums", { type });
+};
+export const schoolList = () => {
+  return $postParam("/api/admin/common/school/list", {});
+};
+export const getSchoolInfo = code => {
+  return $postParam("/api/admin/common/school/query_by_school_code", { code });
+};
+export const getSysConfig = key => {
+  return $postParam("/api/admin/common/sys_config/get_one", { key });
+};
+export const getSysTime = () => {
+  return $postParam("/api/admin/common/get_system_time", {});
+};
+export const loginAuthen = datas => {
+  return $postParam("/api/report/wuda/open/user/authentication/login", datas);
+};
+export const logoutAuthen = datas => {
+  return $get("/api/report/wuda/open/user/authentication/logout", datas);
+};

+ 81 - 85
src/modules/login/fetchSmsMixins.js

@@ -1,85 +1,81 @@
-import { getSmsCode } from "./api";
-
-const wstorage = {
-  set(key, value, expire = null) {
-    window.localStorage.setItem(key, JSON.stringify({ value, expire }));
-  },
-  get(key, defaultVal = null) {
-    const lsvalue = JSON.parse(window.localStorage.getItem(key));
-    return lsvalue && (!lsvalue.expire || lsvalue.expire > new Date().getTime())
-      ? lsvalue.value
-      : defaultVal;
-  },
-  remove(key) {
-    window.localStorage.removeItem(key);
-  }
-};
-
-const codeWaitingTime = 60;
-
-export default {
-  data() {
-    return {
-      isFetchingCode: false,
-      codeContent: "获取验证码",
-      codeWaitingTime,
-      time: codeWaitingTime,
-      setT: null
-    };
-  },
-  methods: {
-    setWaitingTime() {
-      let codetime = wstorage.get(this.nameWaitTime);
-      if (codetime) {
-        let num = Math.floor((codetime.expire - new Date().getTime()) / 1000);
-        if (num > 0) {
-          this.time = num;
-          this.isFetchingCode = true;
-          this.changeContent();
-        }
-      }
-    },
-    fetchSmsCode() {
-      this.$refs.modalFormComp.validateField("phone", async valid => {
-        if (valid) return;
-        this.isFetchingCode = true;
-        const data = await getSmsCode(this.modalForm.phone).catch(() => {
-          this.isFetchingCode = false;
-        });
-        if (!data) return;
-        this.changeContent();
-      });
-    },
-    changeContent() {
-      if (!this.isFetchingCode) return;
-      this.codeContent = "倒计时" + this.time + "s";
-      const circleTime = time => {
-        this.setT = setInterval(() => {
-          if (time > 1) {
-            time--;
-            let expire = new Date().getTime() + time * 1000;
-            wstorage.set(
-              this.nameWaitTime,
-              {
-                time,
-                expire
-              },
-              expire
-            );
-            this.codeContent = "倒计时" + time + "s";
-          } else {
-            this.clearSetContent();
-          }
-        }, 1e3);
-      };
-      circleTime(this.time);
-    },
-    clearSetContent() {
-      this.time = this.codeWaitingTime;
-      wstorage.remove(this.nameWaitTime);
-      this.codeContent = "获取验证码";
-      this.isFetchingCode = false;
-      clearInterval(this.setT);
-    }
-  }
-};
+import { getSmsCode } from "./api";
+
+const wstorage = {
+  set(key, value, expire = null) {
+    window.localStorage.setItem(key, JSON.stringify({ value, expire }));
+  },
+  get(key, defaultVal = null) {
+    const lsvalue = JSON.parse(window.localStorage.getItem(key));
+    return lsvalue && (!lsvalue.expire || lsvalue.expire > new Date().getTime())
+      ? lsvalue.value
+      : defaultVal;
+  },
+  remove(key) {
+    window.localStorage.removeItem(key);
+  }
+};
+
+const codeWaitingTime = 60;
+
+export default {
+  data() {
+    return {
+      isFetchingCode: false,
+      codeContent: "获取验证码",
+      codeWaitingTime,
+      time: codeWaitingTime
+    };
+  },
+  methods: {
+    setWaitingTime() {
+      let codetime = wstorage.get(this.nameWaitTime);
+      if (codetime) {
+        let num = Math.floor((codetime.expire - new Date().getTime()) / 1000);
+        if (num > 0) {
+          this.time = num;
+          this.isFetchingCode = true;
+          this.changeContent();
+        }
+      }
+    },
+    fetchSmsCode() {
+      this.$refs.modalFormComp.validateField("phone", async valid => {
+        if (valid) return;
+        this.isFetchingCode = true;
+        const data = await getSmsCode(this.modalForm.phone).catch(() => {
+          this.isFetchingCode = false;
+        });
+        if (!data) return;
+        this.changeContent();
+      });
+    },
+    changeContent() {
+      if (!this.isFetchingCode) return;
+      this.codeContent = "倒计时" + this.time + "s";
+      const circleTime = time => {
+        let t = setInterval(() => {
+          if (time > 1) {
+            time--;
+            let expire = new Date().getTime() + time * 1000;
+            wstorage.set(
+              this.nameWaitTime,
+              {
+                time,
+                expire
+              },
+              expire
+            );
+            this.codeContent = "倒计时" + time + "s";
+          } else {
+            this.time = this.codeWaitingTime;
+            wstorage.remove(this.nameWaitTime);
+            this.codeContent = "获取验证码";
+            this.isFetchingCode = false;
+            clearInterval(t);
+          }
+        }, 1e3);
+      };
+      circleTime(this.time);
+    }
+  }
+};

+ 48 - 48
src/modules/login/router.js

@@ -1,48 +1,48 @@
-import LoginHome from "./views/LoginHome";
-import Login from "./views/Login";
-import SelectSchool from "./views/SelectSchool";
-import LoginAuthen from "./views/LoginAuthen";
-import LogoutAuthen from "./views/LogoutAuthen";
-
-export default {
-  path: "/login-home",
-  component: LoginHome,
-  children: [
-    {
-      path: "/login",
-      name: "Login",
-      component: Login,
-      meta: {
-        title: "登录",
-        noRequire: true
-      }
-    },
-    {
-      path: "/select-school",
-      name: "SelectSchool",
-      component: SelectSchool,
-      meta: {
-        title: "选择学校",
-        noRequire: true
-      }
-    },
-    {
-      path: "/login-authen/:code",
-      name: "LoginAuthen",
-      component: LoginAuthen,
-      meta: {
-        title: "第三方登录",
-        noRequire: true
-      }
-    },
-    {
-      path: "/logout-authen",
-      name: "LogoutAuthen",
-      component: LogoutAuthen,
-      meta: {
-        title: "第三方退出",
-        noRequire: true
-      }
-    }
-  ]
-};
+import LoginHome from "./views/LoginHome";
+import Login from "./views/Login";
+import LoginAuthen from "./views/LoginAuthen";
+import LogoutAuthen from "./views/LogoutAuthen";
+import SelectSchool from "./views/SelectSchool";
+
+export default {
+  path: "/login-home",
+  component: LoginHome,
+  children: [
+    {
+      path: "/login",
+      name: "Login",
+      component: Login,
+      meta: {
+        title: "登录",
+        noRequire: true
+      }
+    },
+    {
+      path: "/login-authen/:code",
+      name: "LoginAuthen",
+      component: LoginAuthen,
+      meta: {
+        title: "第三方登录",
+        noRequire: true
+      }
+    },
+    {
+      path: "/logout-authen",
+      name: "LogoutAuthen",
+      component: LogoutAuthen,
+      meta: {
+        title: "第三方退出",
+        noRequire: true
+      }
+    },
+    {
+      path: "/select-school",
+      name: "SelectSchool",
+      component: SelectSchool,
+      meta: {
+        title: "选择学校",
+        noRequire: true
+      }
+    }
+  ]
+};

+ 291 - 320
src/modules/login/views/Login.vue

@@ -1,320 +1,291 @@
-<template>
-  <div class="login login-box">
-    <div class="login-theme"><h2>知学知考-教研分析</h2></div>
-    <div class="login-body" @keyup.enter="submit('loginForm')">
-      <div class="login-title">
-        <img v-if="schoolLogo" :src="schoolLogo" alt="学校logo" />
-        <h1 v-else>知学知考-教研分析</h1>
-      </div>
-      <div class="login-form">
-        <el-form
-          v-if="IS_USERNAME_TYPE"
-          ref="loginForm"
-          :model="loginModel"
-          :rules="loginRules"
-        >
-          <el-form-item prop="loginName">
-            <el-input
-              v-model.trim="loginModel.loginName"
-              placeholder="请输入账号"
-              name="username"
-              clearable
-            >
-              <i class="icon icon-phone" slot="prefix"></i>
-            </el-input>
-          </el-form-item>
-          <el-form-item prop="password">
-            <el-input
-              type="password"
-              v-model.trim="loginModel.password"
-              placeholder="请输入密码"
-              clearable
-            >
-              <i class="icon icon-password" slot="prefix"></i>
-            </el-input>
-          </el-form-item>
-          <el-form-item prop="schoolCode"></el-form-item>
-          <el-form-item>
-            <el-button
-              class="login-submit-btn"
-              size="large"
-              type="info"
-              :disabled="isSubmit"
-              round
-              @click="submit('loginForm')"
-              >登录</el-button
-            >
-          </el-form-item>
-        </el-form>
-        <el-form v-else ref="loginForm" :model="loginModel" :rules="loginRules">
-          <el-form-item prop="mobileNumber">
-            <el-input
-              v-model.trim="loginModel.mobileNumber"
-              placeholder="请输入手机号"
-              name="mobileNumber"
-              clearable
-            >
-              <i class="icon icon-phone" slot="prefix"></i>
-            </el-input>
-          </el-form-item>
-          <el-form-item prop="code">
-            <div class="vlcode">
-              <div class="vlcode-right">
-                <el-button
-                  style="width:100%;"
-                  type="text"
-                  @click="fetchSmsCode"
-                  :disabled="isFetchingCode"
-                  >+{{ codeContent }}</el-button
-                >
-              </div>
-              <div class="vlcode-left">
-                <el-input
-                  v-model.trim="loginModel.code"
-                  placeholder="请输入手机验证码"
-                  name="code"
-                  clearable
-                >
-                  <i class="icon icon-checkcode" slot="prefix"></i>
-                </el-input>
-              </div>
-            </div>
-          </el-form-item>
-          <el-form-item prop="schoolCode"></el-form-item>
-          <el-form-item>
-            <el-button
-              class="login-submit-btn"
-              size="large"
-              type="info"
-              :disabled="isSubmit"
-              round
-              @click="submit('loginForm')"
-              >登录</el-button
-            >
-          </el-form-item>
-        </el-form>
-      </div>
-      <div class="login-action box-justify">
-        <div></div>
-        <el-button type="text" @click="switchLoginType">
-          <i>{{ switchBtnName }}</i>
-          <i class="el-icon-arrow-right"></i>
-        </el-button>
-      </div>
-    </div>
-
-    <!-- 修改密码 -->
-    <reset-pwd
-      :user-info="userInfo"
-      ref="ResetPwd"
-      @modified="resetPwdSuccess"
-    ></reset-pwd>
-  </div>
-</template>
-
-<script>
-import { password, phone, smscode } from "@/plugins/formRules";
-import { login, getSmsCode, getSchoolInfo } from "../api";
-import { Base64 } from "@/plugins/crypto";
-import ResetPwd from "@/modules/base/components/ResetPwd";
-import { ORG_CODE } from "@/constants/app";
-import fetchSmsMixins from "../fetchSmsMixins";
-
-export default {
-  name: "login",
-  components: { ResetPwd },
-  mixins: [fetchSmsMixins],
-  data() {
-    return {
-      nameWaitTime: "login",
-      smsCodeRequired: false,
-      loginModel: {
-        schoolCode: ORG_CODE,
-        loginName: "",
-        password: "",
-        code: "",
-        mobileNumber: ""
-      },
-      loginRules: {
-        code: smscode,
-        password,
-        loginName: [
-          {
-            required: true,
-            message: "请输入用户名",
-            trigger: "change"
-          }
-        ],
-        schoolCode: [
-          {
-            required: true,
-            message: "学校编码缺失",
-            trigger: "change"
-          }
-        ],
-        mobileNumber: phone
-      },
-      userInfo: {},
-      roles: [],
-      isSubmit: false,
-      schoolLogo: "",
-      loginType: "ACCOUNT"
-    };
-  },
-  mounted() {
-    this.$ls.clear();
-    this.setWaitingTime();
-    this.getSchool();
-  },
-  computed: {
-    IS_USERNAME_TYPE() {
-      return this.loginType === "ACCOUNT";
-    },
-    switchBtnName() {
-      return this.loginType === "ACCOUNT" ? "短信登录" : "账号登录";
-    }
-  },
-  methods: {
-    async getSchool() {
-      const data = await getSchoolInfo(ORG_CODE);
-      this.$ls.set("schoolLogo", data.logo);
-      this.$ls.set("schoolName", data.name);
-      this.schoolLogo = data.logo;
-    },
-    switchLoginType() {
-      this.loginType = this.loginType === "ACCOUNT" ? "PHONE" : "ACCOUNT";
-    },
-    async submit(name) {
-      const valid = await this.$refs[name].validate().catch(() => {});
-      if (!valid) return;
-
-      if (this.isSubmit) return;
-      this.isSubmit = true;
-      let datas = {
-        schoolCode: this.loginModel.schoolCode,
-        type: this.loginType
-      };
-      if (this.IS_USERNAME_TYPE) {
-        datas = {
-          ...datas,
-          loginName: this.loginModel.loginName,
-          password: Base64(this.loginModel.password)
-        };
-      } else {
-        datas = {
-          ...datas,
-          code: this.loginModel.code,
-          mobileNumber: this.loginModel.mobileNumber
-        };
-      }
-      const data = await login(datas).catch(() => {});
-      this.isSubmit = false;
-      if (!data) return;
-
-      if (data.orgInfo)
-        this.$ls.set("orgId", data.orgInfo.id, this.GLOBAL.authTimeout);
-      if (data.schoolInfo)
-        this.$ls.set("schoolId", data.schoolInfo.id, this.GLOBAL.authTimeout);
-      this.$ls.set("user", data, this.GLOBAL.authTimeout);
-
-      this.$ls.set("token", data.accessToken, this.GLOBAL.authTimeout);
-
-      // 强制修改密码和绑定手机号
-      if (
-        data.userLoginCheckResult &&
-        (!data.userLoginCheckResult.pwdCount ||
-          !data.userLoginCheckResult.mobileNumber)
-      ) {
-        this.userInfo = {
-          ...this.loginModel,
-          ...data.userLoginCheckResult
-        };
-        this.$refs.ResetPwd.open();
-        return;
-      }
-
-      if (data.roleList && data.roleList.includes("ADMIN")) {
-        this.$router.push({
-          name: "SelectSchool"
-        });
-      } else {
-        this.$router.push({
-          name: "Home"
-        });
-      }
-    },
-    resetPwdSuccess(data) {
-      if (data.orgInfo)
-        this.$ls.set("orgId", data.orgInfo.id, this.GLOBAL.authTimeout);
-      if (data.schoolInfo)
-        this.$ls.set("schoolId", data.schoolInfo.id, this.GLOBAL.authTimeout);
-      this.$ls.set("user", data, this.GLOBAL.authTimeout);
-
-      this.$ls.set("token", data.accessToken, this.GLOBAL.authTimeout);
-
-      if (data.roleList && data.roleList.includes("ADMIN")) {
-        this.$router.push({
-          name: "SelectSchool"
-        });
-      } else {
-        this.$router.push({
-          name: "Home"
-        });
-      }
-    },
-    // code valid
-    checkField(field) {
-      return new Promise((resolve, reject) => {
-        this.$refs.loginForm.validateField(field, unvalid => {
-          if (unvalid) {
-            reject();
-          } else {
-            resolve();
-          }
-        });
-      });
-    },
-    async fetchSmsCode() {
-      const validAll = [
-        this.checkField("mobileNumber"),
-        this.checkField("schoolCode")
-      ];
-
-      let result = true;
-      await Promise.all(validAll).catch(() => {
-        result = false;
-      });
-
-      if (!result) return;
-
-      this.isFetchingCode = true;
-      const data = await getSmsCode({
-        schoolCode: this.loginModel.schoolCode,
-        mobileNumber: this.loginModel.mobileNumber
-      }).catch(() => {
-        this.isFetchingCode = false;
-      });
-      if (!data) return;
-
-      if (data.mobileNumber) {
-        this.$message.success(
-          `已向手机尾号【${data.mobileNumber.slice(
-            -4
-          )}】成功发送短信,请在2分钟内进行验证!`
-        );
-        this.changeContent();
-      } else {
-        this.isFetchingCode = false;
-        this.$message.error("未绑定手机号,请先绑定!");
-        // this.userInfo = {
-        //   ...data,
-        //   loginName: this.loginModel.loginName,
-        //   schoolCode: this.loginModel.schoolCode,
-        //   password: this.loginModel.password
-        // };
-        // this.$refs.ResetPwd.open();
-      }
-    }
-  }
-};
-</script>
+<template>
+  <div class="login login-box">
+    <div class="login-theme"><h2>知学知考-教研分析</h2></div>
+    <div class="login-body" @keyup.enter="submit('loginForm')">
+      <div class="login-title">
+        <img v-if="schoolLogo" :src="schoolLogo" alt="学校logo" />
+        <h1 v-else>知学知考-教研分析</h1>
+      </div>
+      <div class="login-form">
+        <el-form ref="loginForm" :model="loginModel" :rules="loginRules">
+          <el-form-item prop="loginName">
+            <el-input
+              v-model.trim="loginModel.loginName"
+              name="username"
+              placeholder="请输入账号"
+              clearable
+            >
+              <i class="icon icon-phone" slot="prefix"></i>
+            </el-input>
+          </el-form-item>
+          <el-form-item prop="code" v-if="smsCodeRequired">
+            <div class="vlcode">
+              <div class="vlcode-right">
+                <el-button
+                  style="width:100%;"
+                  type="text"
+                  @click="fetchSmsCode"
+                  :disabled="isFetchingCode"
+                  >+{{ codeContent }}</el-button
+                >
+              </div>
+              <div class="vlcode-left">
+                <el-input
+                  v-model.trim="loginModel.code"
+                  placeholder="请输入手机验证码"
+                  clearable
+                >
+                  <i class="icon icon-checkcode" slot="prefix"></i>
+                </el-input>
+              </div>
+            </div>
+          </el-form-item>
+          <el-form-item prop="password">
+            <el-input
+              type="password"
+              name="password"
+              v-model.trim="loginModel.password"
+              placeholder="请输入密码"
+              clearable
+            >
+              <i class="icon icon-password" slot="prefix"></i>
+            </el-input>
+          </el-form-item>
+          <el-form-item prop="schoolCode"></el-form-item>
+          <el-form-item>
+            <el-button
+              class="login-submit-btn"
+              size="large"
+              type="info"
+              :disabled="isSubmit"
+              round
+              @click="submit('loginForm')"
+              >登录</el-button
+            >
+          </el-form-item>
+        </el-form>
+      </div>
+    </div>
+
+    <!-- 修改密码 -->
+    <reset-pwd :user-password="loginModel.password" ref="ResetPwd"></reset-pwd>
+  </div>
+</template>
+
+<script>
+import { password, smscode } from "@/plugins/formRules";
+import {
+  login,
+  getSmsCode,
+  getSchoolInfo,
+  getSysConfig,
+  getSysTime
+} from "../api";
+import { Base64 } from "@/plugins/crypto";
+import { initSyncTime } from "@/plugins/syncServerTime";
+import ResetPwd from "@/modules/base/components/ResetPwd";
+import { ORG_CODE } from "@/constants/app";
+
+const wstorage = {
+  set(key, value, expire = null) {
+    window.localStorage.setItem(key, JSON.stringify({ value, expire }));
+  },
+  get(key, defaultVal = null) {
+    const lsvalue = JSON.parse(window.localStorage.getItem(key));
+    return lsvalue && (!lsvalue.expire || lsvalue.expire > new Date().getTime())
+      ? lsvalue.value
+      : defaultVal;
+  },
+  remove(key) {
+    window.localStorage.removeItem(key);
+  }
+};
+
+const codeWaitingTime = 60;
+const nameWaitTime = "login";
+
+export default {
+  name: "login",
+  components: { ResetPwd },
+  data() {
+    return {
+      nameWaitTime,
+      smsCodeRequired: false,
+      loginModel: {
+        schoolCode: ORG_CODE,
+        loginName: "",
+        code: "",
+        password: ""
+      },
+      loginRules: {
+        code: smscode,
+        password,
+        loginName: [
+          {
+            required: true,
+            message: "请输入用户名",
+            trigger: "change"
+          }
+        ],
+        schoolCode: [
+          {
+            required: true,
+            message: "学校编码缺失",
+            trigger: "change"
+          }
+        ]
+      },
+      roles: [],
+      isSubmit: false,
+      schoolLogo: "",
+      // code
+      isFetchingCode: false,
+      codeContent: "获取验证码",
+      codeWaitingTime,
+      time: codeWaitingTime
+    };
+  },
+  mounted() {
+    this.$ls.clear();
+    this.setWaitingTime();
+    this.getSchool();
+    this.getSmsCodeRequired();
+    this.syncServerTime();
+  },
+  methods: {
+    async syncServerTime() {
+      const time = await getSysTime();
+      initSyncTime(time);
+    },
+    async getSmsCodeRequired() {
+      const data = await getSysConfig("sys.code.enable");
+      this.smsCodeRequired = data.configValue === "true";
+    },
+    async getSchool() {
+      const data = await getSchoolInfo(ORG_CODE);
+      this.$ls.set("schoolLogo", data.logo);
+      this.$ls.set("schoolName", data.name);
+      this.schoolLogo = data.logo;
+    },
+    async submit(name) {
+      const valid = await this.$refs[name].validate().catch(() => {});
+      if (!valid) return;
+
+      if (this.isSubmit) return;
+      this.isSubmit = true;
+      const data = await login({
+        loginName: this.loginModel.loginName,
+        password: Base64(this.loginModel.password),
+        code: this.smsCodeRequired ? this.loginModel.code : null,
+        schoolCode: this.loginModel.schoolCode
+      }).catch(() => {});
+      this.isSubmit = false;
+      if (!data) return;
+
+      if (data.orgInfo)
+        this.$ls.set("orgId", data.orgInfo.id, this.GLOBAL.authTimeout);
+      if (data.schoolInfo)
+        this.$ls.set("schoolId", data.schoolInfo.id, this.GLOBAL.authTimeout);
+      this.$ls.set("user", data, this.GLOBAL.authTimeout);
+
+      // 强制修改密码
+      // if (!data.user.pwdUpdateTime) {
+      //   this.$refs.ResetPwd.open();
+      //   return;
+      // }
+
+      this.$ls.set("token", data.accessToken, this.GLOBAL.authTimeout);
+      // this.$store.commit("setUser", data);
+
+      if (data.roleList.includes("ADMIN")) {
+        this.$router.push({
+          name: "SelectSchool"
+        });
+      } else {
+        this.$router.push({
+          name: "Home"
+        });
+      }
+    },
+    // code valid
+    setWaitingTime() {
+      let codetime = wstorage.get(this.nameWaitTime);
+      if (codetime) {
+        let num = Math.floor((codetime.expire - new Date().getTime()) / 1000);
+        if (num > 0) {
+          this.time = num;
+          this.isFetchingCode = true;
+          this.changeContent();
+        }
+      }
+    },
+    checkField(field) {
+      return new Promise((resolve, reject) => {
+        this.$refs.loginForm.validateField(field, unvalid => {
+          if (unvalid) {
+            reject();
+          } else {
+            resolve();
+          }
+        });
+      });
+    },
+    async fetchSmsCode() {
+      const validAll = [
+        this.checkField("loginName"),
+        this.checkField("password"),
+        this.checkField("schoolCode")
+      ];
+
+      let result = true;
+      await Promise.all(validAll).catch(() => {
+        result = false;
+      });
+
+      if (!result) return;
+
+      this.isFetchingCode = true;
+      const data = await getSmsCode({
+        loginName: this.loginModel.loginName,
+        schoolCode: this.loginModel.schoolCode,
+        password: Base64(this.loginModel.password)
+      }).catch(() => {
+        this.isFetchingCode = false;
+      });
+      if (!data) return;
+      this.$message.success(
+        `已向手机号【${data}】成功发送短信,请在2分钟内进行验证!`
+      );
+      this.changeContent();
+    },
+    changeContent() {
+      if (!this.isFetchingCode) return;
+      this.codeContent = "倒计时" + this.time + "s";
+      const circleTime = time => {
+        let t = setInterval(() => {
+          if (time > 1) {
+            time--;
+            let expire = new Date().getTime() + time * 1000;
+            wstorage.set(
+              this.nameWaitTime,
+              {
+                time,
+                expire
+              },
+              expire
+            );
+            this.codeContent = "倒计时" + time + "s";
+          } else {
+            this.time = this.codeWaitingTime;
+            wstorage.remove(this.nameWaitTime);
+            this.codeContent = "获取验证码";
+            this.isFetchingCode = false;
+            clearInterval(t);
+          }
+        }, 1e3);
+      };
+      circleTime(this.time);
+    }
+  }
+};
+</script>

+ 52 - 52
src/modules/login/views/LoginAuthen.vue

@@ -1,52 +1,52 @@
-<template>
-  <div class="login-authen">
-    <h1 class="color-white text-center">
-      <i class="el-icon-loading"></i> 正在登录...
-    </h1>
-  </div>
-</template>
-
-<script>
-import { loginAuthen } from "../api";
-
-export default {
-  name: "login-authen",
-  data() {
-    return {
-      code: this.$route.params.code
-    };
-  },
-  mounted() {
-    this.login();
-  },
-  methods: {
-    async login() {
-      if (!this.code) {
-        this.$notify.error({
-          title: "非法操作",
-          message: "code丢失"
-        });
-        return;
-      }
-      const data = await loginAuthen({ code: this.code });
-      if (!data) return;
-
-      if (data.orgInfo) this.$ls.set("orgId", data.orgInfo.id);
-      if (data.schoolInfo) this.$ls.set("schoolId", data.schoolInfo.id);
-      this.$ls.set("user", data);
-
-      // 强制修改密码
-      // if (!data.user.pwdUpdateTime) {
-      //   this.$refs.ResetPwd.open();
-      //   return;
-      // }
-
-      this.$ls.set("token", data.accessToken);
-
-      this.$router.push({
-        name: "Home"
-      });
-    }
-  }
-};
-</script>
+<template>
+  <div class="login-authen">
+    <h1 class="color-white text-center">
+      <i class="el-icon-loading"></i> 正在登录...
+    </h1>
+  </div>
+</template>
+
+<script>
+import { loginAuthen } from "../api";
+
+export default {
+  name: "login-authen",
+  data() {
+    return {
+      code: this.$route.params.code
+    };
+  },
+  mounted() {
+    this.login();
+  },
+  methods: {
+    async login() {
+      if (!this.code) {
+        this.$notify.error({
+          title: "非法操作",
+          message: "code丢失"
+        });
+        return;
+      }
+      const data = await loginAuthen({ code: this.code });
+      if (!data) return;
+
+      if (data.orgInfo) this.$ls.set("orgId", data.orgInfo.id);
+      if (data.schoolInfo) this.$ls.set("schoolId", data.schoolInfo.id);
+      this.$ls.set("user", data);
+
+      // 强制修改密码
+      // if (!data.user.pwdUpdateTime) {
+      //   this.$refs.ResetPwd.open();
+      //   return;
+      // }
+
+      this.$ls.set("token", data.accessToken);
+
+      this.$router.push({
+        name: "Home"
+      });
+    }
+  }
+};
+</script>

+ 15 - 25
src/modules/login/views/LoginHome.vue

@@ -1,25 +1,15 @@
-<template>
-  <div class="login-home">
-    <router-view></router-view>
-    <div class="login-footer">
-      <p>
-        <a href="http://www.qmth.com.cn" target="_blank"
-          >Copyright © 2022 启明泰和</a
-        >
-        <a href="https://beian.miit.gov.cn/" target="_blank"
-          >鄂ICP备12000033号-9</a
-        >
-      </p>
-    </div>
-  </div>
-</template>
-
-<script>
-export default {
-  name: "login-home",
-  data() {
-    return {};
-  },
-  methods: {}
-};
-</script>
+<template>
+  <div class="login-home">
+    <router-view></router-view>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "login-home",
+  data() {
+    return {};
+  },
+  methods: {}
+};
+</script>

+ 19 - 19
src/modules/login/views/LogoutAuthen.vue

@@ -1,19 +1,19 @@
-<template>
-  <div class="logout-authen">
-    <h1 class="color-white text-center">
-      <i class="el-icon-loading"></i> 正在退出...
-    </h1>
-  </div>
-</template>
-
-<script>
-export default {
-  name: "logout-authen",
-  data() {
-    return {};
-  },
-  created() {
-    window.location.href = "/api/report/wuda/open/user/authentication/logout";
-  }
-};
-</script>
+<template>
+  <div class="logout-authen">
+    <h1 class="color-white text-center">
+      <i class="el-icon-loading"></i> 正在退出...
+    </h1>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "logout-authen",
+  data() {
+    return {};
+  },
+  created() {
+    window.location.href = "/api/report/wuda/open/user/authentication/logout";
+  }
+};
+</script>

+ 75 - 76
src/modules/login/views/SelectSchool.vue

@@ -1,76 +1,75 @@
-<template>
-  <div class="select-school login login-box">
-    <div class="login-theme"></div>
-    <div class="login-body">
-      <div class="login-title">
-        <h1>选择学校</h1>
-      </div>
-      <div class="school-form">
-        <el-form ref="modalFormComp" :model="modalForm" :rules="rules">
-          <el-form-item prop="schoolId">
-            <school-select
-              v-model="modalForm.schoolId"
-              style="width:100%;"
-              @change="schoolChange"
-            ></school-select>
-          </el-form-item>
-          <el-form-item>
-            <el-button style="width:100%;" type="primary" @click="confirm"
-              >进入学校</el-button
-            >
-          </el-form-item>
-          <el-form-item>
-            <el-button style="width:100%;" type="warning" @click="toAdmin"
-              >进入超管中心<i class="el-icon-arrow-right"></i
-            ></el-button>
-          </el-form-item>
-        </el-form>
-      </div>
-    </div>
-  </div>
-</template>
-
-<script>
-export default {
-  name: "select-school",
-  data() {
-    return {
-      schools: [],
-      modalForm: { schoolId: "" },
-      curSchool: {},
-      rules: {
-        schoolId: [{ required: true, message: "请选择学校", trigger: "change" }]
-      }
-    };
-  },
-  created() {
-    this.$ls.remove("schoolId");
-    this.$ls.remove("schoolName");
-    this.$ls.remove("schoolLogo");
-  },
-  methods: {
-    schoolChange(school) {
-      this.curSchool = school;
-    },
-    toAdmin() {
-      this.$router.push({ name: "Admin" });
-    },
-    async confirm() {
-      const valid = await this.$refs.modalFormComp.validate().catch(() => {});
-      if (!valid) return;
-
-      this.$ls.set(
-        "schoolId",
-        this.modalForm.schoolId,
-        this.GLOBAL.authTimeout
-      );
-      this.$ls.set("schoolName", this.curSchool.name, this.GLOBAL.authTimeout);
-      this.$ls.set("schoolLogo", this.curSchool.logo, this.GLOBAL.authTimeout);
-
-      this.$router.push({
-        name: "Home"
-      });
-    }
-  }
-};
-</script>
+<template>
+  <div class="select-school login login-box">
+    <div class="login-body">
+      <div class="login-title">
+        <h1>选择学校</h1>
+      </div>
+      <div class="login-form">
+        <el-form ref="modalFormComp" :model="modalForm" :rules="rules">
+          <el-form-item prop="schoolId">
+            <school-select
+              v-model="modalForm.schoolId"
+              style="width:100%;"
+              @change="schoolChange"
+            ></school-select>
+          </el-form-item>
+          <el-form-item>
+            <el-button style="width:100%;" type="primary" @click="confirm"
+              >进入学校</el-button
+            >
+          </el-form-item>
+          <el-form-item>
+            <el-button style="width:100%;" type="warning" @click="toAdmin"
+              >进入超管中心<i class="el-icon-arrow-right"></i
+            ></el-button>
+          </el-form-item>
+        </el-form>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "select-school",
+  data() {
+    return {
+      schools: [],
+      modalForm: { schoolId: "" },
+      curSchool: {},
+      rules: {
+        schoolId: [{ required: true, message: "请选择学校", trigger: "change" }]
+      }
+    };
+  },
+  created() {
+    this.$ls.remove("schoolId");
+    this.$ls.remove("schoolName");
+    this.$ls.remove("schoolLogo");
+  },
+  methods: {
+    schoolChange(school) {
+      this.curSchool = school;
+    },
+    toAdmin() {
+      this.$router.push({ name: "Admin" });
+    },
+    async confirm() {
+      const valid = await this.$refs.modalFormComp.validate().catch(() => {});
+      if (!valid) return;
+
+      this.$ls.set(
+        "schoolId",
+        this.modalForm.schoolId,
+        this.GLOBAL.authTimeout
+      );
+      this.$ls.set("schoolName", this.curSchool.name, this.GLOBAL.authTimeout);
+      this.$ls.set("schoolLogo", this.curSchool.logo, this.GLOBAL.authTimeout);
+
+      this.$router.push({
+        name: "Home"
+      });
+    }
+  }
+};
+</script>

+ 1 - 1
src/views/Home.vue

@@ -164,7 +164,7 @@ export default {
     }
   },
   created() {
-    this.initData1();
+    this.initData();
   },
   methods: {
     initData1() {

+ 2 - 3
vue.config.js

@@ -7,13 +7,12 @@ var devProxy = {
   }
 };
 
-var proxy = process.env.NODE_ENV === "production" ? {} : devProxy;
-
 // 配置手册: https://cli.vuejs.org/zh/config/#vue-config-js
 var config = {
   // publicPath: './',
   devServer: {
-    port: 8057
+    port: 8057,
+    proxy: devProxy
   },
   transpileDependencies: ["vue-echarts", "resize-detector"],
   chainWebpack: config => {