123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- import { createAction, NavigationActions } from '../../utils'
- import * as authService from '../../services/auth'
- export default {
- namespace: 'optional',
- state: {
- optDataByGoodId: [],
- optDataByIds: [],
- optionalReturn: [],
- goodsBoom: [],
- // isRefreshing: false,
- // totalPages: 2,
- // // 0:隐藏footer 1:已加载完成,没有更多数据 2 :显示加载中
- // showFoot: 0
- colorGroups: [],
- colorData: [],
- goodsPriceByColor: [],
- goodsOpt: [],
- },
- reducers: {
- optionalByGoodIdReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- optionalByIdsReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- saveOptionalReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- getBoomReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- getColorGroupsReducer(state, {payload}) {
- return {...state, ...payload}
- },
- getColorByGroupsReducer(state, {payload}) {
- return {...state, ...payload}
- },
- getPriceByColorIdReducer(state, {payload}) {
- return {...state, ...payload}
- },
- saveGoodsOptReducer(state, {payload}) {
- return {...state, ...payload}
- }
- },
- effects: {
- // 获取选配信息 ByGoodId
- *optionalByGoodIdSaga(action, { call, put }) {
- let returnData = []
- try {
- const hotdata = yield call(() =>
- authService.getOptionalByGoodId(action.payload)
- )
- if (hotdata && hotdata.data) {
- returnData = hotdata.data
- }
- yield put(
- createAction('optionalByGoodIdReducer')({
- optDataByGoodId: returnData,
- })
- )
- } catch (error) {
- yield put(
- createAction('optionalByGoodIdReducer')({
- optDataByGoodId: returnData,
- })
- )
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- // 获取选配信息 ByIds
- *optionalByIds(action, { call, put }) {
- try {
- const hotdata = yield call(() =>
- authService.getOptionalByIds({ ids: action.payload })
- )
- if (hotdata && hotdata.data) {
- yield put(
- createAction('optionalByIdsReducer')({
- optDataByIds: hotdata.data,
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- // 保存选配
- *saveOptionalSaga(action, { call, put }) {
- try {
- const hotdata = yield call(() =>
- authService.saveOptional(action.payload)
- )
- if (hotdata && hotdata.data) {
- yield put(
- createAction('saveOptionalReducer')({
- optionalReturn: hotdata.data,
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- // 获取Boom信息
- *getBoomInfo(action, { call, put }) {
- try {
- const hotdata = yield call(() =>
- authService.getBoomInfo({ parentGoodId: action.payload })
- )
- if (hotdata && hotdata.data) {
- yield put(
- createAction('getBoomReducer')({
- goodsBoom: hotdata.data,
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //获取颜色选配分组
- *getColorGroups(action, { call, put}) {
- try {
- const hotdata = yield call(() =>
- authService.getColorGroups({})
- )
- if(hotdata && hotdata.data) {
- yield put(
- createAction('getColorGroupsReducer')({
- colorGroups : hotdata.data
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //根据颜色分组查询颜色
- *getColorByGroups(action, { call, put}) {
- try {
- const hotdata = yield call(() =>
- authService.getColorByGroups(action.payload)
- )
- console.log(hotdata);
- if(hotdata && hotdata.data) {
- yield put(
- createAction('getColorByGroupsReducer')({
- colorData : hotdata.data
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //根据色卡号查询商品调色价格
- *getPriceByColorId(action, { call, put}) {
- try {
- const hotdata = yield call(() =>
- authService.getPriceByColorId(action.payload)
- )
- if(hotdata && hotdata.data) {
- yield put(
- createAction('getPriceByColorIdReducer')({
- goodsPriceByColor : hotdata.data
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //保存调色商品配置
- *saveGoodsOpt(action, { call, put}) {
- try {
- const hotdata = yield call(() =>
- authService.saveGoodsOpt(action.payload)
- )
- if(hotdata && hotdata.data) {
- yield put(
- createAction('saveGoodsOptReducer')({
- goodsOpt : hotdata.data
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- }
- },
- }
|