Bladeren bron

首页增加权限判断

luohailiang 2 jaren geleden
bovenliggende
commit
53df52e73a

+ 32 - 3
src/components/CommonHeader/index.vue

@@ -1,9 +1,7 @@
 <script setup>
 import {login,message} from "./api.js";
 import {user, refresh} from '~/store/user';
-
-// console.log('user :>> ', user);
-const navList = [
+let navList = [
   {
     id: '1',
     title: '首页',
@@ -40,6 +38,37 @@ const navList = [
     name: 'tbkt'
   }
 ]
+if(user && user.user_role_id && user.user_role_id > 75) {
+  navList = [
+    {
+      id: '1',
+      title: '首页',
+      name: 'home'
+    },
+    {
+      id: '2',
+      title: '课程资源',
+      name: 'resource'
+    },
+    {
+      id: '3',
+      title: '直播课堂',
+      name: 'zbkt'
+    },
+    {
+      id: '5',
+      title: '艺术广场',
+      name: 'ysgc'
+    },
+    {
+      id: '6',
+      title: '数字美术馆',
+      name: 'szmsg'
+    },
+  ]
+}
+// console.log('user :>> ', user);
+
 
 const route = useRoute()
 const currentRootRoute = $computed(() => route.matched[0].path.substring(1))

+ 68 - 44
src/pages/home/index.vue

@@ -213,6 +213,7 @@ import bgImg1 from "/images/home/live-2.png";
 import bgImg2 from "/images/home/live-3.png";
 import 'swiper/css/swiper.css';
 import Swiper from 'swiper';
+import {ElMessage} from "element-plus";
 
 export default {
     components: {
@@ -347,63 +348,86 @@ export default {
             this.curMenu = item;
         },
         toTeacher() {
-            this.$router.push({name: 'resource'});
+            if(!user) {
+              ElMessage.warning(`请先登录!`);
+            } else {
+              this.$router.push({name: 'resource'});
+            }
+
             // localStorage.setItem('curNav', 'resource');
         },
         toLive(type) {
+          if(!user) {
+            ElMessage.warning(`请先登录!`);
+          } else {
             switch (type) {
-                case 1:
-                    if (user.user_role_id < 76) {
-                        this.$router.push({name: 'ssys'});
-                    }
+              case 1:
+                if (user.user_role_id < 76) {
+                  this.$router.push({name: 'ssys'});
+                } else{
+                  ElMessage.warning(`您暂无权限!`);
+                }
 
-                    // localStorage.setItem('curNav', 'zbkt');
-                    break;
-                case 2:
-                    this.$router.push({name: 'wlzb'});
-                    // localStorage.setItem('curNav', 'zbkt');
-                    break;
-                case 3:
-                    this.$router.push({name: 'ztzb'});
-                    // localStorage.setItem('curNav', 'zbkt');
-                    break;
-                case 4:
-                    if (user.user_role_id < 76) {
-                        this.$router.push({name: 'zhjy_zhjyzxxx'});
-                    }
+                // localStorage.setItem('curNav', 'zbkt');
+                break;
+              case 2:
+                this.$router.push({name: 'wlzb'});
+                // localStorage.setItem('curNav', 'zbkt');
+                break;
+              case 3:
+                this.$router.push({name: 'ztzb'});
+                // localStorage.setItem('curNav', 'zbkt');
+                break;
+              case 4:
+                if (user.user_role_id < 76) {
+                  this.$router.push({name: 'zhjy_zhjyzxxx'});
+                }  else{
+                  ElMessage.warning(`您暂无权限!`);
+                }
 
-                    // localStorage.setItem('curNav', 'zhjy');
-                    break;
-                case 5:
-                    if (user.user_role_id < 76) {
-                        this.$router.push({name: 'zhjy_zhjyxtbk'});
-                    }
+                // localStorage.setItem('curNav', 'zhjy');
+                break;
+              case 5:
+                if (user.user_role_id < 76) {
+                  this.$router.push({name: 'zhjy_zhjyxtbk'});
+                } else {
+                  ElMessage.warning(`您暂无权限!`);
+                }
 
-                    // localStorage.setItem('curNav', 'zbkt');
-                    break;
-                case 6:
-                    if (user.user_role_id < 76) {
-                        this.$router.push({name: 'zhjy_zhjytbjy'});
-                    }
+                // localStorage.setItem('curNav', 'zbkt');
+                break;
+              case 6:
+                if (user.user_role_id < 76) {
+                  this.$router.push({name: 'zhjy_zhjytbjy'});
+                } else {
+                  ElMessage.warning(`您暂无权限!`);
+                }
 
-                    // localStorage.setItem('curNav', 'zbkt');
-                    break;
-                case 7:
-                    this.$router.push({name: 'ysgc'});
-                    // localStorage.setItem('curNav', 'zbkt');
-                    break;
-                case 8:
-                    this.$router.push({name: 'szmsg'});
-                    // localStorage.setItem('curNav', 'zbkt');
-                    break;
+                // localStorage.setItem('curNav', 'zbkt');
+                break;
+              case 7:
+                this.$router.push({name: 'ysgc'});
+                // localStorage.setItem('curNav', 'zbkt');
+                break;
+              case 8:
+                this.$router.push({name: 'szmsg'});
+                // localStorage.setItem('curNav', 'zbkt');
+                break;
             }
+          }
+
         },
         lookDetail(id, type) {
+          if(!user) {
+            ElMessage.warning(`请先登录!`);
+          } else {
             if (type == 1) {
-                this.$router.push({name: "ysgc_stuDetail", params: {id: id}});
+              this.$router.push({name: "ysgc_stuDetail", params: {id: id}});
             } else if (type == 2) {
-                this.$router.push({name: "ysgc_jsDetail", params: {id: id}});
+              this.$router.push({name: "ysgc_jsDetail", params: {id: id}});
             }
+          }
+
         },
         initXSData() {
             request({
@@ -638,7 +662,7 @@ export default {
                 right: 0;
                 top: 0;
                 z-index: 30;
-                width: 137px;
+                width: 145px;
                 height: 27px;
                 background: rgba(0, 0, 0, 0.59);
                 border-radius: 0 10px 0 10px;

+ 1 - 1
src/pages/ysgc/jsDetail/index.vue

@@ -12,7 +12,7 @@
     <div class="content">
 
       <div class="detail-title">
-        <h3 class="con_title">美术 +</h3>
+        <h3 class="con_title">{{detailData.yz_name}}</h3>
         <el-popover placement="bottom" :width="410" trigger="hover">
           <template #reference>
             <div class="share">

+ 1 - 1
src/pages/ysgc/stuDetail/index.vue

@@ -11,7 +11,7 @@
     </div>
     <div class="content">
       <div class="detail-title">
-        <h3 class="con_title">美术 +</h3>
+        <h3 class="con_title">{{detailData.yz_name}}</h3>
         <el-popover placement="bottom" :width="410" trigger="hover">
           <template #reference>
             <div class="share">