import { getAccount, setAccount, getBrandId, setBrandId, getBrandPrefix, setBrandPrefix, getToken, setToken, getUid, setUid, getType, setType, setHeadImg, getHeadImg } from '@/libs/util'

export default {
  state: {
    account: getAccount(),
    brandId: getBrandId(),
    brandPrefix: getBrandPrefix(),
    access: 'admin',
    token: getToken(),
    uid: getUid(),
    type: getType(),
    headImg: getHeadImg()
  },
  getters: {
    isBrand: (state) => { return state.brandId != 0 }
  },
  mutations: {
    setAccount (state, account) {
      state.account = account
      setAccount(account)
    },
    setBrandId (state, brandId) {
      state.brandId = brandId
      setBrandId(brandId)
    },
    setBrandPrefix (state, brandPrefix) {
      state.brandPrefix = brandPrefix
      setBrandPrefix(brandPrefix)
    },
    setToken (state, token) {
      state.token = token
      setToken(token)
    },
    setUid (state, uid) {
      state.uid = uid
      setUid(uid)
    },
    setType (state, type) {
      state.type = type
      setType(type)
    },
    setHeadImg (state, headImg) {
      state.headImg = headImg
      setHeadImg(headImg)
    }
  }
}
