import { useLoginUserStore } from '@/stores/loginUser' const loginUserStore = useLoginUserStore(); export function useSetTabbar() { /** * 设置tabbar */ const setTabbar = (index) => { let flag = false; let loginType = uni.getStorageSync('loginType'); //1:处理 2:报修 switch(index){ case 0: // 故障 if(loginUserStore.loginUser.user.engineer == 1){ if(loginType==1){ flag = true; }else{ flag = false; } } break; case 1: // 巡检 if(loginUserStore.loginUser.user.engineer == 0){ flag = false; }else if(loginUserStore.loginUser.menu.some(v => v.link === 'inspectionExecute')){ if(loginType==1){ flag = true; }else{ flag = false; } } break; case 2: // 知识库 if(loginUserStore.loginUser.user.engineer == 1){ if(loginType==1){ flag = true; }else{ flag = false; } }else{ flag = false; } break; case 3: // 首页 if(loginUserStore.loginUser.user.engineer == 0){ flag = true; }else{ if(loginType==1){ flag = false; }else{ flag = true; } } break; case 4: // 我的报修 if(loginUserStore.loginUser.user.engineer == 0){ flag = true; }else{ if(loginType==1){ flag = false; }else{ flag = true; } } break; case 5: // 我的 if(loginUserStore.loginUser.user.engineer == 1){ if(loginType==1){ flag = true; }else{ flag = false; } }else{ flag = false; } break; case 6: // 设置 if(loginUserStore.loginUser.user.engineer == 0){ flag = true; }else{ if(loginType==1){ flag = false; }else{ flag = true; } } break; } uni.setTabBarItem({ index, visible: flag, }); } return { setTabbar }; }