trade.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { message } from 'antd';
  2. import { routerRedux } from 'dva/router';
  3. import {
  4. queryTerminalBuyMsg,
  5. queryOrderList,
  6. queryOrderItem,
  7. querySubOrderItem,
  8. createOrderItem,
  9. invalidOrderItem,
  10. payOrderItem,
  11. sendOrderItem,
  12. receiveOrderItem,
  13. } from '../services/trade';
  14. export default {
  15. namespace: 'trade',
  16. state: {
  17. list: [],
  18. pageNo: 1,
  19. pageSize: 15,
  20. totalSize: 0,
  21. currentItem: {},
  22. },
  23. effects: {
  24. *fetchTerminalBuyMsg({ payload }, { call, put }) {
  25. const response = yield call(queryTerminalBuyMsg, payload);
  26. if (response.success) {
  27. message.success('加载终端购物车列表成功');
  28. yield put({
  29. type: 'querySuccess',
  30. payload: {
  31. list: response.data || [],
  32. },
  33. });
  34. }
  35. },
  36. *createOrderItem({ payload }, { call }) {
  37. const response = yield call(createOrderItem, payload);
  38. if (response.success) {
  39. message.success('创建订单成功');
  40. }
  41. },
  42. },
  43. reducers: {
  44. querySuccess(state, action) {
  45. return {
  46. ...state,
  47. ...action.payload,
  48. };
  49. },
  50. fixList(state, action) {
  51. return {
  52. ...state,
  53. ...action.payload,
  54. };
  55. },
  56. fixCurrentItem(state, action) {
  57. const { currentItem } = state;
  58. return {
  59. ...state,
  60. currentItem: {
  61. ...currentItem,
  62. ...action.payload,
  63. },
  64. };
  65. },
  66. cleanState(state) {
  67. return {
  68. ...state,
  69. currentItem: {},
  70. list: [],
  71. };
  72. },
  73. },
  74. };