Part of post reply. reviewed by redding.
Showing
15 changed files
with
313 additions
and
61 deletions
js/community/components/likeList/likeList.js
0 → 100644
@@ -15,6 +15,7 @@ import { | @@ -15,6 +15,7 @@ import { | ||
15 | Easing, | 15 | Easing, |
16 | Platform, | 16 | Platform, |
17 | TextInput, | 17 | TextInput, |
18 | + Alert, | ||
18 | } from 'react-native' | 19 | } from 'react-native' |
19 | import UserBrief from '../home/UserBrief'; | 20 | import UserBrief from '../home/UserBrief'; |
20 | 21 | ||
@@ -60,6 +61,12 @@ export default class SubjectPost extends Component { | @@ -60,6 +61,12 @@ export default class SubjectPost extends Component { | ||
60 | this.blurAll = this.blurAll.bind(this); | 61 | this.blurAll = this.blurAll.bind(this); |
61 | this.renderToolContainer = this.renderToolContainer.bind(this); | 62 | this.renderToolContainer = this.renderToolContainer.bind(this); |
62 | this.someOneToReply = ''; | 63 | this.someOneToReply = ''; |
64 | + this.replyToSomeOneElse = this.replyToSomeOneElse.bind(this); | ||
65 | + | ||
66 | + this.commentId = ''; | ||
67 | + this.cidTo = ''; | ||
68 | + this.replyContent=''; | ||
69 | + this.commitComment = this.commitComment.bind(this); | ||
63 | } | 70 | } |
64 | 71 | ||
65 | componentDidMount(){ | 72 | componentDidMount(){ |
@@ -163,6 +170,8 @@ export default class SubjectPost extends Component { | @@ -163,6 +170,8 @@ export default class SubjectPost extends Component { | ||
163 | style={styles.lzContainer} | 170 | style={styles.lzContainer} |
164 | onPress={ | 171 | onPress={ |
165 | ()=>{ | 172 | ()=>{ |
173 | + this.cidTo = this.props.authorUid; | ||
174 | + this.commentId = ''; | ||
166 | this.setState({replyState: this.currentReplyState}) | 175 | this.setState({replyState: this.currentReplyState}) |
167 | } | 176 | } |
168 | } | 177 | } |
@@ -196,8 +205,13 @@ export default class SubjectPost extends Component { | @@ -196,8 +205,13 @@ export default class SubjectPost extends Component { | ||
196 | autoCapitalize={'none'} | 205 | autoCapitalize={'none'} |
197 | autoCorrect={false} | 206 | autoCorrect={false} |
198 | autoFocus={true} | 207 | autoFocus={true} |
208 | + onChangeText={ | ||
209 | + (text)=>{ | ||
210 | + this.replyContent = text; | ||
211 | + } | ||
212 | + } | ||
199 | /> | 213 | /> |
200 | - <Text style={styles.submitText}>发送</Text> | 214 | + <Text style={styles.submitText} onPress={this.commitComment}>发送</Text> |
201 | </View> | 215 | </View> |
202 | </View> | 216 | </View> |
203 | ); | 217 | ); |
@@ -206,19 +220,30 @@ export default class SubjectPost extends Component { | @@ -206,19 +220,30 @@ export default class SubjectPost extends Component { | ||
206 | case ReplyState.replySomeone: { | 220 | case ReplyState.replySomeone: { |
207 | return ( | 221 | return ( |
208 | <View style={styles.toolContainer}> | 222 | <View style={styles.toolContainer}> |
209 | - <TouchableOpacity style={styles.imgIcon} onPress={this.showImagePannel}> | ||
210 | - <Image source={require('../../images/pic1.png')}/> | 223 | + <Image style={styles.imgIcon} source={iconSouce}/> |
224 | + <TouchableOpacity style={styles.imgButton} onPress={this.showImagePannel}> | ||
211 | </TouchableOpacity> | 225 | </TouchableOpacity> |
226 | + | ||
212 | <TouchableOpacity style={styles.keyboardIcon} onPress={this.blurAll}> | 227 | <TouchableOpacity style={styles.keyboardIcon} onPress={this.blurAll}> |
213 | - <Image style={styles.keyboardIcon} source={require('../../images/jianpan1.png')} /> | 228 | + <Image source={require('../../images/jianpan1.png')} /> |
214 | </TouchableOpacity> | 229 | </TouchableOpacity> |
215 | - <View style={styles.rightContainer}> | ||
216 | - <Text | ||
217 | - style={styles.boardText} | ||
218 | - onPress={this.showBoardPannel} | ||
219 | - > | ||
220 | - {this.props.selectedBoard} | ||
221 | - </Text> | 230 | + <View style={[styles.rightContainer]}> |
231 | + <TextInput | ||
232 | + ref='textInput' | ||
233 | + style={styles.replyTextInput} | ||
234 | + placeholderTextColor='#b0b0b0' | ||
235 | + placeholder={'回复'+this.someOneToReply+':'} | ||
236 | + multiline={true} | ||
237 | + autoCapitalize={'none'} | ||
238 | + autoCorrect={false} | ||
239 | + autoFocus={true} | ||
240 | + onChangeText={ | ||
241 | + (text)=>{ | ||
242 | + this.replyContent = text; | ||
243 | + } | ||
244 | + } | ||
245 | + /> | ||
246 | + <Text style={styles.submitText} onPress={this.commitComment}>发送</Text> | ||
222 | </View> | 247 | </View> |
223 | </View> | 248 | </View> |
224 | ); | 249 | ); |
@@ -229,6 +254,22 @@ export default class SubjectPost extends Component { | @@ -229,6 +254,22 @@ export default class SubjectPost extends Component { | ||
229 | } | 254 | } |
230 | } | 255 | } |
231 | 256 | ||
257 | + commitComment() { | ||
258 | + if (this.replyContent.length == 0) { | ||
259 | + Alert.alert('抱歉','请先输入内容'); | ||
260 | + return; | ||
261 | + } | ||
262 | + let params = { | ||
263 | + postId: this.props.postId, | ||
264 | + commentId: this.commentId, | ||
265 | + cidFrom: this.props.cidFrom, | ||
266 | + cidTo: this.cidTo, | ||
267 | + authorUid: this.props.authorUid, | ||
268 | + content: this.replyContent, | ||
269 | + } | ||
270 | + this.props.commentWithParams(params); | ||
271 | + this.blurAll(); | ||
272 | + } | ||
232 | renderRow(rowData, sectionId) { | 273 | renderRow(rowData, sectionId) { |
233 | switch (sectionId) { | 274 | switch (sectionId) { |
234 | case 'header': | 275 | case 'header': |
@@ -279,7 +320,7 @@ export default class SubjectPost extends Component { | @@ -279,7 +320,7 @@ export default class SubjectPost extends Component { | ||
279 | style={styles.commentContainer} | 320 | style={styles.commentContainer} |
280 | onPress={ | 321 | onPress={ |
281 | ()=> { | 322 | ()=> { |
282 | - this.replySomeone(rowData.nickName); | 323 | + this.replyToSomeOneElse(rowData.nickName); |
283 | } | 324 | } |
284 | } | 325 | } |
285 | > | 326 | > |
@@ -290,6 +331,8 @@ export default class SubjectPost extends Component { | @@ -290,6 +331,8 @@ export default class SubjectPost extends Component { | ||
290 | timeago={rowData.timeago} | 331 | timeago={rowData.timeago} |
291 | isOwner={rowData.LZ} | 332 | isOwner={rowData.LZ} |
292 | onPressAvatar={() => { | 333 | onPressAvatar={() => { |
334 | + this.cidTo = rowData.cidTo; | ||
335 | + this.commentId = rowData.commentId; | ||
293 | this.props.onPressAvatar && this.props.onPressAvatar(); | 336 | this.props.onPressAvatar && this.props.onPressAvatar(); |
294 | }} | 337 | }} |
295 | /> | 338 | /> |
@@ -304,8 +347,10 @@ export default class SubjectPost extends Component { | @@ -304,8 +347,10 @@ export default class SubjectPost extends Component { | ||
304 | } | 347 | } |
305 | } | 348 | } |
306 | 349 | ||
307 | - replyToSomeOne(someOne) { | ||
308 | - | 350 | + replyToSomeOneElse(someOne) { |
351 | + this.someOneToReply = someOne; | ||
352 | + this.currentReplyState = ReplyState.replySomeone; | ||
353 | + this.setState({replyState: this.currentReplyState}); | ||
309 | } | 354 | } |
310 | 355 | ||
311 | renderLikeAvatar(avatars) { | 356 | renderLikeAvatar(avatars) { |
@@ -328,6 +373,7 @@ const styles = StyleSheet.create({ | @@ -328,6 +373,7 @@ const styles = StyleSheet.create({ | ||
328 | container: { | 373 | container: { |
329 | top: 0, | 374 | top: 0, |
330 | flex: 1, | 375 | flex: 1, |
376 | + backgroundColor: 'white', | ||
331 | }, | 377 | }, |
332 | likePannel: { | 378 | likePannel: { |
333 | backgroundColor: 'white', | 379 | backgroundColor: 'white', |
@@ -132,4 +132,9 @@ export default keyMirror({ | @@ -132,4 +132,9 @@ export default keyMirror({ | ||
132 | LIKE_MESSAGE_REQUEST: null, | 132 | LIKE_MESSAGE_REQUEST: null, |
133 | LIKE_MESSAGE_SUCCESS: null, | 133 | LIKE_MESSAGE_SUCCESS: null, |
134 | LIKE_MESSAGE_FAILURE: null, | 134 | LIKE_MESSAGE_FAILURE: null, |
135 | + | ||
136 | + SUBJECT_REPLY_REQUEST: null, | ||
137 | + SUBJECT_REPLY_SUCCESS: null, | ||
138 | + SUBJECT_REPLY_FAILURE: null, | ||
139 | + SUBJECT_REPLY_UPDATE: null, | ||
135 | }); | 140 | }); |
js/community/containers/LikeListContainer.js
0 → 100644
@@ -58,6 +58,7 @@ class SubjectPostContainer extends Component { | @@ -58,6 +58,7 @@ class SubjectPostContainer extends Component { | ||
58 | super(props); | 58 | super(props); |
59 | this.onEndReached = this.onEndReached.bind(this); | 59 | this.onEndReached = this.onEndReached.bind(this); |
60 | this.assetsSelected = this.assetsSelected.bind(this); | 60 | this.assetsSelected = this.assetsSelected.bind(this); |
61 | + this.commentWithParams = this.commentWithParams.bind(this); | ||
61 | } | 62 | } |
62 | 63 | ||
63 | componentDidMount() { | 64 | componentDidMount() { |
@@ -87,6 +88,10 @@ class SubjectPostContainer extends Component { | @@ -87,6 +88,10 @@ class SubjectPostContainer extends Component { | ||
87 | this.props.actions.assetsSelected(assets); | 88 | this.props.actions.assetsSelected(assets); |
88 | } | 89 | } |
89 | 90 | ||
91 | + commentWithParams(params) { | ||
92 | + this.props.actions.commentWithParams(params); | ||
93 | + } | ||
94 | + | ||
90 | render() { | 95 | render() { |
91 | let {headIcon,nickName} = this.props.subject.authorInfo; | 96 | let {headIcon,nickName} = this.props.subject.authorInfo; |
92 | let timeagoStr = timeago().format(this.props.subject.createTime, 'zh_CN'); | 97 | let timeagoStr = timeago().format(this.props.subject.createTime, 'zh_CN'); |
@@ -105,26 +110,26 @@ class SubjectPostContainer extends Component { | @@ -105,26 +110,26 @@ class SubjectPostContainer extends Component { | ||
105 | 110 | ||
106 | let dataBlob = { | 111 | let dataBlob = { |
107 | header : [header], | 112 | header : [header], |
108 | - // 'title': [this.props.subject.postsTitle], | ||
109 | - title: ['港南都爱啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦'], | ||
110 | - // content: [this.props.subject.blocks.toJS()], | ||
111 | - content: [[ | ||
112 | - { | ||
113 | - "contentData": "前几天这条关于adidas Originals NMD入手攻略的资讯发布后,评论区的童鞋们都“炸”啦,各种关于如何排队如何购买的问题一股脑地涌来。为了让大家能顺利买到NMD,今天小编就扮演一下临时客服,帮大家解决几个困惑。", | ||
114 | - "order": 1, | ||
115 | - "templateKey": "text" | ||
116 | - }, | ||
117 | - { | ||
118 | - "contentData": "http://img11.static.yhbimg.com/yhb-img01/2016/03/11/07/017c954c712e3e732f565d56d193c761af.jpg?imageView/2/w/640/h/640", | ||
119 | - "order": 2, | ||
120 | - "templateKey": "image" | ||
121 | - }, | ||
122 | - { | ||
123 | - "contentData": "http://img11.static.yhbimg.com/yhb-img01/2016/03/11/07/012868bed62e639554e5fecb09b6d44cfe.jpg?imageView/2/w/640/h/640", | ||
124 | - "order": 3, | ||
125 | - "templateKey": "image" | ||
126 | - } | ||
127 | - ],], | 113 | + 'title': [this.props.subject.postsTitle], |
114 | + // title: ['港南都爱啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦'], | ||
115 | + content: [this.props.subject.blocks.toJS()], | ||
116 | + // content: [[ | ||
117 | + // { | ||
118 | + // "contentData": "前几天这条关于adidas Originals NMD入手攻略的资讯发布后,评论区的童鞋们都“炸”啦,各种关于如何排队如何购买的问题一股脑地涌来。为了让大家能顺利买到NMD,今天小编就扮演一下临时客服,帮大家解决几个困惑。", | ||
119 | + // "order": 1, | ||
120 | + // "templateKey": "text" | ||
121 | + // }, | ||
122 | + // { | ||
123 | + // "contentData": "http://img11.static.yhbimg.com/yhb-img01/2016/03/11/07/017c954c712e3e732f565d56d193c761af.jpg?imageView/2/w/640/h/640", | ||
124 | + // "order": 2, | ||
125 | + // "templateKey": "image" | ||
126 | + // }, | ||
127 | + // { | ||
128 | + // "contentData": "http://img11.static.yhbimg.com/yhb-img01/2016/03/11/07/012868bed62e639554e5fecb09b6d44cfe.jpg?imageView/2/w/640/h/640", | ||
129 | + // "order": 3, | ||
130 | + // "templateKey": "image" | ||
131 | + // } | ||
132 | + // ],], | ||
128 | 133 | ||
129 | like: [likeData], | 134 | like: [likeData], |
130 | comments: this.props.subject.commentList.toJS(), | 135 | comments: this.props.subject.commentList.toJS(), |
@@ -139,6 +144,10 @@ class SubjectPostContainer extends Component { | @@ -139,6 +144,10 @@ class SubjectPostContainer extends Component { | ||
139 | assetsSelected={this.assetsSelected} | 144 | assetsSelected={this.assetsSelected} |
140 | assets={this.props.subject.assets.toJS()} | 145 | assets={this.props.subject.assets.toJS()} |
141 | commentCount={this.props.subject.commentCount} | 146 | commentCount={this.props.subject.commentCount} |
147 | + commentWithParams={this.commentWithParams} | ||
148 | + postId={this.props.subject.id} | ||
149 | + cidFrom={this.props.user.profile.uid} | ||
150 | + authorUid={this.props.subject.authorInfo.uid} | ||
142 | /> | 151 | /> |
143 | </View> | 152 | </View> |
144 | ); | 153 | ); |
@@ -11,6 +11,7 @@ import PostingService from '../../services/PostingService'; | @@ -11,6 +11,7 @@ import PostingService from '../../services/PostingService'; | ||
11 | import Immutable, {List, Record} from 'immutable'; | 11 | import Immutable, {List, Record} from 'immutable'; |
12 | import { | 12 | import { |
13 | NativeModules, | 13 | NativeModules, |
14 | + Alert, | ||
14 | } from 'react-native' | 15 | } from 'react-native' |
15 | 16 | ||
16 | let YH_CommunityAssetsPicker = NativeModules.YH_CommunityAssetsPicker; | 17 | let YH_CommunityAssetsPicker = NativeModules.YH_CommunityAssetsPicker; |
@@ -187,8 +188,10 @@ export function updateUploadState(url,fileName) { | @@ -187,8 +188,10 @@ export function updateUploadState(url,fileName) { | ||
187 | if (posting.postPercent == 1) { | 188 | if (posting.postPercent == 1) { |
188 | let assets = posting.assets.toJS(); | 189 | let assets = posting.assets.toJS(); |
189 | let imageStr = ''; | 190 | let imageStr = ''; |
191 | + let sizeStr = ''; | ||
190 | for (let i = 0; i < assets.length; i++) { | 192 | for (let i = 0; i < assets.length; i++) { |
191 | imageStr += assets[i].webURL+','; | 193 | imageStr += assets[i].webURL+','; |
194 | + sizeStr += assets[i].width + 'x' + assets[i].height +','; | ||
192 | } | 195 | } |
193 | let param = { | 196 | let param = { |
194 | postTitle: encodeURI(posting.title), | 197 | postTitle: encodeURI(posting.title), |
@@ -196,6 +199,7 @@ export function updateUploadState(url,fileName) { | @@ -196,6 +199,7 @@ export function updateUploadState(url,fileName) { | ||
196 | forumCode: posting.currentBoardId, | 199 | forumCode: posting.currentBoardId, |
197 | contentData: encodeURI(posting.content), | 200 | contentData: encodeURI(posting.content), |
198 | images: imageStr, | 201 | images: imageStr, |
202 | + sizes: sizeStr, | ||
199 | } | 203 | } |
200 | return new PostingService().commitPost(param).then((json) => { | 204 | return new PostingService().commitPost(param).then((json) => { |
201 | store.delete(POSTING_CACHE_KEY); | 205 | store.delete(POSTING_CACHE_KEY); |
@@ -22,6 +22,10 @@ const { | @@ -22,6 +22,10 @@ const { | ||
22 | SUBJECT_COMMENTS_SUCCESS, | 22 | SUBJECT_COMMENTS_SUCCESS, |
23 | SUBJECT_COMMENTS_FAILURE, | 23 | SUBJECT_COMMENTS_FAILURE, |
24 | SUBJECT_ASSETS_SELECTED, | 24 | SUBJECT_ASSETS_SELECTED, |
25 | + SUBJECT_REPLY_REQUEST, | ||
26 | + SUBJECT_REPLY_SUCCESS, | ||
27 | + SUBJECT_REPLY_FAILURE, | ||
28 | + SUBJECT_REPLY_UPDATE, | ||
25 | } = require('../../constants/actionTypes').default; | 29 | } = require('../../constants/actionTypes').default; |
26 | 30 | ||
27 | export function requestPostContent(postsId) { | 31 | export function requestPostContent(postsId) { |
@@ -97,24 +101,26 @@ export function commentsRequestSuccess(json) { | @@ -97,24 +101,26 @@ export function commentsRequestSuccess(json) { | ||
97 | let {list} = json; | 101 | let {list} = json; |
98 | let newList = []; | 102 | let newList = []; |
99 | list && list.map((obj,i)=> { | 103 | list && list.map((obj,i)=> { |
100 | - let {createTime, reply, replyTo, blocks} = obj; | 104 | + let {createTime, reply, replyTo, blocks,postInfo,id} = obj; |
101 | let timeagoStr = timeago().format(createTime, 'zh_CN'); | 105 | let timeagoStr = timeago().format(createTime, 'zh_CN'); |
102 | let newBlocks = []; | 106 | let newBlocks = []; |
103 | blocks && blocks.map((blockItem, i) => { | 107 | blocks && blocks.map((blockItem, i) => { |
104 | let {commentId,content,templateKey,orderBy} = blockItem; | 108 | let {commentId,content,templateKey,orderBy} = blockItem; |
105 | let newItem = { | 109 | let newItem = { |
106 | - "contentData": content, | ||
107 | - "order": orderBy, | ||
108 | - "templateKey": templateKey, | 110 | + "contentData": content||'', |
111 | + "order": orderBy||'', | ||
112 | + "templateKey": templateKey||'', | ||
109 | }; | 113 | }; |
110 | newBlocks.push(newItem); | 114 | newBlocks.push(newItem); |
111 | }) | 115 | }) |
112 | let newObj={ | 116 | let newObj={ |
113 | - timeago: timeagoStr, | ||
114 | - headIcon: reply.headIcon, | ||
115 | - nickName: reply.nickName, | 117 | + commentId: id||'', |
118 | + cidTo: postInfo.authorUid||'', | ||
119 | + timeago: timeagoStr||'', | ||
120 | + headIcon: reply.headIcon||'', | ||
121 | + nickName: reply.nickName||'', | ||
116 | LZ:false, | 122 | LZ:false, |
117 | - blocks: newBlocks, | 123 | + blocks: newBlocks||[], |
118 | } | 124 | } |
119 | newList.push(newObj); | 125 | newList.push(newObj); |
120 | }) | 126 | }) |
@@ -139,3 +145,90 @@ export function assetsSelected(assets) { | @@ -139,3 +145,90 @@ export function assetsSelected(assets) { | ||
139 | payload: assets, | 145 | payload: assets, |
140 | } | 146 | } |
141 | } | 147 | } |
148 | + | ||
149 | +export function commentWithParams(params) { | ||
150 | + return (dispatch, getState) => { | ||
151 | + dispatch(startComment()); | ||
152 | + let {subject} = getState(); | ||
153 | + let assets = subject.assets.toJS(); | ||
154 | + if (assets.length) { | ||
155 | + for (let i = 0; i < assets.length; i++) { | ||
156 | + let asset = assets[i] | ||
157 | + | ||
158 | + new PostingService().uploadImageAsset(asset) | ||
159 | + .then(response => { | ||
160 | + dispatch(updateCommentProgress(response, params)); | ||
161 | + }).catch(error => { | ||
162 | + dispatch(commentFail(error)); | ||
163 | + }); | ||
164 | + } | ||
165 | + } else { | ||
166 | + dispatch(commitComment(params)); | ||
167 | + } | ||
168 | + } | ||
169 | +} | ||
170 | + | ||
171 | +export function startComment() { | ||
172 | + return { | ||
173 | + type: SUBJECT_REPLY_REQUEST, | ||
174 | + } | ||
175 | +} | ||
176 | + | ||
177 | +export function commitComment(params) { | ||
178 | + return dispatch => { | ||
179 | + new PostingService().commitReply(params) | ||
180 | + .then(response => { | ||
181 | + dispatch(commentSuccess(response)); | ||
182 | + }).catch(error => { | ||
183 | + dispatch(commentFail(error)); | ||
184 | + }); | ||
185 | + } | ||
186 | +} | ||
187 | + | ||
188 | +export function updateCommentProgress(url, params) { | ||
189 | + return (dispatch, getState) => { | ||
190 | + let {subject} = getState(); | ||
191 | + let {assetsUrlStr, assetFinishCount} = subject; | ||
192 | + let newStr = assetsUrlStr + url + ','; | ||
193 | + let newCount = assetFinishCount + 1; | ||
194 | + let payloadData = { | ||
195 | + newStr, | ||
196 | + newCount, | ||
197 | + }; | ||
198 | + console.log(payloadData); | ||
199 | + dispatch(commentImageStateChanged(payloadData)); | ||
200 | + dispatch(() => { | ||
201 | + let {subject} = getState(); | ||
202 | + if (subject.assetFinishCount == subject.assets.toJS().length) { | ||
203 | + let newParams = { | ||
204 | + ...params, | ||
205 | + images: subject.assetsUrlStr, | ||
206 | + } | ||
207 | + console.log(newParams); | ||
208 | + dispatch(commitComment(newParams)); | ||
209 | + } | ||
210 | + | ||
211 | + }); | ||
212 | + } | ||
213 | +} | ||
214 | + | ||
215 | +export function commentImageStateChanged(payloadData) { | ||
216 | + return { | ||
217 | + type: SUBJECT_REPLY_UPDATE, | ||
218 | + payload: payloadData, | ||
219 | + } | ||
220 | +} | ||
221 | + | ||
222 | +export function commentSuccess(json) { | ||
223 | + return { | ||
224 | + type: SUBJECT_REPLY_SUCCESS, | ||
225 | + payload: json, | ||
226 | + } | ||
227 | +} | ||
228 | + | ||
229 | +export function commentFail (error) { | ||
230 | + return { | ||
231 | + type: SUBJECT_COMMENTS_FAILURE, | ||
232 | + payload: error, | ||
233 | + } | ||
234 | +} |
@@ -50,6 +50,10 @@ let InitialState = Record({ | @@ -50,6 +50,10 @@ let InitialState = Record({ | ||
50 | commentList: List(),// | 50 | commentList: List(),// |
51 | 51 | ||
52 | assets: List(),//回复里面的图片。 | 52 | assets: List(),//回复里面的图片。 |
53 | + assetsUrlStr: '', | ||
54 | + assetFinishCount: 0, | ||
55 | + isReplying: false, | ||
56 | + replyError: null, | ||
53 | }); | 57 | }); |
54 | 58 | ||
55 | export default InitialState; | 59 | export default InitialState; |
@@ -23,6 +23,11 @@ const { | @@ -23,6 +23,11 @@ const { | ||
23 | SUBJECT_COMMENTS_SUCCESS, | 23 | SUBJECT_COMMENTS_SUCCESS, |
24 | SUBJECT_COMMENTS_FAILURE, | 24 | SUBJECT_COMMENTS_FAILURE, |
25 | SUBJECT_ASSETS_SELECTED, | 25 | SUBJECT_ASSETS_SELECTED, |
26 | + | ||
27 | + SUBJECT_REPLY_REQUEST, | ||
28 | + SUBJECT_REPLY_SUCCESS, | ||
29 | + SUBJECT_REPLY_FAILURE, | ||
30 | + SUBJECT_REPLY_UPDATE, | ||
26 | } = require('../../constants/actionTypes').default; | 31 | } = require('../../constants/actionTypes').default; |
27 | 32 | ||
28 | const initialState = new InitialState; | 33 | const initialState = new InitialState; |
@@ -132,6 +137,32 @@ export default function postingReducer(state = initialState, action) { | @@ -132,6 +137,32 @@ export default function postingReducer(state = initialState, action) { | ||
132 | return nextState; | 137 | return nextState; |
133 | } | 138 | } |
134 | break; | 139 | break; |
140 | + case SUBJECT_REPLY_REQUEST: { | ||
141 | + let nextState = state.set('isReplying',true).set('replyError',null); | ||
142 | + return nextState; | ||
143 | + } | ||
144 | + break; | ||
145 | + case SUBJECT_REPLY_SUCCESS:{ | ||
146 | + let nextState = state.set('assets',Immutable.fromJS([])) | ||
147 | + .set('assetsUrlStr','') | ||
148 | + .set('assetFinishCount',0) | ||
149 | + .set('isReplying',false) | ||
150 | + .set('replyError',error) | ||
151 | + return nextState; | ||
152 | + } | ||
153 | + break; | ||
154 | + case SUBJECT_REPLY_FAILURE: { | ||
155 | + let nextState = state.set('isReplying',false).set('replyError',action.payload); | ||
156 | + return nextState; | ||
157 | + } | ||
158 | + break; | ||
159 | + case SUBJECT_REPLY_UPDATE: { | ||
160 | + let {newStr,newCount} = action.payload; | ||
161 | + let nextState = state.set('assetsUrlStr',newStr).set('assetFinishCount',newCount); | ||
162 | + return nextState; | ||
163 | + } | ||
164 | + | ||
165 | + break; | ||
135 | default: | 166 | default: |
136 | return initialState; | 167 | return initialState; |
137 | break; | 168 | break; |
@@ -433,16 +433,10 @@ export function uploadAvatar(assetURL) { | @@ -433,16 +433,10 @@ export function uploadAvatar(assetURL) { | ||
433 | // dispatch(startUploadAvatar()); | 433 | // dispatch(startUploadAvatar()); |
434 | let {user} = getState(); | 434 | let {user} = getState(); |
435 | 435 | ||
436 | - let formData = new FormData() | ||
437 | let params = { | 436 | let params = { |
438 | - 'fileData': { | ||
439 | - name: 'avatar.jpg', | ||
440 | - type: 'image/jpeg', | ||
441 | - uri: assetURL.url, | ||
442 | - }, | ||
443 | - | 437 | + assetURL, |
444 | uid: user.profile.uid, | 438 | uid: user.profile.uid, |
445 | - bucket: 'yhb_head', | 439 | + bucket: 'yhb_head', |
446 | }; | 440 | }; |
447 | 441 | ||
448 | return new UserService().updateUserAvatar(params) | 442 | return new UserService().updateUserAvatar(params) |
@@ -451,6 +445,7 @@ export function uploadAvatar(assetURL) { | @@ -451,6 +445,7 @@ export function uploadAvatar(assetURL) { | ||
451 | dispatch(avatarUploadSuccess(json)); | 445 | dispatch(avatarUploadSuccess(json)); |
452 | dispatch(syncUserWithSSOUid(user.profile.uid)); | 446 | dispatch(syncUserWithSSOUid(user.profile.uid)); |
453 | }).catch(error => { | 447 | }).catch(error => { |
448 | + console.log(error); | ||
454 | dispatch(avatarUploadFailure(error)); | 449 | dispatch(avatarUploadFailure(error)); |
455 | }) | 450 | }) |
456 | 451 | ||
@@ -687,7 +682,6 @@ function parseJson(json) { | @@ -687,7 +682,6 @@ function parseJson(json) { | ||
687 | } | 682 | } |
688 | 683 | ||
689 | function parseReply(json) { | 684 | function parseReply(json) { |
690 | - console.log('========>', json); | ||
691 | let {lastedTime, list} = json; | 685 | let {lastedTime, list} = json; |
692 | let replies = []; | 686 | let replies = []; |
693 | list && list.map((item, i) => { | 687 | list && list.map((item, i) => { |
@@ -42,6 +42,19 @@ export default class PostingService { | @@ -42,6 +42,19 @@ export default class PostingService { | ||
42 | }); | 42 | }); |
43 | } | 43 | } |
44 | 44 | ||
45 | + async commitReply(params) { | ||
46 | + return await this.api.get({ | ||
47 | + url:'', | ||
48 | + body: { | ||
49 | + method:'app.social.addComment', | ||
50 | + ...params, | ||
51 | + } | ||
52 | + }).then((json) => { | ||
53 | + return json; | ||
54 | + }).catch((error) => { | ||
55 | + throw(error); | ||
56 | + }); | ||
57 | + } | ||
45 | 58 | ||
46 | async getBoardList() { | 59 | async getBoardList() { |
47 | 60 | ||
@@ -114,7 +127,8 @@ export default class PostingService { | @@ -114,7 +127,8 @@ export default class PostingService { | ||
114 | options.body = formData; | 127 | options.body = formData; |
115 | options.method = 'post'; | 128 | options.method = 'post'; |
116 | options.headers = {'project':'social',HTTP_REFERER:'admin.yohobuy.com'}; | 129 | options.headers = {'project':'social',HTTP_REFERER:'admin.yohobuy.com'}; |
117 | - | 130 | + console.log('zhixingdao zheli le ..............SSSSSSSSSSSSSSSSSSSSSSSS'); |
131 | + console.log(options); | ||
118 | return await fetch('http://upload.static.yohobuy.com', options) | 132 | return await fetch('http://upload.static.yohobuy.com', options) |
119 | .then((response) => { | 133 | .then((response) => { |
120 | 134 |
@@ -3,22 +3,74 @@ | @@ -3,22 +3,74 @@ | ||
3 | import Request from '../../common/services/Request'; | 3 | import Request from '../../common/services/Request'; |
4 | import moment from 'moment'; | 4 | import moment from 'moment'; |
5 | 5 | ||
6 | +import {Platform, Dimensions, NativeModules, CameraRoll,} from 'react-native'; | ||
7 | +import DeviceInfo from 'react-native-device-info'; | ||
8 | +import queryString from 'query-string'; | ||
9 | +import RNNativeConfig from '../../common/services/RNNativeConfig'; | ||
10 | + | ||
6 | export default class UserService { | 11 | export default class UserService { |
7 | constructor() { | 12 | constructor() { |
8 | this.api = new Request(); | 13 | this.api = new Request(); |
9 | } | 14 | } |
10 | 15 | ||
11 | async updateUserAvatar(params) { | 16 | async updateUserAvatar(params) { |
12 | - return await this.api.get({ | ||
13 | - url: '', | ||
14 | - body: { | ||
15 | - method:'app.social.modifyHead', | ||
16 | - ...params, | ||
17 | - } | ||
18 | - }).then((json)=> { | ||
19 | - return json; | 17 | + // return await this.api.post({ |
18 | + // url: '', | ||
19 | + // body: { | ||
20 | + // method:'app.social.modifyHead', | ||
21 | + // ...params, | ||
22 | + // } | ||
23 | + // }).then((json)=> { | ||
24 | + // return json; | ||
25 | + // }).catch((error) => { | ||
26 | + // throw error; | ||
27 | + // }); | ||
28 | + let {assetURL,uid,bucket}= params | ||
29 | + let formData = new FormData(); | ||
30 | + formData.append('fileData',{name:'avatar.jpg',type: 'image/jpeg','uri':assetURL}); | ||
31 | + | ||
32 | + | ||
33 | + let app_version = DeviceInfo.getBuildNumber(); | ||
34 | + let os_version = DeviceInfo.getSystemVersion(); | ||
35 | + let client_type = Platform.OS === 'ios' ? 'iphone' : 'android'; | ||
36 | + let {height, width} = Dimensions.get('window'); | ||
37 | + let screen_size = width + 'x' + height; | ||
38 | + let privateKey = RNNativeConfig.getPrivateKey(); | ||
39 | + | ||
40 | + formData.append('app_version',app_version); | ||
41 | + formData.append('os_version',os_version); | ||
42 | + formData.append('client_type',client_type); | ||
43 | + formData.append('screen_size',width + 'x' + height); | ||
44 | + formData.append('privateKey',privateKey); | ||
45 | + formData.append('uid',uid); | ||
46 | + formData.append('bucket',bucket); | ||
47 | + formData.append('method','app.social.modifyHead'); | ||
48 | + formData.append('client_secret','aaaaaaaaaaaaaaaaaaaaa') | ||
49 | + | ||
50 | + let options = {}; | ||
51 | + options.body = formData; | ||
52 | + options.method = 'post'; | ||
53 | + options.headers = {method:'app.social.modifyHead',HTTP_REFERER:'admin.yohobuy.com',client_secret:'aaaaaaaaaaaaaaaaaaaaa'}; | ||
54 | + | ||
55 | + return await fetch('http://192.168.102.206:8095/social', options) | ||
56 | + .then((response) => { | ||
57 | + | ||
58 | + return response.json().then( | ||
59 | + (json) => { | ||
60 | + console.log(json); | ||
61 | + if (json.code == 200) { | ||
62 | + return json.data.imagesList[0]; | ||
63 | + }else { | ||
64 | + throw(json); | ||
65 | + } | ||
66 | + } | ||
67 | + ) | ||
68 | + | ||
69 | + | ||
20 | }).catch((error) => { | 70 | }).catch((error) => { |
21 | - throw error; | 71 | + console.log('wwwwwwwwwwwwwwww'); |
72 | + console.log(error); | ||
73 | + throw(error); | ||
22 | }); | 74 | }); |
23 | 75 | ||
24 | } | 76 | } |
-
Please register or login to post a comment