const state = {
  proxyInfo: null,
  proxySwitch: false,
  proxyRefresh: false
}

const mutations = {
  // 开启用供应商代理
  OPEN_PROXY: (state, proxy) => {
    state.proxyInfo = {
      authUserId: proxy.authUserId,
      infoId: proxy.infoId,
      name: proxy.name,
      shopStatus: proxy.shopStatus ? 1 : 0,
      shopType: proxy.shopType,
      userIdentity: 2, // 开启代理
      mobile: proxy.mobile,
      token: proxy.token,
      prefix: proxy.prefix
    }
    state.proxySwitch = true // 用于判断是否需要更新路由 ture：需要更新， false：不需要更新
    state.proxyRefresh = true // 代理状态是否改变 根据改状态开重置路由和路由列表
  },
  // 关闭供应商代理
  CLOSE_PROXY: (state) => {
    state.proxyInfo = null
    state.proxySwitch = false
    state.proxyRefresh = true
  },
  // 更改代理状态
  CHANGE_PROXY_STATE: (state, status) => {
    state.proxyRefresh = status
  }
}

export default {
  namespaced: true,
  state,
  mutations
}
