import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) // 动态底部tabbar const userRoleTabbar = { first: [{ pagePath: "pages/tabbar-page/index-tabbar/index-tabbar", iconPath: "../../static/tabBar-icon/Gfayun.png", selectedIconPath: "../../static/tabBar-icon/Bfayun1.png", text: "首页" }, { pagePath: "pages/tabbar-page/myPage-tabbar/myPage-tabbar", iconPath: "../../static/tabBar-icon/Gmine10.png", selectedIconPath: "../../static/tabBar-icon/Bmine57.png", text: "我的" } ], second: [{ pagePath: "pages/tabbar-page/index-tabbar/index-tabbar", iconPath: "../../static/tabBar-icon/Ghome.png", selectedIconPath: "../../static/tabBar-icon/Bhome.png", text: "首页" }, { pagePath: "pages/tabbar-page/myPage-tabbar/myPage-tabbar", iconPath: "../../static/tabBar-icon/Gmine10.png", selectedIconPath: "../../static/tabBar-icon/Bmine57.png", text: "我的" } ] } const store = new Vuex.Store({ state: { // 用戶界面判斷 userInfo: {}, roleType: null, // 1客户,2货代,3司机 userTabbar: [] ,// 用户所在角色底部菜单, }, mutations: { setUserInfo(state, identity) { state.userInfo = userObj[identity] }, // 设置底部栏 setUserTabbar(state, roleType) { state.roleType = roleType if (roleType == 1) { state.userTabbar = userRoleTabbar.first uni.setStorageSync('userTabbar', state.userTabbar) } else if (roleType == 2 || roleType == 3) { state.userTabbar = userRoleTabbar.second uni.setStorageSync('userTabbar', state.userTabbar) } } } }) export default store