import Keys from '@/constant/key'
import { getToken, getProjectId, getCookieUserInfo, getSessionUserInfo, getCookieMac, getCookieMacNew } from '@/utils/cookies'

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

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