Showing
9 changed files
with
170 additions
and
54 deletions
@@ -16,15 +16,12 @@ export default class ContentFansListCell extends Component { | @@ -16,15 +16,12 @@ export default class ContentFansListCell extends Component { | ||
16 | render() { | 16 | render() { |
17 | let {data} = this.props; | 17 | let {data} = this.props; |
18 | let resource = data.isMutualAttention ? require('../../images/content_attentioned.png') : require('../../images/content_fan.png'); | 18 | let resource = data.isMutualAttention ? require('../../images/content_attentioned.png') : require('../../images/content_fan.png'); |
19 | + let status = data.isMutualAttention ? 1 : 0; | ||
19 | 20 | ||
20 | function onHeadIconPress() { | 21 | function onHeadIconPress() { |
21 | 22 | ||
22 | } | 23 | } |
23 | 24 | ||
24 | - function onFanButtonPress() { | ||
25 | - | ||
26 | - } | ||
27 | - | ||
28 | return ( | 25 | return ( |
29 | <View> | 26 | <View> |
30 | <View style={styles.headerBackground}> | 27 | <View style={styles.headerBackground}> |
@@ -39,7 +36,7 @@ export default class ContentFansListCell extends Component { | @@ -39,7 +36,7 @@ export default class ContentFansListCell extends Component { | ||
39 | </Text> | 36 | </Text> |
40 | <Text style={styles.startTimeText}>{data.createTime}</Text> | 37 | <Text style={styles.startTimeText}>{data.createTime}</Text> |
41 | </View> | 38 | </View> |
42 | - <TouchableOpacity activeOpacity={1} style={styles.fanContainer} onPress={()=> {onFanButtonPress()}}> | 39 | + <TouchableOpacity activeOpacity={1} style={styles.fanContainer} onPress={()=> {this.props.updateAttentionAction && this.props.updateAttentionAction(status)}}> |
43 | <Image style={styles.fanImage} source={resource}/> | 40 | <Image style={styles.fanImage} source={resource}/> |
44 | </TouchableOpacity> | 41 | </TouchableOpacity> |
45 | </View> | 42 | </View> |
@@ -39,6 +39,7 @@ export default class ContentListView extends Component { | @@ -39,6 +39,7 @@ export default class ContentListView extends Component { | ||
39 | <ContentFansListCell | 39 | <ContentFansListCell |
40 | key={'row'+ rowID} | 40 | key={'row'+ rowID} |
41 | data={rowData} | 41 | data={rowData} |
42 | + updateAttentionAction={this.props.updateAttentionAction} | ||
42 | /> | 43 | /> |
43 | } | 44 | } |
44 | 45 |
@@ -40,9 +40,15 @@ export default keyMirror({ | @@ -40,9 +40,15 @@ export default keyMirror({ | ||
40 | FETCH_CONTENT_LIST_SUCCESS: null, | 40 | FETCH_CONTENT_LIST_SUCCESS: null, |
41 | FETCH_CONTENT_LIST_FAILURE: null, | 41 | FETCH_CONTENT_LIST_FAILURE: null, |
42 | 42 | ||
43 | - ADD_CONTENT_INBOX_REQUEST: null, | ||
44 | - ADD_CONTENT_INBOX_SUCCESS: null, | ||
45 | - ADD_CONTENT_INBOX_FAILURE: null, | 43 | + //回复评论 |
44 | + ADD_ARTICLE_COMMENT_REQUEST: null, | ||
45 | + ADD_ARTICLE_COMMENT_SUCCESS: null, | ||
46 | + ADD_ARTICLE_COMMENT_FAILURE: null, | ||
47 | + | ||
48 | + //关注用户 | ||
49 | + UPDATE_ATTENTION_REQUEST: null, | ||
50 | + UPDATE_ATTENTION_SUCCESS: null, | ||
51 | + UPDATE_ATTENTION_FAILURE: null, | ||
46 | 52 | ||
47 | MESSAGE_CLEAR_OTHER_LIST: null, | 53 | MESSAGE_CLEAR_OTHER_LIST: null, |
48 | MESSAGE_CLEAR_COMMENT_LIST: null, | 54 | MESSAGE_CLEAR_COMMENT_LIST: null, |
@@ -44,12 +44,16 @@ class ContentListContainer extends Component { | @@ -44,12 +44,16 @@ class ContentListContainer extends Component { | ||
44 | constructor(props) { | 44 | constructor(props) { |
45 | super(props); | 45 | super(props); |
46 | 46 | ||
47 | + this.updateAttentionAction = this.updateAttentionAction.bind(this); | ||
48 | + | ||
47 | } | 49 | } |
48 | 50 | ||
49 | - componentDidMount() { | 51 | + updateAttentionAction(status) { |
52 | + this.props.actions.updateAttentionAction(status); | ||
53 | + } | ||
50 | 54 | ||
55 | + componentDidMount() { | ||
51 | this.props.actions.getContentList(true, this.props.contentListId) | 56 | this.props.actions.getContentList(true, this.props.contentListId) |
52 | - | ||
53 | } | 57 | } |
54 | 58 | ||
55 | componentWillUnmount() { | 59 | componentWillUnmount() { |
@@ -68,6 +72,7 @@ class ContentListContainer extends Component { | @@ -68,6 +72,7 @@ class ContentListContainer extends Component { | ||
68 | contentListId={this.props.contentListId} | 72 | contentListId={this.props.contentListId} |
69 | onRefresh={this._onRefresh} | 73 | onRefresh={this._onRefresh} |
70 | onEndReached={this._onEndReached} | 74 | onEndReached={this._onEndReached} |
75 | + updateAttentionAction={this.updateAttentionAction} | ||
71 | /> | 76 | /> |
72 | 77 | ||
73 | </View> | 78 | </View> |
@@ -46,10 +46,10 @@ class ContentMessageContainer extends Component { | @@ -46,10 +46,10 @@ class ContentMessageContainer extends Component { | ||
46 | super(props); | 46 | super(props); |
47 | 47 | ||
48 | this.state = { | 48 | this.state = { |
49 | - businessType: 0, | ||
50 | - commentId: 0, | 49 | + dataSource : {}, |
51 | }; | 50 | }; |
52 | - this._onRefresh = this._onRefresh.bind(this) | 51 | + |
52 | + this._onRefresh = this._onRefresh.bind(this); | ||
53 | this._onEndReached = this._onEndReached.bind(this); | 53 | this._onEndReached = this._onEndReached.bind(this); |
54 | this._storeReplySource = this._storeReplySource.bind(this); | 54 | this._storeReplySource = this._storeReplySource.bind(this); |
55 | } | 55 | } |
@@ -79,16 +79,19 @@ class ContentMessageContainer extends Component { | @@ -79,16 +79,19 @@ class ContentMessageContainer extends Component { | ||
79 | } | 79 | } |
80 | 80 | ||
81 | _addInBoxAction(addValue) { | 81 | _addInBoxAction(addValue) { |
82 | - // this.props.actions.addContentInBox(this.state.businessType, this.state.commentId, addValue) | 82 | + |
83 | + let addType = this.state.dataSource.businessType === 1003 ? 1 : 0; | ||
84 | + let destId = addType === 0 ? this.state.dataSource.articleId : 0; | ||
85 | + let commentId = this.state.dataSource.commentId; | ||
86 | + let columnType = addType === 0? 1001 : 0; | ||
87 | + | ||
88 | + this.props.actions.addArticleCommentAction(addValue, destId, commentId, addType, columnType); | ||
83 | } | 89 | } |
84 | 90 | ||
85 | _storeReplySource(dataSource) { | 91 | _storeReplySource(dataSource) { |
86 | - console.log(dataSource.businessType); | ||
87 | - this.setState = ({ | ||
88 | - businessType: dataSource.businessType, | ||
89 | - commentId: dataSource.commentId, | 92 | + this.setState({ |
93 | + dataSource: dataSource, | ||
90 | }); | 94 | }); |
91 | - console.log(this.state.businessType); | ||
92 | } | 95 | } |
93 | 96 | ||
94 | render() { | 97 | render() { |
@@ -19,10 +19,15 @@ const { | @@ -19,10 +19,15 @@ const { | ||
19 | FETCH_CONTENT_LIST_SUCCESS, | 19 | FETCH_CONTENT_LIST_SUCCESS, |
20 | FETCH_CONTENT_LIST_FAILURE, | 20 | FETCH_CONTENT_LIST_FAILURE, |
21 | 21 | ||
22 | - //新增回复或关注 | ||
23 | - ADD_CONTENT_INBOX_REQUEST, | ||
24 | - ADD_CONTENT_INBOX_SUCCESS, | ||
25 | - ADD_CONTENT_INBOX_FAILURE, | 22 | + //回复评论 |
23 | + ADD_ARTICLE_COMMENT_REQUEST, | ||
24 | + ADD_ARTICLE_COMMENT_SUCCESS, | ||
25 | + ADD_ARTICLE_COMMENT_FAILURE, | ||
26 | + | ||
27 | + //关注用户 | ||
28 | + UPDATE_ATTENTION_REQUEST, | ||
29 | + UPDATE_ATTENTION_SUCCESS, | ||
30 | + UPDATE_ATTENTION_FAILURE, | ||
26 | 31 | ||
27 | //清除消息内容 | 32 | //清除消息内容 |
28 | MESSAGE_CLEAR_OTHER_LIST, | 33 | MESSAGE_CLEAR_OTHER_LIST, |
@@ -95,22 +100,42 @@ export function getContentListFailure(error, isLatest) { | @@ -95,22 +100,42 @@ export function getContentListFailure(error, isLatest) { | ||
95 | } | 100 | } |
96 | } | 101 | } |
97 | 102 | ||
98 | -export function addContentInBoxRequest() { | 103 | +export function addArticleCommentRequest() { |
104 | + return { | ||
105 | + type: ADD_ARTICLE_COMMENT_REQUEST, | ||
106 | + } | ||
107 | +} | ||
108 | + | ||
109 | +export function addArticleCommentSuccess(json) { | ||
110 | + return { | ||
111 | + type: ADD_ARTICLE_COMMENT_SUCCESS, | ||
112 | + payload: json, | ||
113 | + } | ||
114 | +} | ||
115 | + | ||
116 | +export function addArticleCommentFailure(error) { | ||
99 | return { | 117 | return { |
100 | - type: ADD_CONTENT_INBOX_REQUEST, | 118 | + type: ADD_ARTICLE_COMMENT_FAILURE, |
119 | + payload: error, | ||
120 | + } | ||
121 | +} | ||
122 | + | ||
123 | +export function updateAttentionRequest() { | ||
124 | + return { | ||
125 | + type: UPDATE_ATTENTION_REQUEST, | ||
101 | } | 126 | } |
102 | } | 127 | } |
103 | 128 | ||
104 | -export function addContentInBoxSuccess(json) { | 129 | +export function updateAttentionSuccess(json) { |
105 | return { | 130 | return { |
106 | - type: ADD_CONTENT_INBOX_SUCCESS, | 131 | + type: UPDATE_ATTENTION_SUCCESS, |
107 | payload: json, | 132 | payload: json, |
108 | } | 133 | } |
109 | } | 134 | } |
110 | 135 | ||
111 | -export function addContentInBoxFailure(error) { | 136 | +export function updateAttentionFailure(error) { |
112 | return { | 137 | return { |
113 | - type: ADD_CONTENT_INBOX_FAILURE, | 138 | + type: UPDATE_ATTENTION_FAILURE, |
114 | payload: error, | 139 | payload: error, |
115 | } | 140 | } |
116 | } | 141 | } |
@@ -252,18 +277,18 @@ function parseContentList(json) { | @@ -252,18 +277,18 @@ function parseContentList(json) { | ||
252 | } | 277 | } |
253 | } | 278 | } |
254 | 279 | ||
255 | -//新增消息 | ||
256 | -export function addContentInBox(businessType, attachId, addValue) { | 280 | +//回复评论 |
281 | +export function addArticleCommentAction(content, destId, commentId, addType, columnType) { | ||
257 | return (dispatch, getState) => { | 282 | return (dispatch, getState) => { |
258 | let {app} = getState(); | 283 | let {app} = getState(); |
259 | let processor = (uid)=> { | 284 | let processor = (uid)=> { |
260 | - dispatch(addContentInBoxRequest()); | ||
261 | - return new ContentService().addMessageInBox(businessType, attachId, addValue, uid) | 285 | + dispatch(addArticleCommentRequest()); |
286 | + return new ContentService().addArticleComment(content, destId, uid, commentId, addType, columnType) | ||
262 | .then(json => { | 287 | .then(json => { |
263 | - dispatch(addContentInBoxSuccess(json)); | 288 | + dispatch(addArticleCommentSuccess(json)); |
264 | }) | 289 | }) |
265 | .catch(error => { | 290 | .catch(error => { |
266 | - dispatch(addContentInBoxFailure(error)); | 291 | + dispatch(addArticleCommentFailure(error)); |
267 | }); | 292 | }); |
268 | } | 293 | } |
269 | ReactNative.NativeModules.YH_CommonHelper.uid() | 294 | ReactNative.NativeModules.YH_CommonHelper.uid() |
@@ -282,6 +307,37 @@ export function addContentInBox(businessType, attachId, addValue) { | @@ -282,6 +307,37 @@ export function addContentInBox(businessType, attachId, addValue) { | ||
282 | }; | 307 | }; |
283 | } | 308 | } |
284 | 309 | ||
310 | +//关注用户 | ||
311 | +export function updateAttentionAction(attentionStatus) { | ||
312 | + return (dispatch, getState) => { | ||
313 | + let {app} = getState(); | ||
314 | + let processor = (uid)=> { | ||
315 | + dispatch(updateAttentionRequest()); | ||
316 | + return new ContentService().updateAttention(uid, attentionStatus) | ||
317 | + .then(json => { | ||
318 | + dispatch(updateAttentionSuccess(json)); | ||
319 | + }) | ||
320 | + .catch(error => { | ||
321 | + dispatch(updateAttentionFailure(error)); | ||
322 | + }); | ||
323 | + } | ||
324 | + ReactNative.NativeModules.YH_CommonHelper.uid() | ||
325 | + .then(uid => { | ||
326 | + processor(uid) | ||
327 | + }) | ||
328 | + .catch(error => { | ||
329 | + ReactNative.NativeModules.YH_CommonHelper.login() | ||
330 | + .then(uid => { | ||
331 | + processor(uid) | ||
332 | + }) | ||
333 | + .catch(error => { | ||
334 | + }); | ||
335 | + }); | ||
336 | + }; | ||
337 | +} | ||
338 | + | ||
339 | + | ||
340 | + | ||
285 | export function clearCommentMessageList() { | 341 | export function clearCommentMessageList() { |
286 | return (dispatch) => { | 342 | return (dispatch) => { |
287 | dispatch(clearCommentMessageListAction()); | 343 | dispatch(clearCommentMessageListAction()); |
@@ -16,7 +16,7 @@ let InitialState = Record({ | @@ -16,7 +16,7 @@ let InitialState = Record({ | ||
16 | error:null, | 16 | error:null, |
17 | })), | 17 | })), |
18 | 18 | ||
19 | - //查询消息 | 19 | + //main页面消息 |
20 | commentList: new (Record({ | 20 | commentList: new (Record({ |
21 | isFetching: false, | 21 | isFetching: false, |
22 | list: List(), | 22 | list: List(), |
@@ -27,6 +27,7 @@ let InitialState = Record({ | @@ -27,6 +27,7 @@ let InitialState = Record({ | ||
27 | shouldShowEmpty: false, | 27 | shouldShowEmpty: false, |
28 | pageCount: 0, | 28 | pageCount: 0, |
29 | })), | 29 | })), |
30 | + //列表页面 | ||
30 | contentList: new (Record({ | 31 | contentList: new (Record({ |
31 | isFetching: false, | 32 | isFetching: false, |
32 | list: List(), | 33 | list: List(), |
@@ -38,7 +39,11 @@ let InitialState = Record({ | @@ -38,7 +39,11 @@ let InitialState = Record({ | ||
38 | pageCount: 0, | 39 | pageCount: 0, |
39 | })), | 40 | })), |
40 | 41 | ||
41 | - addContent: new (Record({ | 42 | + addCommentContent: new (Record({ |
43 | + isFetching: false, | ||
44 | + error: null, | ||
45 | + })), | ||
46 | + updateAttentionContent: new (Record({ | ||
42 | isFetching: false, | 47 | isFetching: false, |
43 | error: null, | 48 | error: null, |
44 | })), | 49 | })), |
@@ -16,9 +16,15 @@ const { | @@ -16,9 +16,15 @@ const { | ||
16 | FETCH_CONTENT_LIST_SUCCESS, | 16 | FETCH_CONTENT_LIST_SUCCESS, |
17 | FETCH_CONTENT_LIST_FAILURE, | 17 | FETCH_CONTENT_LIST_FAILURE, |
18 | 18 | ||
19 | - ADD_CONTENT_INBOX_REQUEST, | ||
20 | - ADD_CONTENT_INBOX_SUCCESS, | ||
21 | - ADD_CONTENT_INBOX_FAILURE, | 19 | + //回复评论 |
20 | + ADD_ARTICLE_COMMENT_REQUEST, | ||
21 | + ADD_ARTICLE_COMMENT_SUCCESS, | ||
22 | + ADD_ARTICLE_COMMENT_FAILURE, | ||
23 | + | ||
24 | + //关注用户 | ||
25 | + UPDATE_ATTENTION_REQUEST, | ||
26 | + UPDATE_ATTENTION_SUCCESS, | ||
27 | + UPDATE_ATTENTION_FAILURE, | ||
22 | 28 | ||
23 | //清除消息内容 | 29 | //清除消息内容 |
24 | MESSAGE_CLEAR_OTHER_LIST, | 30 | MESSAGE_CLEAR_OTHER_LIST, |
@@ -97,17 +103,30 @@ export default function grassReducer(state=initialState, action) { | @@ -97,17 +103,30 @@ export default function grassReducer(state=initialState, action) { | ||
97 | .setIn([getContentListObject(action.isLatest), 'shouldShowEmpty'], true); | 103 | .setIn([getContentListObject(action.isLatest), 'shouldShowEmpty'], true); |
98 | } | 104 | } |
99 | 105 | ||
100 | - case ADD_CONTENT_INBOX_REQUEST: { | ||
101 | - return state.setIn(['addContent', 'isFetching'], true); | 106 | + case ADD_ARTICLE_COMMENT_REQUEST: { |
107 | + return state.setIn(['addCommentContent', 'isFetching'], true); | ||
108 | + } | ||
109 | + | ||
110 | + case ADD_ARTICLE_COMMENT_SUCCESS: { | ||
111 | + return state.setIn(['addCommentContent', 'isFetching'], false); | ||
112 | + } | ||
113 | + | ||
114 | + case ADD_ARTICLE_COMMENT_FAILURE: { | ||
115 | + return state.setIn(['addCommentContent', 'isFetching'], false) | ||
116 | + .setIn(['addCommentContent', 'error'], action.payload); | ||
117 | + } | ||
118 | + | ||
119 | + case UPDATE_ATTENTION_REQUEST: { | ||
120 | + return state.setIn(['updateAttentionContent', 'isFetching'], true); | ||
102 | } | 121 | } |
103 | 122 | ||
104 | - case ADD_CONTENT_INBOX_SUCCESS: { | ||
105 | - return state.setIn(['addContent', 'isFetching'], false); | 123 | + case UPDATE_ATTENTION_SUCCESS: { |
124 | + return state.setIn(['updateAttentionContent', 'isFetching'], false); | ||
106 | } | 125 | } |
107 | 126 | ||
108 | - case ADD_CONTENT_INBOX_FAILURE: { | ||
109 | - return state.setIn(['addContent', 'isFetching'], false) | ||
110 | - .setIn(['addContent', 'error'], action.payload); | 127 | + case UPDATE_ATTENTION_FAILURE: { |
128 | + return state.setIn(['updateAttentionContent', 'isFetching'], false) | ||
129 | + .setIn(['updateAttentionContent', 'error'], action.payload); | ||
111 | } | 130 | } |
112 | 131 | ||
113 | case MESSAGE_CLEAR_OTHER_LIST: { | 132 | case MESSAGE_CLEAR_OTHER_LIST: { |
@@ -48,16 +48,40 @@ export default class ContentService { | @@ -48,16 +48,40 @@ export default class ContentService { | ||
48 | }) | 48 | }) |
49 | } | 49 | } |
50 | 50 | ||
51 | - //新增消息,关注,回复等 | ||
52 | - async addMessageInBox(businessType, attachId, addValue, uid) { | 51 | + //评论(回复)接口 |
52 | + async addArticleComment(content, destId, uid, commentId, addType, columnType) { | ||
53 | return await this.api.get({ | 53 | return await this.api.get({ |
54 | url: '', | 54 | url: '', |
55 | body: { | 55 | body: { |
56 | - businessType, | ||
57 | - attachValue: attachId, | ||
58 | - params: addValue, | ||
59 | - optUid: uid, | ||
60 | - method: 'app.grass.addInBox', | 56 | + content, |
57 | + destId, | ||
58 | + commentId, | ||
59 | + addType, | ||
60 | + columnType, | ||
61 | + uid, | ||
62 | + method: 'app.grass.addArticleComment', | ||
63 | + } | ||
64 | + }) | ||
65 | + .then(json => { | ||
66 | + return json | ||
67 | + }) | ||
68 | + .catch(error => { | ||
69 | + throw(error) | ||
70 | + }) | ||
71 | + } | ||
72 | + | ||
73 | + //关注用户接口 | ||
74 | + async updateAttention(uid, attentionStatus) { | ||
75 | + return await this.api.get({ | ||
76 | + url: '', | ||
77 | + body: { | ||
78 | + uid: uid, | ||
79 | + topicId: 1, | ||
80 | + followUid: '1', | ||
81 | + status: attentionStatus, //状态(0:关注,1:取消) | ||
82 | + attentionType: 1, //类型(0:话题,1:用户) | ||
83 | + authorType: 1, | ||
84 | + method: 'app.grass.updateAttention', | ||
61 | } | 85 | } |
62 | }) | 86 | }) |
63 | .then(json => { | 87 | .then(json => { |
-
Please register or login to post a comment