import Config from '../../../../utils/config'; import { getNoticeDetail,getTitleListBySameSort } from '../../services/index'; import { Toast } from 'antd-mobile'; import router from 'umi/router'; import { ListView } from 'antd-mobile' let announcementList = new ListView.DataSource({ rowHasChanged: (row1, row2) => row1 !== row2, }); export default { namespace:'announcementDetailModel', state: { announcementListArr:[], announcementList, isLoading:false, article:{} }, reducers: { updateState(state, { payload }) { return { ...state, ...payload, }; }, }, effects: { *getTitleListBySameSort({ payload }, { call, put,select }) { Toast.loading('加载中', 0, null, true); yield put({ type: 'updateState', payload: { isLoading:true, }, }); const { rc, msg, total,data } = yield call(getTitleListBySameSort, { ...payload }); let {announcementList,announcementListArr} = yield select(state => {return state.announcementDetailModel}); if (rc === Config.constant.codeSuccess) { Toast.hide(); const lg = total; let announcementListData = data; yield put({ type: 'updateState', payload: { announcementListArr:announcementListData, isLoading:false, refreshing:false, }, }); } else { Toast.fail(msg); } }, *getDetail({ payload }, { call, put,select }) { const { rc, msg, data } = yield call(getNoticeDetail, { ...payload }); if (rc === Config.constant.codeSuccess) { yield put({ type: 'updateState', payload: { article:data }, }); window.shareNotice = function (){ if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { window.webkit.messageHandlers.toShare.postMessage({title:data.title,content:data.title,url:window.location.href}); } else if (/(Android)/i.test(navigator.userAgent)) { window.js.toShare(data.title,'',data.content,window.location.href); } } } else { Toast.fail(msg); } }, }, subscriptions: { // setupHistory({ dispatch, history }) { // history.listen(location => {}); // }, }, };