AnnounceModel.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { createAction, NavigationActions } from '../../utils'
  2. import * as authService from '../../services/auth'
  3. export default {
  4. namespace: 'announce',
  5. state: {
  6. announceDatas: [],
  7. announceContent: [],
  8. bannerData: [],
  9. bannerTime: {},
  10. },
  11. reducers: {
  12. announce(state, { payload }) {
  13. return { ...state, ...payload }
  14. },
  15. bannerReducer(state, { payload }) {
  16. return { ...state, ...payload }
  17. },
  18. },
  19. effects: {
  20. //公告
  21. *getAnnounce(action, { call, put }) {
  22. try {
  23. const announcedata = yield call(authService.getannounce)
  24. if (announcedata && announcedata.data) {
  25. announcedata.data.unshift({
  26. noticeType: '',
  27. noticeTypeName: '全部',
  28. })
  29. yield put(
  30. createAction('announce')({
  31. announceDatas: announcedata.data,
  32. })
  33. )
  34. }
  35. } catch (error) {
  36. console.log(
  37. error,
  38. '-----error的完整信息' + '\n' + error.response.data.message,
  39. '-----相关错误信息'
  40. )
  41. }
  42. },
  43. //公告内容
  44. *getAnnounceContent(action, { call, put }) {
  45. try {
  46. const announceContent = yield call(() =>
  47. authService.getannounceContent(action.payload)
  48. )
  49. if (announceContent && announceContent.data) {
  50. yield put(
  51. createAction('announce')({
  52. announceContent: announceContent.data,
  53. })
  54. )
  55. }
  56. } catch (error) {
  57. console.log(
  58. error,
  59. '-----error的完整信息' + '\n' + error.response.data.message,
  60. '-----相关错误信息'
  61. )
  62. }
  63. },
  64. //轮播
  65. *getBanner(action, { call, put }) {
  66. try {
  67. const bannerData = yield call(() =>
  68. authService.getBannerImg({ search_EQ_isEnable: 1 })
  69. )
  70. const bannerTime = yield call(authService.GetBannerTime)
  71. if (bannerData && bannerData.data && bannerTime && bannerTime.data) {
  72. yield put(
  73. createAction('bannerReducer')({
  74. bannerData: bannerData.data.content,
  75. bannerTime: bannerTime.data.content,
  76. })
  77. )
  78. }
  79. } catch (error) {
  80. console.log(
  81. error,
  82. '-----error的完整信息' + '\n' + error.response.data.message,
  83. '-----相关错误信息'
  84. )
  85. }
  86. },
  87. },
  88. // subscriptions: {
  89. // setup({ dispatch }) {
  90. // dispatch({ type: "getHotSale" });
  91. // }
  92. // }
  93. }