...
|
...
|
@@ -47,6 +47,8 @@ import VipUserFloor from '../floor/VipUserFloor'; |
|
|
import ActivityProductFloor from '../floor/ActivityProductFloor';
|
|
|
import HotCategoryIndividualization from '../floor/HotCategoryIndividualization';
|
|
|
import ProductListCell from '../../../common/components/ListCell/ProductListCell';
|
|
|
import RecommendPopView from './RecommendPopView';
|
|
|
|
|
|
|
|
|
export default class Home extends Component {
|
|
|
|
...
|
...
|
@@ -59,6 +61,7 @@ export default class Home extends Component { |
|
|
this._floorCellRender = this._floorCellRender.bind(this);
|
|
|
this._currentChannelData = this._currentChannelData.bind(this);
|
|
|
this._renderSectionHeader = this._renderSectionHeader.bind(this);
|
|
|
this._autoScrollToProductList = this._autoScrollToProductList.bind(this);
|
|
|
|
|
|
this.dataSource = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
...
|
...
|
@@ -389,11 +392,16 @@ export default class Home extends Component { |
|
|
|
|
|
}
|
|
|
|
|
|
_autoScrollToProductList() {
|
|
|
this.props.onClickRecommendProduct&&this.props.onClickRecommendProduct()
|
|
|
}
|
|
|
|
|
|
_renderFooter() {
|
|
|
let data = this._currentChannelData();
|
|
|
let {isFetching, endReached, list, cached} = data;
|
|
|
let floorList = list.size > 0 ? list.toArray() : cached.get('list').toArray();
|
|
|
let isLoadingMore = !endReached && floorList.size != 0;
|
|
|
|
|
|
let isLoadingMore = !endReached && floorList.length != 0;
|
|
|
|
|
|
return (
|
|
|
<LoadMoreIndicator
|
...
|
...
|
@@ -423,66 +431,81 @@ export default class Home extends Component { |
|
|
render() {
|
|
|
let channel = this.props.channel;
|
|
|
let data = this._currentChannelData();
|
|
|
let {isFetching} = data;
|
|
|
let {isFetching, recommendProduct} = data;
|
|
|
let dataSource = floorParser.homeDataParse(data, channel);
|
|
|
|
|
|
let isPullToRefresh = isFetching;
|
|
|
|
|
|
let recommendData = recommendProduct.get('list').toArray();
|
|
|
let recommendVisible = recommendProduct.get('isVisible');
|
|
|
|
|
|
if (recommendData.length > 0) {
|
|
|
recommendData = recommendData[0];
|
|
|
} else {
|
|
|
recommendVisible = false;
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
{
|
|
|
Platform.OS === 'ios' ?
|
|
|
<ListView
|
|
|
ref={(c) => {
|
|
|
this.listView = c;
|
|
|
}}
|
|
|
contentContainerStyle={styles.contentContainer}
|
|
|
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
|
|
|
renderRow={this._renderRow}
|
|
|
renderSectionHeader={this._renderSectionHeader}
|
|
|
removeClippedSubviews={true}
|
|
|
enableEmptySections={true}
|
|
|
enablePullToRefresh={true}
|
|
|
isOnPullToRefresh={isPullToRefresh}
|
|
|
onRefreshData={() => {
|
|
|
this.props.onRefresh && this.props.onRefresh();
|
|
|
}}
|
|
|
onEndReached={() => {
|
|
|
this.props.onEndReached && this.props.onEndReached();
|
|
|
}}
|
|
|
renderFooter={this._renderFooter}
|
|
|
/>
|
|
|
:
|
|
|
<ListView
|
|
|
ref={(c) => {
|
|
|
this.listView = c;
|
|
|
}}
|
|
|
contentContainerStyle={styles.contentContainer}
|
|
|
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
|
|
|
renderRow={this._renderRow}
|
|
|
renderSectionHeader={this._renderSectionHeader}
|
|
|
removeClippedSubviews={true}
|
|
|
enableEmptySections={true}
|
|
|
enablePullToRefresh={true}
|
|
|
isOnPullToRefresh={isPullToRefresh}
|
|
|
refreshControl={
|
|
|
<RefreshControl
|
|
|
refreshing={false}
|
|
|
onRefresh={() => {
|
|
|
this.props.onRefresh && this.props.onRefresh();
|
|
|
}}
|
|
|
colors={['#000000', '#ff0000']}
|
|
|
progressBackgroundColor="#ffffff"
|
|
|
/>
|
|
|
}
|
|
|
onEndReached={() => {
|
|
|
this.props.onEndReached && this.props.onEndReached();
|
|
|
}}
|
|
|
renderFooter={this._renderFooter}
|
|
|
/>
|
|
|
}
|
|
|
|
|
|
{
|
|
|
Platform.OS === 'ios' ?
|
|
|
|
|
|
<ListView
|
|
|
ref={(c) => {
|
|
|
this.listView = c;
|
|
|
}}
|
|
|
contentContainerStyle={styles.contentContainer}
|
|
|
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
|
|
|
renderRow={this._renderRow}
|
|
|
renderSectionHeader={this._renderSectionHeader}
|
|
|
removeClippedSubviews={true}
|
|
|
enableEmptySections={true}
|
|
|
enablePullToRefresh={true}
|
|
|
isOnPullToRefresh={isPullToRefresh}
|
|
|
onRefreshData={() => {
|
|
|
this.props.onRefresh && this.props.onRefresh();
|
|
|
}}
|
|
|
onEndReached={() => {
|
|
|
this.props.onEndReached && this.props.onEndReached();
|
|
|
<RecommendPopView
|
|
|
data={recommendData}
|
|
|
isVisible={recommendVisible}
|
|
|
onPress={()=>{
|
|
|
this._autoScrollToProductList();
|
|
|
}}
|
|
|
renderFooter={this._renderFooter}
|
|
|
/>
|
|
|
:
|
|
|
<ListView
|
|
|
ref={(c) => {
|
|
|
this.listView = c;
|
|
|
}}
|
|
|
contentContainerStyle={styles.contentContainer}
|
|
|
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
|
|
|
renderRow={this._renderRow}
|
|
|
renderSectionHeader={this._renderSectionHeader}
|
|
|
removeClippedSubviews={true}
|
|
|
enableEmptySections={true}
|
|
|
enablePullToRefresh={true}
|
|
|
isOnPullToRefresh={isPullToRefresh}
|
|
|
refreshControl={
|
|
|
<RefreshControl
|
|
|
refreshing={false}
|
|
|
onRefresh={() => {
|
|
|
this.props.onRefresh && this.props.onRefresh();
|
|
|
}}
|
|
|
colors={['#000000', '#ff0000']}
|
|
|
progressBackgroundColor="#ffffff"
|
|
|
/>
|
|
|
}
|
|
|
onEndReached={() => {
|
|
|
this.props.onEndReached && this.props.onEndReached();
|
|
|
}}
|
|
|
renderFooter={this._renderFooter}
|
|
|
/>
|
|
|
}
|
|
|
</View>
|
|
|
);
|
|
|
}
|
...
|
...
|
@@ -529,5 +552,5 @@ let styles = StyleSheet.create({ |
|
|
height: 44,
|
|
|
marginTop: 15,
|
|
|
marginBottom: 15
|
|
|
}
|
|
|
},
|
|
|
}); |
...
|
...
|
|