Pārlūkot izejas kodu

feat:增加局端校端用户权限隔离

coder 1 gadu atpakaļ
vecāks
revīzija
49bb83c2d2
2 mainītis faili ar 17 papildinājumiem un 2 dzēšanām
  1. 2 1
      public/auto-login.html
  2. 15 1
      src/pages/index.vue

+ 2 - 1
public/auto-login.html

@@ -82,6 +82,7 @@
       dd.ready(function () {
         var corpId = params.corpId ? params.corpId : '';
         var tag = params.tag ? params.tag : '';
+        var role = params.role ? params.role : '';
         // const t = tag.split('_');
         // if (t.length > 1) {
         //   tag = t.splice(0, 1)[0];
@@ -133,7 +134,7 @@
                           return
                         }
                         localStorage.setItem('userInfo', JSON.stringify(res.data));
-                        location.href = '/app/mobile/' + (tag ? ('#/?tag=' + tag) : '');
+                        location.href = '/app/mobile/' + (tag ? ('#/?tag=' + tag) : '') + (role ? ('&role=' + role) : '');
                       } else {
                         alert(res.msg);
                       }

+ 15 - 1
src/pages/index.vue

@@ -1,6 +1,7 @@
 <script setup>
 import * as dd from 'dingtalk-jsapi'
 import { menuList } from './menuData.js'
+import { userInfo } from "~/store/user";
 
 defineOptions({
   name: 'IndexPage',
@@ -9,6 +10,19 @@ const router = useRouter()
 const { currentRoute } = useRouter()
 const route = currentRoute.value
 const tag = route.query.tag
+const role = route.query.role
+
+const { uo_type } = userInfo;
+const isBureau = ref(false); // 当前用户是否局端
+isBureau.value = uo_type === "1";
+let authVerify = $ref(false)
+if ((isBureau.value && role == 'ju') || (!isBureau.value && role == 'xiao')) {
+  authVerify = true
+} else {
+  let msg = "您是" + (isBureau.value ? "教育局" : "学校") + "用户,无法访问此应用"
+  alert(msg)
+}
+
 let menuListData = {}
 for (const item of menuList) {
   if (item.tag === tag) {
@@ -36,7 +50,7 @@ function linkTo(child) {
 
 <template>
   <div class="IndexPage">
-    <div class="bodyContainer">
+    <div v-show="authVerify" class="bodyContainer">
       <div class="card">
         <div class="titleCard">
           <p>{{ menuListData.title }}</p>