| | |
| | | // 如果version无需保存到本地永久存储,无需lifeData.version方式 |
| | | version: '1.0.0', |
| | | activeRoleId: "", |
| | | tabBarList: [], |
| | | // tabBarList: [], |
| | | adCodeBase: {}, |
| | | tabbarIndex: uni.getStorageSync("tabbarIndex") || 0, |
| | | // tabbarIndex: uni.getStorageSync("tabbarIndex") || 0, |
| | | hasUpdate: false, //true为不可登录,需要更新,false则是最新版 |
| | | |
| | | menu: [], |
| | | }, |
| | | |
| | | mutations: { |
| | |
| | | // 保存变量到本地,见顶部函数定义 |
| | | saveLifeData(saveKey, state[saveKey]) |
| | | }, |
| | | // 设置菜单 |
| | | setTabBarList(state, data) { |
| | | let i = 0 |
| | | if (state.tabBarList.length > 0) { |
| | | i = state.tabBarList.length |
| | | } |
| | | data.forEach(e => { |
| | | e.i = i |
| | | i++ |
| | | }) |
| | | // // 设置菜单 |
| | | // setTabBarList(state, data) { |
| | | // let i = 0 |
| | | // if (state.tabBarList.length > 0) { |
| | | // i = state.tabBarList.length |
| | | // } |
| | | // data.forEach(e => { |
| | | // e.i = i |
| | | // i++ |
| | | // }) |
| | | |
| | | state.tabBarList = data; |
| | | uni.setStorageSync('tabBarList', data) |
| | | // console.log(uni.getStorageSync('tabBarList')) |
| | | }, |
| | | // state.tabBarList = data; |
| | | // uni.setStorageSync('tabBarList', data) |
| | | // // console.log(uni.getStorageSync('tabBarList')) |
| | | // }, |
| | | //设置当前激活的角色 |
| | | setActiveRoleId(state, roleId) { |
| | | state.activeRoleId = roleId |
| | | uni.setStorageSync('activeRoleId', roleId) |
| | | }, |
| | | //设置底部导航栏索引 |
| | | SET_TABBAT_INDEX(state, index) { |
| | | state.tabbarIndex = index |
| | | uni.setStorageSync('tabbarIndex', index) |
| | | |
| | | SET_MENU(state, menuList) { |
| | | state.menu = menuList |
| | | uni.setStorageSync('menu', menuList) |
| | | }, |
| | | |
| | | //设置底部导航栏索引 |
| | | // SET_TABBAT_INDEX(state, index) { |
| | | // state.tabbarIndex = index |
| | | // uni.setStorageSync('tabbarIndex', index) |
| | | // }, |
| | | SET_HAS_UPDATE(state, val) { |
| | | state.hasUpdate = val |
| | | uni.setStorageSync('hasUpdate', val) |
| | |
| | | }, |
| | | |
| | | async submit() { |
| | | const that = this |
| | | |
| | | //保存当前激活的角色 |
| | | store.commit("setActiveRoleId", this.selectRole.id) |
| | | |
| | |
| | | let data = res.data |
| | | const appMenu = data.filter(e => e.name == 'app')[0] |
| | | console.log("菜单:", appMenu) |
| | | store.commit("SET_MENU", appMenu) |
| | | |
| | | |
| | | this.$u.func.showToast("切换角色成功") |
| | | |
| | | uni.showToast({ |
| | | title: "切换身份成功", |
| | | icon: "success", |
| | | duration: data.duration || 1500, |
| | | success: () => { |
| | | setTimeout(() => { |
| | | this.$u.func.globalNavigator("/pages/home/index", "switchTab") |
| | | }, data.duration || 1500) |
| | | } |
| | | }) |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | import { |
| | | logAdd |
| | | } from "@/api/system/logManage" |
| | | import { |
| | | messageCount |
| | | } from "@/api/system/message" |
| | | import { |
| | | saveCId |
| | | } from "@/api/system/user.js" |
| | | |
| | | // 全局公共方法 |
| | | const install = (Vue, vm) => { |
| | |
| | | vm.$u.vuex('accessToken', userInfo.access_token) |
| | | vm.$u.vuex('isLogin', true) |
| | | |
| | | //添加当前激活的roleId(默认取第一个) |
| | | vm.$u.vuex('activeRoleId', userInfo.role_id.split(",")[0]) |
| | | let activeRoleId = userInfo.role_id.split(",")[0] |
| | | console.log("当前激活角色的id:", activeRoleId) |
| | | |
| | | uni.switchTab({ |
| | | url: '/pages/home/index' |
| | | //添加当前激活的roleId(默认取第一个) |
| | | vm.$u.vuex('activeRoleId', activeRoleId) |
| | | |
| | | //获取角色菜单 |
| | | dynamicMenu(activeRoleId).then(res => { |
| | | let data = res.data |
| | | let appMenu = data.filter(e => e.name == 'app')[0] |
| | | console.log("当前角色菜单:", appMenu) |
| | | vm.$u.vuex('menu', appMenu) |
| | | |
| | | //跳转到首页 |
| | | uni.switchTab({ |
| | | url: '/pages/home/index' |
| | | }) |
| | | |
| | | }) |
| | | } |
| | | |