From 3c738f4fe2762bba8087e5a22fc0dc06560eab0e Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Thu, 08 Aug 2024 10:01:17 +0800
Subject: [PATCH] 三色任务与自查任务
---
utils/func.js | 107 +++++++++++++++++------------------------------------
1 files changed, 35 insertions(+), 72 deletions(-)
diff --git a/utils/func.js b/utils/func.js
index efef0f5..eada620 100644
--- a/utils/func.js
+++ b/utils/func.js
@@ -1,91 +1,48 @@
import store from "@/store/index.js"
import {
- dynamicMenu
+ dynamicMenu,
+ getDetail
} from "@/api/system/role.js"
import {
logAdd
} from "@/api/system/logManage"
-import {
- messageCount
-} from "@/api/system/message"
-import {
- saveCId
-} from "@/api/system/user.js"
// 全局公共方法
const install = (Vue, vm) => {
// 登录操作 1
- const login = (userInfo) => {
+ const login = async (userInfo, pageType) => {
vm.$u.vuex('userInfo', userInfo)
vm.$u.vuex('accessToken', userInfo.access_token)
- vm.$u.vuex('refreshToken', userInfo.refresh_token)
vm.$u.vuex('isLogin', true)
- vm.$u.vuex('adCodeBase', userInfo.detail.adCodeBase)
- let role = userInfo.role_id.split(",")
- dynamicMenu(userInfo.role_id, 'app').then(res => {
- if (res.code == 200) {
- let adCodeBase = userInfo.detail.adCodeBase
- if (res.data.length > 2) {
- //当菜单有 首页 工作 我的 时,对用户进行判断
- if (!adCodeBase) {
- //没有行政区划时 去掉首页
- res.data.shift()
- }
- }
-
- store.commit("setTabBarList", res.data)
- store.commit('setActiveRoleId', role[0])
- // uni.switchTab({
- // url: res.data[0].path
- // })
- let url = res.data[0].path
- let name = ""
- if (url.indexOf("patrol")) {
- name = "责任人首页"
- } else {
- name = "首页"
- }
-
- let params = {
- recipient: userInfo.user_id,
- status: 0
- }
-
- // #ifdef APP-PLUS
-
- //2.0
- // 获取App端cid并存入redis
- let pinf = plus.push.getClientInfo();
- console.log(pinf, pinf.clientid, "---------------")
- if (pinf && pinf.clientid) {
- uni.setStorageSync('cid', pinf.clientid);
- saveCId(userInfo.user_id, pinf.clientid)
- } else {
- var obtainingCIDTimer = setInterval(function() {
- pinf = plus.push.getClientInfo();
- if (pinf.clientid) {
- uni.setStorageSync('cid', pinf.clientid);
- saveCId(userInfo.user_id, pinf.clientid)
- clearInterval(obtainingCIDTimer);
- }
- }, 50);
- }
- setTimeout(() => {
- console.log('cid', uni.getStorageSync('cid'));
- }, 500);
-
-
- // #endif
-
- messageCount(params).then(res => {
- updateTabbar(res.data)
- globalNavigator(url, "switchTab", name)
- })
- }
+ let activeRoleId = userInfo.role_id.split(",")[0]
+ const resDetail = await getDetail({
+ id: activeRoleId
+ })
+ console.log("当前激活角色的id:", resDetail.data)
+ //添加当前激活的角色(默认取第一个)
+ store.commit('setActiveRole', resDetail.data)
+ //获取角色菜单
+ const {
+ data
+ } = await dynamicMenu({
+ roleId: activeRoleId,
+ roleName: resDetail.data.roleName
})
-
+ let appMenu = data.filter(e => e.name == 'app')[0].children
+ console.log("当前角色菜单:", appMenu)
+ store.commit('SET_MENU', appMenu)
+ if (pageType == 4 && resDetail.data.roleAlias == "mj") {
+ uni.navigateTo({
+ url: '/subPackage/school/security'
+ })
+ } else {
+ //跳转到首页
+ uni.switchTab({
+ url: '/pages/home/index'
+ })
+ }
}
@@ -98,6 +55,12 @@
})
vm.$u.vuex('accessToken', '')
vm.$u.vuex('isLogin', false)
+ if (uni.getStorageSync("pageType")) {
+ uni.removeStorageSync("pageType")
+ }
+ if (uni.getStorageSync("houseCode")) {
+ uni.removeStorageSync("houseCode")
+ }
uni.redirectTo({
url: '/pages/login/login-account'
})
--
Gitblit v1.9.3