notification.js
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import * as types from '../constants/ActionTypes';
import {getNotificationList,finish_Notification,getUnreadMessage,readAllMessages} from '../../utils/notificationUtil';
import { message } from 'antd';
import moment from 'moment';
import {SubmissionError,change} from 'redux-form';
//获取提醒列表
export function loadNotificationList(offset,limit){
return dispatch => {
return getNotificationList(offset,limit).then(data => {
const {items,total_count} = data
dispatch({
type : types.GET_NOTIFICATION_LIST,
notificationList: items,
notificationListCount:total_count
});
}).catch(err => {throw err});
}
}
//点击读取提醒
export function finishNotification(id,page=1){
return dispatch => {
return finish_Notification(id).then(data => {
let offset = (page-1)*30;
dispatch(loadNotificationList(offset,30));
dispatch(loadUnreadMessage());
}).catch(err => {throw err});
}
}
//获取首页五条未读消息列表
export function loadUnreadMessage(offset,limit){
return dispatch => {
return getUnreadMessage(offset,limit).then(data => {
const {items,total_count} = data
dispatch({
type : types.GET_UNREAD_LIST,
unreadList: items,
unreadListCount:total_count
});
}).catch(err => {throw err});
}
}
export function finishAllMessages(values){
return dispatch => {
return readAllMessages(values).then(data => {
dispatch(loadUnreadMessage());
}).catch(err => {throw err});
}
}