index.js 1.56 KB
import actions from './actions';
import mutations from './mutations';

export function defaultSelectedSize() {
  return {
    productId: null,
    product: {},
    sizeId: null,
    storageId: null,
    size: {},
  };
}

export function defaultProduct() {
  return {
    brand_name: '',
    canPublishSecondHand: false,
    gender: '通用',
    goods_list: [
      {
        canAddSize: false,
        color_name: '',
        goods_id: null,
        goods_name: '-',
        image_list: [
        ],
        size_list: [
        ]
      }
    ],
    least_price: null,
    max_price: null,
    max_sort_id: null,
    min_price: null,
    offer_price: null,
    product_code: null,
    product_id: null,
    product_name: null,
    sale_time: null,
    sellerCanPublish: true,
    series_name: null,
    shelve_status: null,
    resource: null,
    activity: [],
    recommend: [],
    top3: [],
  };
}

export function defaultState() {
  return {
    products: {},

    /**
     1: 当前商品对应品牌系统的推荐
     2: 商品详情页面取前3
     3: 品牌系统-商品列表页面显示前30个商品, 且不能显示当前详情页对应的商品(接口过滤)
     */
    topLists: {},
    fav: {},

    /**
     * 用户在商品详情页选择的交易信息
     * productId: 商品id
     * product: 商品详情
     * sizeId: 尺寸id
     * storageId: 库存id
     * size: 尺寸信息
     */
    selectedProductInfo: defaultSelectedSize(),
  };
}

export default function() {
  return {
    namespaced: true,
    state: defaultState(),
    mutations,
    actions,
  };
}