Authored by 于良

社区首页版块部分 支持 点击区域 区分 review by 草莓

... ... @@ -71,10 +71,12 @@ export default class Home extends React.Component {
like: React.PropTypes.string.isRequired,
}),
hot: ImmutablePropTypes.contains({
postId: React.PropTypes.number,
avatar: React.PropTypes.string,
content: React.PropTypes.string.isRequired,
}),
new: ImmutablePropTypes.contains({
postId: React.PropTypes.number,
avatar: React.PropTypes.string,
content: React.PropTypes.string.isRequired,
}),
... ... @@ -200,12 +202,24 @@ export default class Home extends React.Component {
style={styles.carouselSection}
items={rowData.toJS()}
onClick={(info) => {
let type = info.type;
let item = rowData.get(info.index);
let section = {
id: item.get('header').get('id'),
name: item.get('header').get('title'),
if (type == 0) {
// section
let section = {
id: item.get('header').get('id'),
name: item.get('header').get('title'),
}
this.props.onPressSection && this.props.onPressSection(section);
} else if (type == 1) {
// hot
let postId = item.get('hot').get('postId')
this.props.onPressPost && this.props.onPressPost(postId);
} else if (type == 2) {
// new
let postId = item.get('new').get('postId')
this.props.onPressPost && this.props.onPressPost(postId);
}
this.props.onPressSection && this.props.onPressSection(section);
}}
/>
);
... ...
... ... @@ -259,14 +259,14 @@ function parseBNS(json) {
avatar: hotAvatar,
content: hotPost && hotPost.contentData ? hotPost.contentData : '',
hasImg: hotPost && hotPost.hasImgFlg ? hotPost.hasImgFlg : '',
postId: hotPost && hotPost.postId ? hotPost.postId : '',
postId: hotPost && hotPost.postId ? hotPost.postId : 0,
postTitle: hotPost && hotPost.postsTitle ? hotPost.postsTitle : '',
},
new: {
avatar: newAvatar,
content: newPost && newPost.contentData ? newPost.contentData : '',
hasImg: newPost && newPost.hasImgFlg ? newPost.hasImgFlg : '',
postId: newPost && newPost.postId ? newPost.postId : '',
postId: newPost && newPost.postId ? newPost.postId : 0,
postTitle: newPost && newPost.postsTitle ? newPost.postsTitle : '',
},
num: {
... ...