Authored by 盖剑秋

Large image. reviewed by redding.

... ... @@ -7,6 +7,7 @@ import {
StyleSheet,
Image,
Dimensions,
TouchableOpacity,
} from 'react-native'
import SlicedImage from '../../../common/components/SlicedImage';
... ... @@ -49,9 +50,23 @@ export default class SubjectContent extends Component {
imgHeight = imgWidth/w*h;
}
}
return(
<SlicedImage key={i} style={[styles.contentImage,{width:imgWidth,height:imgHeight}]} source={{uri:content}}/>
)
if (this.props.onPressLargeImage) {
return (
<TouchableOpacity
key={i}
style={[styles.contentImage,{width:imgWidth,height:imgHeight}]}
onPress={()=>{
this.props.onPressLargeImage(item.index);
}}
>
<SlicedImage key={i} style={{width:imgWidth,height:imgHeight}} source={{uri:content}}/>
</TouchableOpacity>
);
} else {
return(
<SlicedImage key={i} style={[styles.contentImage,{width:imgWidth,height:imgHeight}]} source={{uri:content}}/>
)
}
}
})}
</View>
... ...
... ... @@ -16,8 +16,10 @@ import {
Platform,
TextInput,
Alert,
NativeModules,
} from 'react-native'
import UserBrief from '../home/UserBrief';
import PostingService from '../../services/PostingService';
import SPHeaderCell from './SPHeaderCell';
import SubjectContent from './SubjectContent';
... ... @@ -182,7 +184,32 @@ export default class SubjectPost extends Component {
()=>{
this.cidTo = this.props.authorUid;
this.commentId = '';
this.setState({replyState: this.currentReplyState})
NativeModules.YH_CommunityHelper.uid()
.then(uid => {
new PostingService().getPostUser(uid).then(json => {
if (json.forbidSpeaking === 'Y') {
Alert.alert('抱歉','您暂时被禁言,请等待禁言解除哦~');
} else {
this.setState({replyState: this.currentReplyState});
}
}).catch(error => {
this.setState({replyState: this.currentReplyState});
})
})
.catch(error => {
NativeModules.YH_CommunityHelper.login()
.then(uid => {
new PostingService().getPostUser(uid).then(json => {
if (json.forbidSpeaking === 'Y') {
Alert.alert('抱歉','您暂时被禁言,请等待禁言解除哦~');
} else {
this.setState({replyState: this.currentReplyState});
}
}).catch(error => {
this.setState({replyState: this.currentReplyState});
})
});
});
}
}
>
... ... @@ -307,7 +334,7 @@ export default class SubjectPost extends Component {
break;
case 'content':
return(
<SubjectContent blocks={rowData}/>
<SubjectContent onPressLargeImage={this.props.onPressLargeImage} blocks={rowData}/>
);
break;
case 'shareGoods':
... ... @@ -336,8 +363,6 @@ export default class SubjectPost extends Component {
);
break;
case 'comments':
console.log('.............');
console.log(rowData);
return (
<TouchableOpacity
style={styles.commentContainer}
... ... @@ -345,7 +370,35 @@ export default class SubjectPost extends Component {
()=> {
this.cidTo = rowData.cidTo;
this.commentId = rowData.commentId;
this.replyToSomeOneElse(rowData.nickName);
NativeModules.YH_CommunityHelper.uid()
.then(uid => {
new PostingService().getPostUser(uid).then(json => {
if (json.forbidSpeaking === 'Y') {
Alert.alert('抱歉','您暂时被禁言,请等待禁言解除哦~');
} else {
this.replyToSomeOneElse(rowData.nickName);
}
}).catch(error => {
this.replyToSomeOneElse(rowData.nickName);
})
})
.catch(error => {
NativeModules.YH_CommunityHelper.login()
.then(uid => {
new PostingService().getPostUser(uid).then(json => {
if (json.forbidSpeaking === 'Y') {
Alert.alert('抱歉','您暂时被禁言,请等待禁言解除哦~');
} else {
this.replyToSomeOneElse(rowData.nickName);
}
}).catch(error => {
this.replyToSomeOneElse(rowData.nickName);
})
});
});
}
}
>
... ...
... ... @@ -66,6 +66,7 @@ class SubjectPostContainer extends Component {
this.onPressLikeCell = this.onPressLikeCell.bind(this);
this.onPressLikeOrDislike = this.onPressLikeOrDislike.bind(this);
this.onPressShareGoods = this.onPressShareGoods.bind(this);
this.onPressLargeImage = this.onPressLargeImage.bind(this);
}
componentDidMount() {
... ... @@ -86,6 +87,10 @@ class SubjectPostContainer extends Component {
this.props.actions.requestPostComments(300, this.props.subject.lastedTime);
}
onPressLargeImage(index) {
NativeModules.YH_CommunityHelper.showLargeImages(this.props.subject.largeImages,index);
}
assetsSelected(assets) {
this.props.actions.assetsSelected(assets);
}
... ... @@ -188,6 +193,7 @@ class SubjectPostContainer extends Component {
onPressLikeOrDislike={this.onPressLikeOrDislike}
likeState={this.props.subject.hasPraise}
onPressShareGoods={this.onPressShareGoods}
onPressLargeImage={this.onPressLargeImage}
/>
</View>
);
... ...
... ... @@ -192,7 +192,7 @@ export function updateUploadState(url,fileName) {
sizeStr += assets[i].width + 'x' + assets[i].height +',';
}
let param = {
postTitle: encodeURI(posting.title),
postsTitle: encodeURI(posting.title),
uid: ssouid,
forumCode: posting.currentBoardId,
contentData: encodeURI(posting.content),
... ... @@ -252,7 +252,7 @@ export function startPosting(assets) {
NativeModules.YH_CommunityHelper.uid().then(ssouid => {
let {posting} = getState();
let param = {
postTitle: posting.title,
postsTitle: posting.title,
uid: ssouid,
forumCode: posting.currentBoardId,
contentData: posting.content,
... ...
... ... @@ -222,6 +222,38 @@ export function requestPostContent(postsId) {
rightImg = require('../../images/posting/more.png');
}
Actions.refresh({key: 'SubjectPost', rightButtonImage:rightImg});
let largeImages = [];
let index=0;
for (var i = 0; i < json.blocks.length; i++) {
let item = json.blocks[i];
if (item.templateKey == 'image') {
let urlStr = item.contentData||'';
let imgWidth = 640;
let imgHeight = imgWidth;
let sizeStr = item.size || '';
if (sizeStr.length) {
let ary=sizeStr.split('x');
let w = parseInt(ary[0]);
let h = parseInt(ary[1]);
if (w&&h) {
imgHeight = imgWidth/w*h;
}
}
let newSrc = urlStr;
if (urlStr.indexOf('imageView') === -1) {
newSrc = urlStr + '?imageView2/' + '1' + '/w/' + imgWidth + '/h/' + imgHeight;
} else {
newSrc = urlStr.replace('{mode}', '1')
.replace('{width}', imgWidth)
.replace('{height}', imgHeight);
}
largeImages.push(newSrc);
json.blocks[i].index=index;
index++;
}
}
json.largeImages = largeImages;
dispatch(contentRequestSuccess(json));
})
.catch(error => {
... ...
... ... @@ -58,6 +58,7 @@ let InitialState = Record({
replyError: null,
inLikeAction: false,
largeImages:[],
});
export default InitialState;
... ...
... ... @@ -78,6 +78,7 @@ export default function postingReducer(state = initialState, action) {
shareProductSkn,
revieweState,
hasPraise,
largeImages,
LZ,
} = action.payload;
let nextState = state.setIn(['authorInfo','headIcon'],authorInfo.headIcon||'')
... ... @@ -102,6 +103,7 @@ export default function postingReducer(state = initialState, action) {
.set('isContentFetching', false)
.set('contentError', null)
.set('revieweState',revieweState)
.set('largeImages',largeImages)
.set('hasPraise',hasPraise||'N');
if (shareGoods) {
nextState.setIn(['shareGoods','productName'],shareGoods.productName||'')
... ...