const state = {
  token: '',
  info: {},
  menuInfo: {},//菜单点击数据
  tabList:[], //tab页存储
  tabIndex:0, //tab页的坐标
  outProductId:0,//商品详情id
  category_info_id:0,//类目详情id
  brand_info_id:0,//品牌详情id  
  goodsid:0,//审核中商品id
  isdisable:false//审核中商品编辑状态
}
const getters = {
  getToken: state => state.token,
  getUserInfo: state => state.info,
  getMenuInfo: state => state.menuInfo,
  getTabList:state=>state.tabList,
  getTabIndex:state=>state.tabIndex,
  getOutProductId:state=>state.outProductId,
  getCategory_info_id:state=>state.category_info_id,
  getBrand_info_id:state=>state.brand_info_id,
  getGoodsId:state=>state.goodsid,
  getIsDisable:state=>state.isdisable
}
const mutations = {
  SET_GOODS_ID(state, goodsid) {
    state.goodsid = goodsid
  },
  SET_ISDISABLE(state, isdisable) {
    state.isdisable = isdisable
  },
  SET_USER_TOKEN(state, token) {
    state.token = token
  },
  SET_USER_INFO(state, info) {
    state.info = info
  },
  SET_USER_AVATAR(state, info) {
    state.info.avatar = info
  },
  RESET_TOKEN() {
    state.token = ''
  },
  SET_MENUINFO(state, menuInfo) {
    state.menuInfo = menuInfo
  },
  SET_TABLIST(state, tabList) {
    state.tabList = tabList
  },
  SET_TABINDEX(state,index){
    state.tabIndex=index
  },
  SET_OUTPRODUCTID(state,outProductId){
    state.outProductId=outProductId
  },
  SET_CATEGORY_INFO_ID(state,category_info_id){
    state.category_info_id=category_info_id
  },
  SET_BRAND_INDO_ID(state,brand_info_id){
    state.brand_info_id=brand_info_id
  },
  REMOVETAB(state,tabname){
    state.tabList.forEach((element,index) => {
      if(element.name==tabname){
        if(state.tabIndex!=0){
          state.tabIndex--
        }
        state.tabList.splice(index,1)
      }
    });
  },
  CLEAR(state){
    state.tabList=[],
    state.menuInfo={},
    state.info={},
    state.token = '',
    state.tabIndex=0
  }
}
export default {
  state,
  getters,
  mutations
}
