userActions.js
3.04 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
'use strict'
import {Actions} from 'react-native-router-flux';
import UserService from '../../services/UserService';
const {
USER_POSTS_REQUEST,
USER_POSTS_SUCCESS,
USER_POSTS_FAILURE,
USER_LIKE_REQUEST,
USER_LIKE_SUCCESS,
USER_LIKE_FAILURE,
USER_REPLY_REQUEST,
USER_REPLY_SUCCESS,
USER_REPLY_FAILURE,
USER_GO_TO_SETTING_STATS,
} = require('../../constants/actionTypes').default;
export function postRequest() {
return {
type: USER_POSTS_REQUEST
};
}
export function postSuccess(json) {
return {
type: USER_POSTS_SUCCESS,
payload: json
};
}
export function postFailure(error) {
return {
type: USER_POSTS_FAILURE,
payload: error
};
}
export function likeRequest() {
return {
type: USER_LIKE_REQUEST
};
}
export function likeSuccess(json) {
return {
type: USER_LIKE_SUCCESS,
payload: json
};
}
export function likeFailure(error) {
return {
type: USER_LIKE_FAILURE,
payload: error
};
}
export function replyRequest() {
return {
type: USER_REPLY_REQUEST
};
}
export function replySuccess(json) {
return {
type: USER_REPLY_SUCCESS,
payload: json
};
}
export function replyFailure(error) {
return {
type: USER_REPLY_FAILURE,
payload: error
};
}
export function userInfo() {
// return dispatch => {
// dispatch(postRequest());
// return new UserService().posts()
// .then(json => {
// dispatch(postSuccess(json))
// })
// .catch(error => {
// dispatch(postFailure(error));
// });
// };
}
// 获取【我的帖子】数据
export function posts() {
return dispatch => {
// dispatch(postRequest());
// return new UserService().posts()
// .then(json => {
dispatch(postSuccess(postsTestData));
// })
// .catch(error => {
// dispatch(postFailure(error));
// });
};
}
// 获取【我赞过的】数据
export function like() {
return dispatch => {
dispatch(likeRequest());
return new UserService().like()
.then(json => {
dispatch(likeSuccess(json))
})
.catch(error => {
dispatch(likeFailure(error));
});
};
}
// 获取【我的回复】数据
export function reply() {
return dispatch => {
dispatch(replyRequest());
return new UserService().reply()
.then(json => {
dispatch(replySuccess(json))
})
.catch(error => {
dispatch(replyFailure(error));
});
};
}
// 页面跳转
export function goToStatsPage(type) {
switch (type) {
case USER_GO_TO_SETTING_STATS:
{
Actions.SettingStats();
return {
type: USER_GO_TO_SETTING_STATS,
}
}
break;
default:
}
}