CategoryModels.js 952 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { createAction, NavigationActions } from '../../utils'
  2. import * as authService from '../../services/auth'
  3. export default {
  4. namespace: 'category',
  5. state: {
  6. categorydata: [],
  7. },
  8. reducers: {
  9. categoryReducer(state, { payload }) {
  10. return { ...state, ...payload }
  11. },
  12. },
  13. effects: {
  14. //商品分类
  15. *getCategory(action, { call, put }) {
  16. try {
  17. const getcategory = yield call(authService.getcategory)
  18. if (getcategory.data) {
  19. yield put(
  20. createAction('categoryReducer')({
  21. categorydata: getcategory.data,
  22. })
  23. )
  24. }
  25. } catch (error) {
  26. console.log(
  27. error,
  28. '-----error的完整信息' + '\n' + error.response.data.message,
  29. '-----相关错误信息'
  30. )
  31. }
  32. },
  33. },
  34. // subscriptions: {
  35. // setup({ dispatch }) {
  36. // dispatch({ type: "getCategory" });
  37. // }
  38. // }
  39. }