import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) import tabBar from "@/utils/tabbar.js"; // 引入刚刚创建的tabBar.js const store = new Vuex.Store({ state: { dynamicTabbar: [], // 动态tabbar tabBarList: [], dataType: null,//数据标识权限 }, getters: {}, actions: { changeTabbar({ commit }, res) { /* admin 超管 1123598816738675201 客户 1846419477876510721 客服 1839536982874193922 维修负责人 1839537055389515777 维修人员 1839552581620793346 */ if (res.detail.status == 90) { commit('updateTabbar', tabBar.oathTab) uni.reLaunch({ url: "/pages/login/authInfo", }); } else { // console.log(66666666666,role_id) if (res.role_id == "1123598816738675201" || res.role_id == "1846419477876510721") { commit('updateDatatype', 1) //客户 commit('updateTabbar', tabBar.member) uni.reLaunch({ url: "/pages/home/index", }); } if (res.role_id == "1839536982874193922") { commit('updateDatatype', 2) //客服 commit('updateTabbar', tabBar.ordinary) uni.reLaunch({ url: "/pages/submission/records", }); } if (res.role_id == "1839537055389515777") { commit('updateDatatype', 3) //维修负责人 commit('updateTabbar', tabBar.manage) uni.reLaunch({ url: "/pages/submission/records", }); // this.$u.api.updateCoordinate().then(res=>{ // }) } if (res.role_id == "1839552581620793346") { commit('updateDatatype', 4) //维修人员 commit('updateTabbar', tabBar.repair) uni.reLaunch({ url: "/pages/submission/records", }); // 如果是维修人员登录 则实时更新当前维修人员的位置 } } }, changeDatatype({ commit }, type) { commit('updateTabbar', payload) } }, mutations: { updateTabbar(state, list) { uni.setStorageSync('tabBarList', list) // 根据登录时传过来的值,存储对应的tabbarlist state.dynamicTabbar = list }, updateDatatype(state, data) { state.dataType = data } } }) export default store