Procházet zdrojové kódy

统一vip权限判断

shmily1213 před 1 měsícem
rodič
revize
2ca1513a17

+ 8 - 0
README.md

@@ -0,0 +1,8 @@
+# IE-plus 项目
+
+## 微信小程序适配问题
+1、插槽
+
+- 不支持在父组件```for```循环中使用子组件的具名作用域插槽;
+
+- 在```for```循环中渲染同一个具名插槽时,只会渲染一个;

+ 0 - 1
package.json

@@ -58,7 +58,6 @@
     "@dcloudio/uni-h5": "3.0.0-4080720251210001",
     "@dcloudio/uni-mp-weixin": "3.0.0-4080720251210001",
     "@rojer/katex-mini": "^1.3.4",
-    "@vueuse/core": "^14.1.0",
     "echarts": "^6.0.0",
     "flyio": "^0.6.14",
     "katex": "^0.16.25",

+ 4 - 0
src/common/routes.ts

@@ -181,6 +181,10 @@ export const routes = {
    * 常见问题
    */
   pageQa: '/pagesSystem/pages/qa/qa',
+  /**
+   * 测评中心
+   */
+  pageTestCenter: '/pagesOther/pages/test-center/index/index',
 } as const;
 
 export type Routes = keyof typeof routes;

+ 7 - 4
src/hooks/useAuth.ts

@@ -34,13 +34,16 @@ export const useAuth = () => {
     return hasAuth;
   }
 
+  /**
+   * 检查是否具有VIP权限,开了 VIP 的学生、教师、代理商都有VIP权限
+   * @returns 是否具有VIP权限
+   */
   const checkVipPermission = () => {
-    if (!isVip.value) {
-
-    }
+    return hasPermission([EnumUserRole.VIP, EnumUserRole.AGENT, EnumUserRole.TEACHER]);
   }
 
   return {
-    hasPermission
+    hasPermission,
+    checkVipPermission
   }
 }

+ 2 - 2
src/pagesMain/pages/index/components/index-map.vue

@@ -16,7 +16,7 @@
           style="margin-bottom: -18rpx">
           第{{ i + 1 }}步
         </view>
-        <view class="w-full bg-back-light rounded-10 flex flex-col items-center pt-36 pb-28"
+        <view class="w-full bg-back-light rounded-10 flex flex-col items-center pt-36 pb-22"
           style="box-shadow: 1px 2px 0px 0px #DCF8BC;">
           <view>
             <view class="text-24 text-fore-title flex items-center gap-12">
@@ -70,7 +70,7 @@ const maps = computed<SiteMap[]>(() => [{
 }, {
   title: '自我评价',
   desc: '了解自身优势',
-  pagePath: ''
+  pagePath: routes.pageTestCenter
 }, {
   title: '职业规划',
   desc: '锁定职业方向',

+ 2 - 2
src/pagesOther/pages/skill/index/index.vue

@@ -45,7 +45,7 @@ import {getSkillRules, postSkillRules} from "@/api/modules/voluntary";
 import {useAuth} from "@/hooks/useAuth";
 import {EnumUserRole} from "@/common/enum";
 
-const {hasPermission} = useAuth();
+const {checkVipPermission} = useAuth();
 const emptyImg = computed(() => config.ossUrl + '/volunteer/voluntary/index/empty_data.png')
 
 const form = ref<InstanceType<typeof VoluntaryForm>>()
@@ -91,7 +91,7 @@ const handleSelect = async () => {
 }
 
 const handleSubmit = async () => {
-    const hasAuth = hasPermission([EnumUserRole.VIP]);
+  const hasAuth = checkVipPermission();
     if (!hasAuth) {
         return;
     }

+ 3 - 3
src/pagesOther/pages/university/detail/components/plan-enroll-list.vue

@@ -75,7 +75,7 @@ import {useAuth} from "@/hooks/useAuth";
 import {EnumUserRole} from "@/common/enum";
 import {useUserStore} from "@/store/userStore";
 
-const {hasPermission} = useAuth();
+const {checkVipPermission} = useAuth();
 
 const props = withDefaults(defineProps<{
     mode: HistoryMode;
@@ -152,7 +152,7 @@ const handleRuleClick = (descriptor: IPlanEnrollDescriptor, history: IPlanEnroll
 }
 
 const handleAddVoluntary = async (item: IPlanEnrollHistory) => {
-    const hasAuth = hasPermission([EnumUserRole.VIP]);
+  const hasAuth = checkVipPermission();
     if (!hasAuth) {
         return;
     }
@@ -162,7 +162,7 @@ const handleAddVoluntary = async (item: IPlanEnrollHistory) => {
 }
 
 const handleRateVoluntary = (item: IPlanEnrollHistory) => {
-    const hasAuth = hasPermission([EnumUserRole.VIP]);
+    const hasAuth = checkVipPermission();
     if (!hasAuth) {
         return;
     }

+ 2 - 2
src/pagesOther/pages/university/index/index.vue

@@ -21,7 +21,7 @@ import { useTransferPage } from "@/hooks/useTransferPage";
 import { useAuth } from "@/hooks/useAuth";
 import { EnumUserRole } from "@/common/enum";
 
-const { hasPermission } = useAuth();
+const { checkVipPermission } = useAuth();
 const { transferTo, routes } = useTransferPage();
 const current = ref(0);
 const tabs = ref<SwiperTabItem[]>([{
@@ -36,7 +36,7 @@ const handleChangeSwiper = function (e: any) {
   current.value = e.detail.current;
 }
 const handleDetail = (u: University.University) => {
-  const hasAuth = hasPermission([EnumUserRole.VIP]);
+  const hasAuth = checkVipPermission();
   if (!hasAuth) {
     return;
   }

+ 2 - 2
src/pagesOther/pages/voluntary/index/index.vue

@@ -37,7 +37,7 @@ import {getRenderRules, postRenderRules} from "@/api/modules/voluntary";
 import { useAuth } from "@/hooks/useAuth";
 import { EnumUserRole } from "@/common/enum";
 
-const { hasPermission } = useAuth();
+const { checkVipPermission } = useAuth();
 const emptyImg = computed(() => config.ossUrl + '/volunteer/voluntary/index/empty_data.png')
 
 const form = ref<InstanceType<typeof VoluntaryForm>>()
@@ -87,7 +87,7 @@ const processSelected = async (picked: SelectedUniversityMajor) => {
 }
 
 const handleSubmit = async () => {
-    const hasAuth = hasPermission([EnumUserRole.VIP]);
+    const hasAuth = checkVipPermission();
     if (!hasAuth) {
         return;
     }

+ 2 - 2
src/pagesOther/pages/voluntary/list/list.vue

@@ -50,7 +50,7 @@ interface ActionItem {
     disabled?: boolean;
 }
 
-const {hasPermission} = useAuth();
+const {checkVipPermission} = useAuth();
 const {transferTo} = useTransferPage()
 const list = ref<VoluntaryRecord[]>([])
 const paging = ref<ZPagingInstance>()
@@ -166,7 +166,7 @@ const handleDeleted = () => {
 }
 
 const handleAdd = async () => {
-    const hasAuth = hasPermission([EnumUserRole.VIP]);
+    const hasAuth = checkVipPermission();
     if (!hasAuth) {
         return;
     }

+ 2 - 2
src/pagesStudy/components/vhs-exam-item.vue

@@ -30,7 +30,7 @@ import { useTransferPage } from '@/hooks/useTransferPage';
 import { useAuth } from '@/hooks/useAuth';
 import { getOpenExaminee } from '@/api/modules/study';
 
-const { hasPermission } = useAuth();
+const { checkVipPermission } = useAuth();
 const { transferTo } = useTransferPage();
 const props = defineProps<{
   data: Study.VHSPaper;
@@ -41,7 +41,7 @@ const isFinished = computed(() => {
 });
 
 const handleStartExam = () => {
-  const hasAuth = hasPermission([EnumUserRole.VIP]);
+  const hasAuth = checkVipPermission();
   if (hasAuth) {
     if (isFinished.value) {
       transferTo('/pagesStudy/pages/simulation-analysis/simulation-analysis', {

+ 2 - 2
src/pagesStudy/pages/knowledge-practice/knowledge-practice.vue

@@ -36,7 +36,7 @@ const currentSubjectIndex = ref<number>(-1);
 const userStore = useUserStore();
 const pagingRef = ref<ZPagingInstance>();
 
-const { hasPermission } = useAuth();
+const { checkVipPermission } = useAuth();
 const pageTitle = computed(() => {
   const { isVHS, directed, questionType } = prevData.value;
   if (isVHS) {
@@ -96,7 +96,7 @@ const loadKnowledgeList = async () => {
 }
 
 const handleStartPractice = async (node: Study.KnowledgeNode) => {
-  const hasAuth = hasPermission([EnumUserRole.VIP, EnumUserRole.AGENT, EnumUserRole.TEACHER]);
+  const hasAuth = checkVipPermission();
   if (hasAuth) {
     transferTo('/pagesStudy/pages/exam-start/exam-start', {
       data: {

+ 2 - 2
src/pagesStudy/pages/textbooks-practice/textbooks-practice.vue

@@ -31,7 +31,7 @@ import { useAuth } from '@/hooks/useAuth';
 const { prevData, transferTo } = useTransferPage();
 const userStore = useUserStore();
 const pagingRef = ref();
-const { hasPermission } = useAuth();
+const { checkVipPermission } = useAuth();
 
 const pageTitle = computed(() => {
   return '教材同步练习';
@@ -60,7 +60,7 @@ const loadKnowledgeList = async (page: number, size: number) => {
 }
 
 const handleStartPractice = async (node: Study.KnowledgeNode) => {
-  const hasAuth = hasPermission([EnumUserRole.VIP, EnumUserRole.AGENT, EnumUserRole.TEACHER]);
+  const hasAuth = checkVipPermission();
   if (hasAuth) {
     transferTo('/pagesStudy/pages/exam-start/exam-start', {
       data: {