import { createAction, NavigationActions } from '../../utils' import * as authService from '../../services/auth' export default { namespace: 'orderdetail', state: { detailData: [], causesData: [], }, reducers: { detailReducer(state, { payload }) { return { ...state, ...payload } }, causesReducer(state, { payload }) { return { ...state, ...payload } }, }, effects: { *getOrderDetail(action, { call, put }) { try { const detaildata = yield call(() => authService.getOrderDetail(action.payload) ) if (detaildata && detaildata.data) { yield put( createAction('detailReducer')({ detailData: detaildata.data }) ) yield put(NavigationActions.navigate({ routeName: 'OrderDetail' })) } // } catch (error) { console.log( error, '-----error的完整信息' + '\n' + error.response.data.message, '-----相关错误信息' ) } }, *getCauses(action, { call, put }) { try { const causesData = yield call(() => authService.getCauses(action.payload) ) // console.log(causesData, 6666); if (causesData && causesData.data && causesData.data.content) { yield put( createAction('causesReducer')({ causesData: causesData.data.content, }) ) } } catch (error) { console.log( error, '-----error的完整信息' + '\n' + error.response.data.message, '-----相关错误信息' ) } }, }, // subscriptions: { // setup({ dispatch }) { // dispatch({ type: "getOrderDetail" }); // } // } }