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

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: {},
    topLists: {},
    fav: {},

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

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