OrderDetailModel.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { createAction, NavigationActions } from '../../utils'
  2. import * as authService from '../../services/auth'
  3. export default {
  4. namespace: 'orderdetail',
  5. state: {
  6. detailData: [],
  7. causesData: [],
  8. },
  9. reducers: {
  10. detailReducer(state, { payload }) {
  11. return { ...state, ...payload }
  12. },
  13. causesReducer(state, { payload }) {
  14. return { ...state, ...payload }
  15. },
  16. },
  17. effects: {
  18. *getOrderDetail(action, { call, put }) {
  19. try {
  20. const detaildata = yield call(() =>
  21. authService.getOrderDetail(action.payload)
  22. )
  23. if (detaildata && detaildata.data) {
  24. yield put(
  25. createAction('detailReducer')({ detailData: detaildata.data })
  26. )
  27. yield put(NavigationActions.navigate({ routeName: 'OrderDetail' }))
  28. }
  29. //
  30. } catch (error) {
  31. console.log(
  32. error,
  33. '-----error的完整信息' + '\n' + error.response.data.message,
  34. '-----相关错误信息'
  35. )
  36. }
  37. },
  38. *getCauses(action, { call, put }) {
  39. try {
  40. const causesData = yield call(() =>
  41. authService.getCauses(action.payload)
  42. )
  43. // console.log(causesData, 6666);
  44. if (causesData && causesData.data && causesData.data.content) {
  45. yield put(
  46. createAction('causesReducer')({
  47. causesData: causesData.data.content,
  48. })
  49. )
  50. }
  51. } catch (error) {
  52. console.log(
  53. error,
  54. '-----error的完整信息' + '\n' + error.response.data.message,
  55. '-----相关错误信息'
  56. )
  57. }
  58. },
  59. },
  60. // subscriptions: {
  61. // setup({ dispatch }) {
  62. // dispatch({ type: "getOrderDetail" });
  63. // }
  64. // }
  65. }