Kaynağa Gözat

修改头部为请求接口及图标

秦鹏 3 yıl önce
ebeveyn
işleme
db919a31b2
4 değiştirilmiş dosya ile 60 ekleme ve 40 silme
  1. 10 1
      src/api/api.js
  2. 40 37
      src/components/Header.vue
  3. 4 0
      src/utils/request.js
  4. 6 2
      src/views/login.vue

+ 10 - 1
src/api/api.js

@@ -68,7 +68,16 @@ export function GetFillemessage(MethodName, data) {
         data,
     })
 }
-export function getContent(MethodName, UserCode, UserType, SessionID, data) {
+export function getContent(MethodName, data) {
+    let userInfor = JSON.parse(getToken());
+    let UserCode = '',
+        UserType = '',
+        SessionID = ''
+    if (userInfor) {
+        UserCode = userInfor.user_code;
+        UserType = userInfor.user_type;
+        SessionID = userInfor.session_id;
+    }
     return request({
         url: `/GCLSFileServer/ServiceInterface?MethodName=${MethodName}&UserCode=${UserCode}&UserType=${UserType}&SessionID=${SessionID}`,
         method: 'post',

+ 40 - 37
src/components/Header.vue

@@ -47,7 +47,7 @@
                 >
                   <img
                     style="position: relative; width: 24px"
-                    :src="require('../assets/login/' + item.img + '.png')"
+                    :src="item.icon_url_memu_default"
                     alt=""
                   />
                   <span style="margin-left: 16px">
@@ -133,6 +133,7 @@ import Cookies from "js-cookie";
 import { getContent, getStaticContent, getLearnWebContent } from "@/api/api";
 import { setI18nLang } from "@/utils/i18n";
 import { getConfig } from "@/utils/auth";
+import { saveSession, getSession, removeSession } from "@/utils/role";
 
 export default {
   name: "LayoutHeader",
@@ -238,35 +239,9 @@ export default {
         window.location.href = "/";
         return;
       }
-      let MethodName = "login_control-CreateAccessCode";
-      let acsCode = null;
-      // getContent(MethodName, UserCode, UserType, SessionID).then((res) => {
-      //   acsCode = res.access_code;
-      _this.projectName = this.projectList[command].name;
-      let id = this.projectList[command].id;
-      if (id == 0) {
-        // 教学管理系统
-        location.href = `/GCLS-Learn/#/EnterSys`;
-      } else if (id == 1) {
-        // 教材管理系统
-        location.href = `/GCLS-Book/#/EnterSys`;
-      } else if (id == 2) {
-        // 教培中心
-        location.href = `/GCLS-TRC/#/EnterSys`;
-      } else if (id == 3) {
-        // 教研中心
-        location.href = `/GCLS-TC/#/EnterSys`;
-      } else if (id == 4) {
-        // 考试中心
-        location.href = `/GCLS-Test/#/EnterSys`;
-      } else if (id == 5) {
-        // 学习中心
-        location.href = `/GCLS-LC/#/EnterSys`;
-      } else {
-        // 个人中心
-        location.href = `/GCLS-Personal/#/EnterSys`;
-      }
-      // });
+      _this.projectName = _this.projectList[command].name;
+      let relative_path = _this.projectList[command].relative_path;
+      location.href = relative_path;
     },
     // 切换登录的注册
     cutLoginReg() {
@@ -275,6 +250,7 @@ export default {
     QuitLogin() {
       window.location.href = "/";
       removeToken();
+      removeSession("SysList");
       Cookies.remove("JSESSIONID");
       this.userShow = false;
       this.userMessage = null;
@@ -407,8 +383,40 @@ export default {
     // async _getConfig() {
     //   this.configInfor = await getConfigInfor();
     // },
+    getChildSysList() {
+      let _this = this;
+      let MethodName = "login_control-GetChildSysList_CanEnter_PC";
+      getContent(MethodName, {})
+        .then((res) => {
+          if (res.child_sys_list && res.child_sys_list.length > 0) {
+            _this.projectList = res.child_sys_list;
+            _this.projectList.forEach((item, index) => {
+              if (item.key == "GCLS-LC") {
+                _this.LoginNavIndex = index;
+              }
+            });
+            saveSession("SysList", this.projectList);
+          }
+        })
+        .catch((err) => {
+          console.log(err);
+        });
+    },
+  },
+  created() {
+    let _this = this;
+    let SysList = getSession("SysList");
+    if (!SysList) {
+      _this.getChildSysList();
+    } else {
+      _this.projectList = SysList;
+      _this.projectList.forEach((item, index) => {
+        if (item.key == "GCLS-LC") {
+          _this.LoginNavIndex = index;
+        }
+      });
+    }
   },
-  created() {},
   mounted() {
     let _this = this;
     let user = getToken();
@@ -416,15 +424,10 @@ export default {
       _this.userMessage = JSON.parse(user);
       let popedom_code_list = _this.userMessage.popedom_code_list;
       if (_this.userMessage.user_type == "TEACHER") {
-        _this.projectList = _this.handleProList(popedom_code_list);
+        // _this.projectList = _this.handleProList(popedom_code_list);
       } else if (_this.userMessage.user_type == "STUDENT") {
         _this.projectList = _this.stuProList;
       }
-      _this.projectList.forEach((item, index) => {
-        if (item.id == 5) {
-          _this.LoginNavIndex = index;
-        }
-      });
     }
     // _this._getConfig();
     _this.configInfor = JSON.parse(getConfig());

+ 4 - 0
src/utils/request.js

@@ -4,6 +4,8 @@ import store from '../store'
 import Cookies from 'js-cookie'
 import { Message } from 'element-ui'
 import { getToken, removeToken } from "../utils/auth"
+import { removeSession } from "@/utils/role";
+
 axios.defaults.withCredentials = true
 axios.defaults.dataType = 'json'
 axios.defaults.headers['cache-control'] = 'no-cache'
@@ -62,6 +64,8 @@ service.interceptors.response.use(
         } else if (res.status === -1) {
             // 登录失效
             removeToken()
+            removeSession("SysList");
+
             msg = Message({
                 message: '登录会话失效,请重新登录',
                 type: 'error',

+ 6 - 2
src/views/login.vue

@@ -81,11 +81,13 @@
 
 <script>
 import { validUsername, validPass } from "@/utils/validate";
-import { getContent } from "@/api/api";
+import { getStaticContent } from "@/api/api";
 import { getObjArr, saveObjArr } from "@/utils/role";
 import Cookies from "js-cookie";
 import { setToken } from "@/utils/auth";
+import { removeSession } from "@/utils/role";
 import { getConfigInfor } from "@/utils/index";
+3;
 export default {
   name: "Login",
   data() {
@@ -151,6 +153,7 @@ export default {
     },
     //登录
     handleLogin() {
+      removeSession("SysList");
       this.$refs.loginForm.validate((valid) => {
         if (valid) {
           this.loading = true;
@@ -163,7 +166,7 @@ export default {
             user_name: this.loginForm.username,
             password: this.loginForm.password,
           };
-          getContent(MethodName, UserCode, UserType, SessionID, data)
+          getStaticContent(MethodName, data)
             .then((res) => {
               setToken(res);
               this.$router.push({ path: "/" });
@@ -183,6 +186,7 @@ export default {
   },
   mounted() {
     this._getConfig();
+    removeSession("SysList");
   },
 };
 </script>