import { getGoodsCommonDataAPI } from "../services/api";
import { getCustomer } from '@/utils/request';

export default {
  namespace: "goodsCommon",

  state: {
    goodsAllData: []
  },

  effects: {
    // 请求轮播图片
    *getGoodsCommon({ payload }, { call, put }) {
      payload = payload ? payload : {};
      payload.search_customerId = getCustomer().id;
      payload.search_customerRankCode = getCustomer().customerRankCode;
      // payload.search_EQ_isOptional = 0;
      // payload.search_EQ_enableStrucManage = 0;
      payload.search_EQ_isEnable = 1;
      const response = yield call(getGoodsCommonDataAPI, payload);
      yield put({
        type: "goodsCommonData",
        data: response
      });
    }
  },

  reducers: {
    goodsCommonData(state, { data }) {
      return {
        ...state,
        goodsAllData: data.content
      };
    }
  }
};
