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

  return {
    setTabbar
  };
}