mutations.js 1.47 KB
import * as Types from './types';
// import { find, set } from 'lodash';

export default {

  /*
   * @ description: 更新二手商品详情页
   * @ author: huzhiming
   * @ date: 2019-11-22 19:09:49
   * @ version: v1.0.0
  */
  [Types.UPDATE_PRODUCT_DETAIL](state, { info }) {
    if (info) {
      state.info = info;
    } else {
      state.info = {
        imageList: [],
        price: '',
        sizeName: '',
        shoeBoxDesc: '',
        productId: '',
        productName: '',
        productCode: '',
        colorName: '',
        describeInfo: '',
        brandName: '',
        shoeQualityDesc: '',
        soldTime: '',
        image: ''
      };
    }
  },

  /*
   * @ description: 更新相同尺寸 二手商品列表
   * @ author: huzhiming
   * @ date: 2019-11-22 19:09:02
   * @ version: v1.0.0
  */
  [Types.UPDATE_PRODUCT_LIST](state, { data: { product_list, page_total, page, total }, isReset, error }) {
    if (error) {
      state.isShowEmpty = true;
      return false;
    }

    if (product_list) {
      if (page_total > page) {
        state.isMore = true;
        state.pageTotal = page_total;
        state.page = page + 1;
      } else {
        state.isMore = false;
      }

      if (isReset) {
        state.productList = product_list;
      } else {
        state.productList = state.productList.push(...product_list);
      }

      state.total = total;
    }
  },

  [Types.UPDATE_PRODUCT_FILTER](state, { filter }) {
    state.filterData = filter;
  }
};