import { useLoginUserStore } from '@/stores/loginUser'
const loginUserStore = useLoginUserStore()
export function useLoginSuccess() {
  /**
   * 登录成功后的操作
   */
  const loginSuccess = (user) => {
		loginUserStore.setLoginHospital(user.infoPermission.hospitals);
    loginUserStore.setLoginUser(user.user);
    loginUserStore.setLoginUserMenu(user.menu);
		let loginType = uni.getStorageSync('loginType'); //1:处理 2:报修
    // 判断用户标识是否为处理人
    if (user.user.engineer === 1) {
      uni.reLaunch({
        url: '/pages/incidentList/incidentList'
      })
    } else {
			if(loginType==1){
				uni.reLaunch({
				  url: "/pages/repairEntrance/repairEntrance"
				})
			}else if(loginType==2){
				uni.reLaunch({
				  url: "/pages/repair/home"
				})
			}
    }
  }

  return {
    loginSuccess
  };
}