const state = {
  proxyInfo: null,
  proxyState: false,
  isChangeProxy: false
}

const mutations = {
  // 开启用供应商代理
  OPEN_PROXY: (state, proxy) => {
    state.proxyInfo = {
      authUserId: proxy.authUserId,
      brandId: proxy.brandId,
      name: proxy.name,
      password: proxy.password,
      shopStatus: proxy.shopStatus ? 1 : 0,
      shopType: proxy.shopType,
      userIdentity: 2 // 开启代理
    }
    state.proxyState = true // 用于判断是否需要更新路由 ture：需要更新， false：不需要更新
    state.isChangeProxy = true
  },
  // 关闭供应商代理
  CLOSE_PROXY: state => {
    state.proxyInfo = null
    state.proxyState = false
    state.isChangeProxy = true
  },
  // 更改代理状态
  CHANGE_PROXY_STATE: (state, status) => {
    state.isChangeProxy = status
  }
}

export default {
  namespaced: true,
  state,
  mutations
}
