1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import { createAction, NavigationActions } from '../../utils'
- import * as authService from '../../services/auth'
- export default {
- namespace: 'announce',
- state: {
- announceDatas: [],
- announceContent: [],
- bannerData: [],
- bannerTime: {},
- },
- reducers: {
- announce(state, { payload }) {
- return { ...state, ...payload }
- },
- bannerReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- },
- effects: {
- //公告
- *getAnnounce(action, { call, put }) {
- try {
- const announcedata = yield call(authService.getannounce)
- if (announcedata && announcedata.data) {
- announcedata.data.unshift({
- noticeType: '',
- noticeTypeName: '全部',
- })
- yield put(
- createAction('announce')({
- announceDatas: announcedata.data,
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //公告内容
- *getAnnounceContent(action, { call, put }) {
- try {
- const announceContent = yield call(() =>
- authService.getannounceContent(action.payload)
- )
- if (announceContent && announceContent.data) {
- yield put(
- createAction('announce')({
- announceContent: announceContent.data,
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //轮播
- *getBanner(action, { call, put }) {
- try {
- const bannerData = yield call(() =>
- authService.getBannerImg({ search_EQ_isEnable: 1 })
- )
- const bannerTime = yield call(authService.GetBannerTime)
- if (bannerData && bannerData.data && bannerTime && bannerTime.data) {
- yield put(
- createAction('bannerReducer')({
- bannerData: bannerData.data.content,
- bannerTime: bannerTime.data.content,
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- },
- // subscriptions: {
- // setup({ dispatch }) {
- // dispatch({ type: "getHotSale" });
- // }
- // }
- }
|