import { getToken, getProjectId, getCookieUserInfo, getSessionUserInfo } from '@/utils/cookies'

export interface UserState {
  token: string
  openid: string
  userName: string
  userId: string
  userPhone: number
  projectId: string,
  companyId: string,
  remoteControl: boolean  // 当前用户是否可以远程控制设备
}

export const state: UserState = {
  token: getToken() || '',
  openid: '',
  userName: getSessionUserInfo() ? getSessionUserInfo().name : '',
  userId: getSessionUserInfo() ? getSessionUserInfo().id : '',
  userPhone: getSessionUserInfo() ? getSessionUserInfo().phone : 0,
  projectId: getSessionUserInfo() ? getSessionUserInfo().projectId : getProjectId() || '',
  companyId: '',
  remoteControl: false
}
