import { sldCommonService } from '@/utils/utils';

export default {
  namespace: 'manage',

  state: {
    notice: [],
  },

  effects: {
    * getVendorSetting({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'get', `v3/seller/seller/store/settingDetail`);
      if (callback) callback(response);
    },
    //获取商户绑定的商品分类
    * getVendorGoodsCategory({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'get', `v3/goods/seller/goodsCategory/list`);
      if (callback) callback(response);
    },

    //获取商户的关于我们图片列表
    * getStoreProfile({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'get', `v3/seller/seller/storeProfile/list`);
      if (callback) callback(response);
    },
    //商户简介弹窗的编辑
    * getStroeAboutEdit({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'post', `v3/seller/seller/storeProfile/edit`);
      if (callback) callback(response);
    },
    //商户简介弹窗的新增
    * getStroeAboutAdd({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'post', `v3/seller/seller/storeProfile/add`);
      if (callback) callback(response);
    },
    //商户简介列表的删除
    * getStroeAboutDel({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'post', `v3/seller/seller/storeProfile/delete`);
      if (callback) callback(response);
    },

    //荣誉资质列表
    * getStoreCertificate({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'get', `v3/seller/seller/storeCertificate/list`);
      if (callback) callback(response);
    },
    * getStoreCertificateAdd({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'post', `v3/seller/seller/storeCertificate/add`);
      if (callback) callback(response);
    },
    * getStoreCertificateEdit({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'post', `v3/seller/seller/storeCertificate/edit`);
      if (callback) callback(response);
    },
    * getStoreCertificateDel({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'post', `v3/seller/seller/storeCertificate/delete`);
      if (callback) callback(response);
    },

    //荣誉资质列表
    * getStoreFactory({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'get', `v3/seller/seller/storeCompanyShow/list`);
      if (callback) callback(response);
    },
    * getStoreFactoryAdd({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'post', `v3/seller/seller/storeCompanyShow/add`);
      if (callback) callback(response);
    },
    * getStoreFactoryEdit({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'post', `v3/seller/seller/storeCompanyShow/edit`);
      if (callback) callback(response);
    },
    * getStoreFactoryDel({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'post', `v3/seller/seller/storeCompanyShow/delete`);
      if (callback) callback(response);
    },

    //关于我们简介内容
    * getAboutText({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'get', `v3/seller/seller/storeProfile/settingDetail`);
      if (callback) callback(response);
    },
    * getAboutTextEdit({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'post', `v3/seller/seller/storeProfile/updateSetting`);
      if (callback) callback(response);
    },



    //逐级获取商户绑定的商品分类,如果有下级，children返回空数组，否则返回null
    * getVendorGoodsCategoryById({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'get', `v3/goods/seller/goodsCategory/getStoreCateList`);
      if (callback) callback(response);
    },

    //逐级获取商户绑定的商品分类,如果有下级，children返回空数组，否则返回null
    * getOldVendorGoodsCategoryById({ payload, callback }, { call }) {
      const response = yield call(sldCommonService, payload, 'get', `v3/goods/seller/goodsCategory/listByPId`);
      if (callback) callback(response);
    },
  },

  reducers: {
    saveNotice(state, action) {
      return {
        ...state,
        notice: action.payload,
      };
    },
  },
};
