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" }); // } // } }