...
|
...
|
@@ -17,6 +17,7 @@ import GlobalHomeSwiper from './GlobalHomeSwiper'; |
|
|
import RecommendContentTwo from './RecommendContentTwo';
|
|
|
import RecommendContentFive from './RecommendContentFive';
|
|
|
import RecommendContentOne from './RecommendContentOne';
|
|
|
import ProductFliter from './ProductFliter';
|
|
|
import SmallPic from './SmallPic';
|
|
|
import {getSlicedUrl} from '../../../classify/utils/Utils';
|
|
|
|
...
|
...
|
@@ -29,9 +30,11 @@ export default class Home extends Component { |
|
|
this._onEndReached = this._onEndReached.bind(this);
|
|
|
this._renderFooter = this._renderFooter.bind(this);
|
|
|
this.trigggePullToRefresh = this.trigggePullToRefresh.bind(this);
|
|
|
this.renderSectionHeader = this.renderSectionHeader.bind(this);
|
|
|
|
|
|
this.dataSource = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
|
|
sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2),
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -56,54 +59,73 @@ export default class Home extends Component { |
|
|
}
|
|
|
|
|
|
_renderRow(rowData: object, sectionID: number, rowID: number) {
|
|
|
|
|
|
// console.log(rowData.toJS());
|
|
|
if (rowData.get('template_name') == 'focus') {
|
|
|
return (
|
|
|
<GlobalHomeSwiper resource={rowData}/>
|
|
|
);
|
|
|
}else if (rowData.get('template_name') == 'recommend_content_two') {
|
|
|
return (
|
|
|
<RecommendContentTwo resource={rowData}/>
|
|
|
);
|
|
|
}else if (rowData.get('template_name') == 'recommend_content_five') {
|
|
|
return (
|
|
|
<RecommendContentFive
|
|
|
resource={rowData}
|
|
|
// onPressRecommendItem={this.props.onPressRecommendItem}
|
|
|
/>
|
|
|
);
|
|
|
}else if (rowData.get('template_name') == 'recommend_content_one') {
|
|
|
return (
|
|
|
<RecommendContentOne
|
|
|
resource={rowData}
|
|
|
// onPressRecommendItem={this.props.onPressRecommendItem}
|
|
|
/>
|
|
|
);
|
|
|
}else if (rowData.get('template_name') == 'divideImage') {
|
|
|
let data = rowData.get('data').toJS();
|
|
|
let divideImage = getSlicedUrl(data[0].src, width, 20, 2);
|
|
|
if (!divideImage) {return null;}
|
|
|
return (
|
|
|
<Image
|
|
|
source={{uri: divideImage}}
|
|
|
style={{width: width,height: 20}}
|
|
|
resizeMode={'cover'}
|
|
|
></Image>
|
|
|
);
|
|
|
}else if (rowData.get('template_name') == 'small_pic') {
|
|
|
|
|
|
|
|
|
if (sectionID == 'topHeader') {
|
|
|
if (rowData.get('template_name') == 'focus') {
|
|
|
return (
|
|
|
<GlobalHomeSwiper resource={rowData}/>
|
|
|
);
|
|
|
}else if (rowData.get('template_name') == 'recommend_content_two') {
|
|
|
return (
|
|
|
<RecommendContentTwo resource={rowData}/>
|
|
|
);
|
|
|
}else if (rowData.get('template_name') == 'recommend_content_five') {
|
|
|
return (
|
|
|
<RecommendContentFive
|
|
|
resource={rowData}
|
|
|
// onPressRecommendItem={this.props.onPressRecommendItem}
|
|
|
/>
|
|
|
);
|
|
|
}else if (rowData.get('template_name') == 'recommend_content_one') {
|
|
|
return (
|
|
|
<RecommendContentOne
|
|
|
resource={rowData}
|
|
|
// onPressRecommendItem={this.props.onPressRecommendItem}
|
|
|
/>
|
|
|
);
|
|
|
}else if (rowData.get('template_name') == 'divideImage') {
|
|
|
let data = rowData.get('data').toJS();
|
|
|
let divideImage = getSlicedUrl(data[0].src, width, 20, 2);
|
|
|
if (!divideImage) {return null;}
|
|
|
return (
|
|
|
<Image
|
|
|
source={{uri: divideImage}}
|
|
|
style={{width: width,height: 20}}
|
|
|
resizeMode={'cover'}
|
|
|
></Image>
|
|
|
);
|
|
|
}else if (rowData.get('template_name') == 'small_pic') {
|
|
|
return (
|
|
|
<SmallPic
|
|
|
resource={rowData}
|
|
|
// onPressRecommendItem={this.props.onPressRecommendItem}
|
|
|
/>
|
|
|
);
|
|
|
}else if (rowData.get('template_name') == 'paramsGroup') {
|
|
|
let data = rowData.get('data');
|
|
|
return (
|
|
|
<View style={styles.title}>
|
|
|
<Text style={styles.text}>{data.get('title')}</Text>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
renderSectionHeader(sectionData, sectionID) {
|
|
|
if (sectionID == 'productList') {
|
|
|
let {groupInfo} = this.props.data;
|
|
|
return (
|
|
|
<SmallPic
|
|
|
resource={rowData}
|
|
|
<ProductFliter
|
|
|
resource={groupInfo}
|
|
|
// onPressRecommendItem={this.props.onPressRecommendItem}
|
|
|
/>
|
|
|
);
|
|
|
}else if (rowData.get('template_name') == 'paramsGroup') {
|
|
|
let data = rowData.get('data');
|
|
|
return (
|
|
|
<View style={styles.title}>
|
|
|
<Text style={styles.text}>{data.get('title')}</Text>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
...
|
...
|
@@ -117,10 +139,13 @@ export default class Home extends Component { |
|
|
}
|
|
|
|
|
|
render() {
|
|
|
let {list, ptr, isFetching, endReached} = this.props.data;
|
|
|
let dataSource = list.toArray();
|
|
|
let {list, ptr, isFetching, endReached,groupInfo} = this.props.data;
|
|
|
let isPullToRefresh = ptr && isFetching;
|
|
|
let isLoadingMore = dataSource.size != 0 && !ptr && isFetching;
|
|
|
let dataSource = {
|
|
|
topHeader: list.toArray(),
|
|
|
productList: groupInfo,
|
|
|
};
|
|
|
let isLoadingMore = list.toArray().size != 0 && !ptr && isFetching;
|
|
|
|
|
|
return (
|
|
|
<View style={styles.container}>
|
...
|
...
|
@@ -129,9 +154,10 @@ export default class Home extends Component { |
|
|
this.listView = c;
|
|
|
}}
|
|
|
contentContainerStyle={styles.contentContainer}
|
|
|
dataSource={this.dataSource.cloneWithRows(dataSource)}
|
|
|
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
|
|
|
renderRow={this._renderRow}
|
|
|
enableEmptySections={true}
|
|
|
renderSectionHeader={this.renderSectionHeader}
|
|
|
enablePullToRefresh={true}
|
|
|
isOnPullToRefresh={isPullToRefresh}
|
|
|
onRefreshData={() => {
|
...
|
...
|
@@ -160,7 +186,7 @@ let styles = StyleSheet.create({ |
|
|
justifyContent: 'center',
|
|
|
height: 39,
|
|
|
width:width,
|
|
|
backgroundColor: 'white',
|
|
|
backgroundColor: '#f0f0f0',
|
|
|
},
|
|
|
text: {
|
|
|
textAlign: 'center',
|
...
|
...
|
|