diff --git a/pages/index.vue b/pages/index.vue index 298e911..1bce01b 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -12,7 +12,7 @@ - + @@ -86,6 +86,7 @@ const auditreject = iconConfig.auditreject; const auditrejectacount = ref(111) const adauditacount = ref(111) const adpassacount = ref(111) +const quanx = ref(true) const list1 = ref([ { icon: auditreject, title: `未通过(${auditrejectacount.value})` }, { icon: adaudit, title: `待审核(${adauditacount.value})` }, @@ -103,6 +104,9 @@ const list2 = ref([ const grid1Click1 = (e) => { console.log(e); } +onMounted(() => { + getUserRoles() +}) onLoad(() => { proxy.$store.dispatch('webSockerInfo') getCountInfo(); @@ -110,11 +114,11 @@ onLoad(() => { onShow(() => { proxy.$store.dispatch('webSockerInfo') getCountInfo(); + getUserRoles() }) const getCountInfo = () =>{ let from = {} getCount(from).then(e => { - let data = e.data // 将字符串转换为整数并相加 auditrejectacount.value = parseInt(data.talkTopicNoPass || 0) + parseInt(data.actiTopicNoPass || 0); @@ -128,6 +132,46 @@ const getCountInfo = () =>{ }) } +// 获取用户角色权限 +const getUserRoles = () => { + const userInfo = uni.getStorageSync('loginUserPost'); + if (userInfo && Array.isArray(userInfo.roles)) { + userInfo.roles.forEach(role => { + // 判断客服角色 + if (role.roleKey === 'kfuser') { + uni.setTabBarItem({ + index: 0, + visible: false + }); + // 判断审核角色 + } else if (role.roleKey === 'audituser') { + uni.setTabBarItem({ + index: 1, + visible: false + }); + list2.value = [ + { icon: talkautid, title: '话题审核' }, + { icon: adacaudit, title: '活动审核' }, + { icon: stuaudit, title: '认证审核' }, +] + } + // 判断任务的等级角色 + else if (role.roleKey === 'taskLevel') { + uni.setTabBarItem({ + index: 1, + visible: false + }); + list2.value = [ + { icon: adcoin, title: '校园币管理' }, + { icon: adgrade, title: '等级管理' } + ] + quanx.value = false + } + }); + } else { + console.error('loginUserPost 不存在或 roles 不是一个数组'); + } +}; // 点击管理工具的按钮aaa const grid1Click2 = (e) => {