guanchunjie 3 роки тому
батько
коміт
bdd61ab5d5

+ 5 - 2
src/components/Personalcenter/AccountSet.vue

@@ -413,7 +413,7 @@ export default {
       };
       getContent(MethodName, data).then((res) => {
         this.SelectLoading = false;
-        this.total = res.total_count;
+        this.total = this.total ? this.total : res.total_count;
         let orgList = JSON.parse(JSON.stringify(this.orgList));
         let list = orgList.concat(res.org_list);
         this.orgList = this.handleOrgList(JSON.parse(JSON.stringify(list)));
@@ -431,6 +431,8 @@ export default {
           let item = list[i];
           if (myOrgId.indexOf(item.id) < 0) {
             resArr.push(item);
+          } else {
+            this.total = this.total - 1;
           }
         }
       } else {
@@ -441,7 +443,8 @@ export default {
     },
     // 滚动加载
     SelectScroll() {
-      if (this.orgList.length == this.total) {
+      console.log(this.orgList.length, this.total);
+      if (this.orgList.length >= this.total) {
         // this.$message.warning("No more data");
         return;
       }

+ 33 - 169
src/components/common/Header.vue

@@ -39,7 +39,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">
@@ -119,6 +119,7 @@ import { getToken, removeToken, getConfig } from "@/utils/auth";
 import Cookies from "js-cookie";
 import { getContent, getStaticContent, getLearnWebContent } from "@/api/ajax";
 import { setI18nLang } from "@/utils/i18n";
+import { saveSession, getSession, removeSession } from "@/utils/role";
 
 export default {
   name: "LayoutHeader",
@@ -218,69 +219,8 @@ export default {
         return;
       }
       _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`;
-      }
-    },
-    handleCommand2(command) {
-      let _this = this;
-      _this.LoginNavIndex = command;
-      if (!_this.userMessage) {
-        this.$message.warning("Please login first");
-        this.projectName = "考试中心";
-        window.location.href = "/";
-        return;
-      }
-      let MethodName = "login_control-CreateAccessCode";
-      let acsCode = null;
-      getContent(MethodName, {}).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?AccessCode=${acsCode}`;
-        } else if (id == 1) {
-          // 教材管理系统
-          location.href = `/GCLS-Book/#/EnterSys?AccessCode=${acsCode}`;
-        } else if (id == 2) {
-          // 教培中心
-          location.href = `/GCLS-TRC/#/EnterSys?AccessCode=${acsCode}`;
-        } else if (id == 3) {
-          // 教研中心
-          location.href = `/GCLS-TC/#/EnterSys?AccessCode=${acsCode}`;
-        } else if (id == 4) {
-          // 考试中心
-          location.href = `/GCLS-Test/#/EnterSys?AccessCode=${acsCode}`;
-        } else if (id == 5) {
-          // 学习中心
-          location.href = `/GCLS-LC/#/EnterSys?AccessCode=${acsCode}`;
-        } else {
-          // 个人中心
-          location.href = `/GCLS-Personal/#/EnterSys?AccessCode=${acsCode}`;
-        }
-      });
+      let relative_path = _this.projectList[command].relative_path;
+      location.href = relative_path;
     },
     // 切换登录的注册
     cutLoginReg() {
@@ -288,6 +228,7 @@ export default {
     },
     QuitLogin() {
       removeToken();
+      removeSession("SysList");
       this.userShow = false;
       this.userMessage = null;
       window.location.href = "/";
@@ -312,101 +253,24 @@ export default {
       await setI18nLang(lang_type);
       this.$router.go(0);
     },
-    handleProList(list) {
-      let projectList = [];
-      if (list.length == 0) {
-        let arr = [
-          {
-            id: 2,
-            name: "教培中心",
-            img: "project3",
-          },
-          {
-            id: 3,
-            name: "教研中心",
-            img: "project4",
-          },
-          {
-            id: 5,
-            name: "学习中心",
-            img: "project6",
-          },
-          {
-            id: 6,
-            name: "个人中心",
-            img: "project7",
-          },
-        ];
-        projectList = arr;
-      } else {
-        if (list.includes(2000001)) {
-          projectList = JSON.parse(JSON.stringify(this.teacherProList));
-          for (let i = 0; i < list.length; i++) {
-            let code = list[i];
-            if (code == 2000003) {
-              projectList.push({
-                id: 1,
-                name: "教材管理系统",
-                img: "project2",
-              });
-            }
-          }
-        } else {
-          for (let i = 0; i < list.length; i++) {
-            let code = list[i];
-            if (code == 2000002) {
-              projectList.push({
-                id: 0,
-                name: "教学管理系统",
-                img: "project1",
-              });
-            } else if (code == 2000003) {
-              projectList.push({
-                id: 1,
-                name: "教材管理系统",
-                img: "project2",
-              });
-            } else if (code == 2000004) {
-              projectList.push({
-                id: 2,
-                name: "教培中心",
-                img: "project3",
-              });
-            } else if (code == 2000005) {
-              projectList.push({
-                id: 4,
-                name: "考试中心",
-                img: "project5",
-              });
-            } else if (code == 2000006) {
-              projectList.push({
-                id: 3,
-                name: "教研中心",
-                img: "project4",
-              });
-            }
-          }
-          projectList.push({
-            id: 6,
-            // Teacher training center
-            name: "个人中心",
-            img: "project7",
-          });
-        }
-      }
-      // 排序
-      for (var i = 0; i < projectList.length - 1; i++) {
-        for (var j = 0; j < projectList.length - 1 - i; j++) {
-          // 相邻元素两两对比,元素交换,大的元素交换到后面
-          if (projectList[j].id > projectList[j + 1].id) {
-            var temp = projectList[j];
-            projectList[j] = projectList[j + 1];
-            projectList[j + 1] = temp;
+    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-Personal") {
+                _this.LoginNavIndex = index;
+              }
+            });
+            saveSession("SysList", this.projectList);
           }
-        }
-      }
-      console.log(projectList);
-      return projectList;
+        })
+        .catch((err) => {
+          console.log(err);
+        });
     },
   },
   created() {
@@ -415,23 +279,23 @@ export default {
     if (config) {
       _this.configInfor = JSON.parse(config);
     }
+    let SysList = getSession("SysList");
+    if (!SysList) {
+      _this.getChildSysList();
+    } else {
+      _this.projectList = SysList;
+      _this.projectList.forEach((item, index) => {
+        if (item.key == "GCLS-Personal") {
+          _this.LoginNavIndex = index;
+        }
+      });
+    }
   },
   mounted() {
     let _this = this;
     let user = getToken();
     if (user) {
       _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);
-      } else if (_this.userMessage.user_type == "STUDENT") {
-        _this.projectList = _this.stuProList;
-      }
-      _this.projectList.forEach((item, index) => {
-        if (item.id == 6) {
-          _this.LoginNavIndex = index;
-        }
-      });
       _this.getNotReadMessage();
       setInterval(() => {
         _this.getNotReadMessage();

+ 4 - 0
src/utils/request.js

@@ -4,6 +4,7 @@ import store from '../store'
 import Cookies from 'js-cookie'
 import { Message } from 'element-ui'
 import { removeToken } from './auth';
+import { removeSession } from './role';
 
 axios.defaults.withCredentials = true
 axios.defaults.dataType = 'json'
@@ -59,6 +60,8 @@ service.interceptors.response.use(
         showClose: true,
         duration: 0
       })
+      removeToken();
+      removeSession('SysList');
       // if (process.env.NODE_ENV === 'development') {
       //   router.push(`/login`)
       // } else {
@@ -72,6 +75,7 @@ service.interceptors.response.use(
       Cookies.remove('user_real_name')
       Cookies.remove('user_type')
       removeToken();
+      removeSession('SysList');
       msg = Message({
         message: '登录会话失效,请重新登录',
         type: 'error',

+ 4 - 1
src/views/login.vue

@@ -82,9 +82,10 @@
 <script>
 import { validUsername, validPass } from "@/utils/validate";
 import { getStaticContent } from "@/api/ajax";
-import { getObjArr, saveObjArr } from "@/utils/role";
+import { getObjArr, removeSession, saveObjArr } from "@/utils/role";
 import { setToken } from "@/utils/auth";
 import { getConfigInfor } from "@/utils/index";
+
 export default {
   name: "Login",
   data() {
@@ -150,6 +151,7 @@ export default {
     },
     //登录
     handleLogin() {
+      removeSession("SysList");
       this.$refs.loginForm.validate((valid) => {
         if (valid) {
           this.loading = true;
@@ -178,6 +180,7 @@ export default {
     },
   },
   mounted() {
+    removeSession("SysList");
     this._getConfig();
   },
 };