Large image. reviewed by redding.
Showing
7 changed files
with
119 additions
and
10 deletions
@@ -7,6 +7,7 @@ import { | @@ -7,6 +7,7 @@ import { | ||
7 | StyleSheet, | 7 | StyleSheet, |
8 | Image, | 8 | Image, |
9 | Dimensions, | 9 | Dimensions, |
10 | + TouchableOpacity, | ||
10 | } from 'react-native' | 11 | } from 'react-native' |
11 | 12 | ||
12 | import SlicedImage from '../../../common/components/SlicedImage'; | 13 | import SlicedImage from '../../../common/components/SlicedImage'; |
@@ -49,9 +50,23 @@ export default class SubjectContent extends Component { | @@ -49,9 +50,23 @@ export default class SubjectContent extends Component { | ||
49 | imgHeight = imgWidth/w*h; | 50 | imgHeight = imgWidth/w*h; |
50 | } | 51 | } |
51 | } | 52 | } |
52 | - return( | ||
53 | - <SlicedImage key={i} style={[styles.contentImage,{width:imgWidth,height:imgHeight}]} source={{uri:content}}/> | ||
54 | - ) | 53 | + if (this.props.onPressLargeImage) { |
54 | + return ( | ||
55 | + <TouchableOpacity | ||
56 | + key={i} | ||
57 | + style={[styles.contentImage,{width:imgWidth,height:imgHeight}]} | ||
58 | + onPress={()=>{ | ||
59 | + this.props.onPressLargeImage(item.index); | ||
60 | + }} | ||
61 | + > | ||
62 | + <SlicedImage key={i} style={{width:imgWidth,height:imgHeight}} source={{uri:content}}/> | ||
63 | + </TouchableOpacity> | ||
64 | + ); | ||
65 | + } else { | ||
66 | + return( | ||
67 | + <SlicedImage key={i} style={[styles.contentImage,{width:imgWidth,height:imgHeight}]} source={{uri:content}}/> | ||
68 | + ) | ||
69 | + } | ||
55 | } | 70 | } |
56 | })} | 71 | })} |
57 | </View> | 72 | </View> |
@@ -16,8 +16,10 @@ import { | @@ -16,8 +16,10 @@ import { | ||
16 | Platform, | 16 | Platform, |
17 | TextInput, | 17 | TextInput, |
18 | Alert, | 18 | Alert, |
19 | + NativeModules, | ||
19 | } from 'react-native' | 20 | } from 'react-native' |
20 | import UserBrief from '../home/UserBrief'; | 21 | import UserBrief from '../home/UserBrief'; |
22 | +import PostingService from '../../services/PostingService'; | ||
21 | 23 | ||
22 | import SPHeaderCell from './SPHeaderCell'; | 24 | import SPHeaderCell from './SPHeaderCell'; |
23 | import SubjectContent from './SubjectContent'; | 25 | import SubjectContent from './SubjectContent'; |
@@ -182,7 +184,32 @@ export default class SubjectPost extends Component { | @@ -182,7 +184,32 @@ export default class SubjectPost extends Component { | ||
182 | ()=>{ | 184 | ()=>{ |
183 | this.cidTo = this.props.authorUid; | 185 | this.cidTo = this.props.authorUid; |
184 | this.commentId = ''; | 186 | this.commentId = ''; |
185 | - this.setState({replyState: this.currentReplyState}) | 187 | + NativeModules.YH_CommunityHelper.uid() |
188 | + .then(uid => { | ||
189 | + new PostingService().getPostUser(uid).then(json => { | ||
190 | + if (json.forbidSpeaking === 'Y') { | ||
191 | + Alert.alert('抱歉','您暂时被禁言,请等待禁言解除哦~'); | ||
192 | + } else { | ||
193 | + this.setState({replyState: this.currentReplyState}); | ||
194 | + } | ||
195 | + }).catch(error => { | ||
196 | + this.setState({replyState: this.currentReplyState}); | ||
197 | + }) | ||
198 | + }) | ||
199 | + .catch(error => { | ||
200 | + NativeModules.YH_CommunityHelper.login() | ||
201 | + .then(uid => { | ||
202 | + new PostingService().getPostUser(uid).then(json => { | ||
203 | + if (json.forbidSpeaking === 'Y') { | ||
204 | + Alert.alert('抱歉','您暂时被禁言,请等待禁言解除哦~'); | ||
205 | + } else { | ||
206 | + this.setState({replyState: this.currentReplyState}); | ||
207 | + } | ||
208 | + }).catch(error => { | ||
209 | + this.setState({replyState: this.currentReplyState}); | ||
210 | + }) | ||
211 | + }); | ||
212 | + }); | ||
186 | } | 213 | } |
187 | } | 214 | } |
188 | > | 215 | > |
@@ -307,7 +334,7 @@ export default class SubjectPost extends Component { | @@ -307,7 +334,7 @@ export default class SubjectPost extends Component { | ||
307 | break; | 334 | break; |
308 | case 'content': | 335 | case 'content': |
309 | return( | 336 | return( |
310 | - <SubjectContent blocks={rowData}/> | 337 | + <SubjectContent onPressLargeImage={this.props.onPressLargeImage} blocks={rowData}/> |
311 | ); | 338 | ); |
312 | break; | 339 | break; |
313 | case 'shareGoods': | 340 | case 'shareGoods': |
@@ -336,8 +363,6 @@ export default class SubjectPost extends Component { | @@ -336,8 +363,6 @@ export default class SubjectPost extends Component { | ||
336 | ); | 363 | ); |
337 | break; | 364 | break; |
338 | case 'comments': | 365 | case 'comments': |
339 | - console.log('.............'); | ||
340 | - console.log(rowData); | ||
341 | return ( | 366 | return ( |
342 | <TouchableOpacity | 367 | <TouchableOpacity |
343 | style={styles.commentContainer} | 368 | style={styles.commentContainer} |
@@ -345,7 +370,35 @@ export default class SubjectPost extends Component { | @@ -345,7 +370,35 @@ export default class SubjectPost extends Component { | ||
345 | ()=> { | 370 | ()=> { |
346 | this.cidTo = rowData.cidTo; | 371 | this.cidTo = rowData.cidTo; |
347 | this.commentId = rowData.commentId; | 372 | this.commentId = rowData.commentId; |
348 | - this.replyToSomeOneElse(rowData.nickName); | 373 | + |
374 | + | ||
375 | + NativeModules.YH_CommunityHelper.uid() | ||
376 | + .then(uid => { | ||
377 | + new PostingService().getPostUser(uid).then(json => { | ||
378 | + if (json.forbidSpeaking === 'Y') { | ||
379 | + Alert.alert('抱歉','您暂时被禁言,请等待禁言解除哦~'); | ||
380 | + } else { | ||
381 | + this.replyToSomeOneElse(rowData.nickName); | ||
382 | + } | ||
383 | + }).catch(error => { | ||
384 | + this.replyToSomeOneElse(rowData.nickName); | ||
385 | + }) | ||
386 | + }) | ||
387 | + .catch(error => { | ||
388 | + NativeModules.YH_CommunityHelper.login() | ||
389 | + .then(uid => { | ||
390 | + new PostingService().getPostUser(uid).then(json => { | ||
391 | + if (json.forbidSpeaking === 'Y') { | ||
392 | + Alert.alert('抱歉','您暂时被禁言,请等待禁言解除哦~'); | ||
393 | + } else { | ||
394 | + this.replyToSomeOneElse(rowData.nickName); | ||
395 | + } | ||
396 | + }).catch(error => { | ||
397 | + this.replyToSomeOneElse(rowData.nickName); | ||
398 | + }) | ||
399 | + | ||
400 | + }); | ||
401 | + }); | ||
349 | } | 402 | } |
350 | } | 403 | } |
351 | > | 404 | > |
@@ -66,6 +66,7 @@ class SubjectPostContainer extends Component { | @@ -66,6 +66,7 @@ class SubjectPostContainer extends Component { | ||
66 | this.onPressLikeCell = this.onPressLikeCell.bind(this); | 66 | this.onPressLikeCell = this.onPressLikeCell.bind(this); |
67 | this.onPressLikeOrDislike = this.onPressLikeOrDislike.bind(this); | 67 | this.onPressLikeOrDislike = this.onPressLikeOrDislike.bind(this); |
68 | this.onPressShareGoods = this.onPressShareGoods.bind(this); | 68 | this.onPressShareGoods = this.onPressShareGoods.bind(this); |
69 | + this.onPressLargeImage = this.onPressLargeImage.bind(this); | ||
69 | } | 70 | } |
70 | 71 | ||
71 | componentDidMount() { | 72 | componentDidMount() { |
@@ -86,6 +87,10 @@ class SubjectPostContainer extends Component { | @@ -86,6 +87,10 @@ class SubjectPostContainer extends Component { | ||
86 | this.props.actions.requestPostComments(300, this.props.subject.lastedTime); | 87 | this.props.actions.requestPostComments(300, this.props.subject.lastedTime); |
87 | } | 88 | } |
88 | 89 | ||
90 | + onPressLargeImage(index) { | ||
91 | + NativeModules.YH_CommunityHelper.showLargeImages(this.props.subject.largeImages,index); | ||
92 | + } | ||
93 | + | ||
89 | assetsSelected(assets) { | 94 | assetsSelected(assets) { |
90 | this.props.actions.assetsSelected(assets); | 95 | this.props.actions.assetsSelected(assets); |
91 | } | 96 | } |
@@ -188,6 +193,7 @@ class SubjectPostContainer extends Component { | @@ -188,6 +193,7 @@ class SubjectPostContainer extends Component { | ||
188 | onPressLikeOrDislike={this.onPressLikeOrDislike} | 193 | onPressLikeOrDislike={this.onPressLikeOrDislike} |
189 | likeState={this.props.subject.hasPraise} | 194 | likeState={this.props.subject.hasPraise} |
190 | onPressShareGoods={this.onPressShareGoods} | 195 | onPressShareGoods={this.onPressShareGoods} |
196 | + onPressLargeImage={this.onPressLargeImage} | ||
191 | /> | 197 | /> |
192 | </View> | 198 | </View> |
193 | ); | 199 | ); |
@@ -192,7 +192,7 @@ export function updateUploadState(url,fileName) { | @@ -192,7 +192,7 @@ export function updateUploadState(url,fileName) { | ||
192 | sizeStr += assets[i].width + 'x' + assets[i].height +','; | 192 | sizeStr += assets[i].width + 'x' + assets[i].height +','; |
193 | } | 193 | } |
194 | let param = { | 194 | let param = { |
195 | - postTitle: encodeURI(posting.title), | 195 | + postsTitle: encodeURI(posting.title), |
196 | uid: ssouid, | 196 | uid: ssouid, |
197 | forumCode: posting.currentBoardId, | 197 | forumCode: posting.currentBoardId, |
198 | contentData: encodeURI(posting.content), | 198 | contentData: encodeURI(posting.content), |
@@ -252,7 +252,7 @@ export function startPosting(assets) { | @@ -252,7 +252,7 @@ export function startPosting(assets) { | ||
252 | NativeModules.YH_CommunityHelper.uid().then(ssouid => { | 252 | NativeModules.YH_CommunityHelper.uid().then(ssouid => { |
253 | let {posting} = getState(); | 253 | let {posting} = getState(); |
254 | let param = { | 254 | let param = { |
255 | - postTitle: posting.title, | 255 | + postsTitle: posting.title, |
256 | uid: ssouid, | 256 | uid: ssouid, |
257 | forumCode: posting.currentBoardId, | 257 | forumCode: posting.currentBoardId, |
258 | contentData: posting.content, | 258 | contentData: posting.content, |
@@ -222,6 +222,38 @@ export function requestPostContent(postsId) { | @@ -222,6 +222,38 @@ export function requestPostContent(postsId) { | ||
222 | rightImg = require('../../images/posting/more.png'); | 222 | rightImg = require('../../images/posting/more.png'); |
223 | } | 223 | } |
224 | Actions.refresh({key: 'SubjectPost', rightButtonImage:rightImg}); | 224 | Actions.refresh({key: 'SubjectPost', rightButtonImage:rightImg}); |
225 | + | ||
226 | + let largeImages = []; | ||
227 | + let index=0; | ||
228 | + for (var i = 0; i < json.blocks.length; i++) { | ||
229 | + let item = json.blocks[i]; | ||
230 | + if (item.templateKey == 'image') { | ||
231 | + let urlStr = item.contentData||''; | ||
232 | + let imgWidth = 640; | ||
233 | + let imgHeight = imgWidth; | ||
234 | + let sizeStr = item.size || ''; | ||
235 | + if (sizeStr.length) { | ||
236 | + let ary=sizeStr.split('x'); | ||
237 | + let w = parseInt(ary[0]); | ||
238 | + let h = parseInt(ary[1]); | ||
239 | + if (w&&h) { | ||
240 | + imgHeight = imgWidth/w*h; | ||
241 | + } | ||
242 | + } | ||
243 | + let newSrc = urlStr; | ||
244 | + if (urlStr.indexOf('imageView') === -1) { | ||
245 | + newSrc = urlStr + '?imageView2/' + '1' + '/w/' + imgWidth + '/h/' + imgHeight; | ||
246 | + } else { | ||
247 | + newSrc = urlStr.replace('{mode}', '1') | ||
248 | + .replace('{width}', imgWidth) | ||
249 | + .replace('{height}', imgHeight); | ||
250 | + } | ||
251 | + largeImages.push(newSrc); | ||
252 | + json.blocks[i].index=index; | ||
253 | + index++; | ||
254 | + } | ||
255 | + } | ||
256 | + json.largeImages = largeImages; | ||
225 | dispatch(contentRequestSuccess(json)); | 257 | dispatch(contentRequestSuccess(json)); |
226 | }) | 258 | }) |
227 | .catch(error => { | 259 | .catch(error => { |
@@ -78,6 +78,7 @@ export default function postingReducer(state = initialState, action) { | @@ -78,6 +78,7 @@ export default function postingReducer(state = initialState, action) { | ||
78 | shareProductSkn, | 78 | shareProductSkn, |
79 | revieweState, | 79 | revieweState, |
80 | hasPraise, | 80 | hasPraise, |
81 | + largeImages, | ||
81 | LZ, | 82 | LZ, |
82 | } = action.payload; | 83 | } = action.payload; |
83 | let nextState = state.setIn(['authorInfo','headIcon'],authorInfo.headIcon||'') | 84 | let nextState = state.setIn(['authorInfo','headIcon'],authorInfo.headIcon||'') |
@@ -102,6 +103,7 @@ export default function postingReducer(state = initialState, action) { | @@ -102,6 +103,7 @@ export default function postingReducer(state = initialState, action) { | ||
102 | .set('isContentFetching', false) | 103 | .set('isContentFetching', false) |
103 | .set('contentError', null) | 104 | .set('contentError', null) |
104 | .set('revieweState',revieweState) | 105 | .set('revieweState',revieweState) |
106 | + .set('largeImages',largeImages) | ||
105 | .set('hasPraise',hasPraise||'N'); | 107 | .set('hasPraise',hasPraise||'N'); |
106 | if (shareGoods) { | 108 | if (shareGoods) { |
107 | nextState.setIn(['shareGoods','productName'],shareGoods.productName||'') | 109 | nextState.setIn(['shareGoods','productName'],shareGoods.productName||'') |
-
Please register or login to post a comment