...
|
...
|
@@ -39,14 +39,7 @@ export default class Brand extends Component { |
|
|
this.listView = null;
|
|
|
this.sectionData = Map();
|
|
|
this.sectionDataKey = Map();
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
|
}
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
|
|
this.needScrollSection = 0;
|
|
|
}
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
...
|
...
|
@@ -54,11 +47,12 @@ export default class Brand extends Component { |
|
|
this.listView.scrollTo({x: 0, y: 0, animated: false});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
scrollToSection(index,sectionID){
|
|
|
let item = this.sectionDataKey[sectionID];
|
|
|
if (item) {
|
|
|
if (!item.y) {
|
|
|
needScrollSection = sectionID;
|
|
|
this.needScrollSection = sectionID;
|
|
|
item.count = ScrollCount(sectionID,this.sectionData);
|
|
|
this.props.setInitialListSize && this.props.setInitialListSize(item.count);
|
|
|
this.props.setBrandData && this.props.setBrandData(this.sectionDataKey,this.props.brandChannelFliter);
|
...
|
...
|
@@ -73,13 +67,13 @@ export default class Brand extends Component { |
|
|
if (this.sectionDataKey && this.sectionDataKey[sectionID].y != y) {
|
|
|
this.sectionDataKey[sectionID].y = y;
|
|
|
this.props.setBrandData && this.props.setBrandData(this.sectionDataKey,this.props.brandChannelFliter);
|
|
|
if (needScrollSection == sectionID) {
|
|
|
if (this.needScrollSection == sectionID) {
|
|
|
this.listView.scrollTo({x: 0, y, animated: false});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
renderHeader(){
|
|
|
renderHeader() {
|
|
|
return (
|
|
|
<View style={styles.header}>
|
|
|
<TouchableOpacity
|
...
|
...
|
@@ -106,16 +100,12 @@ export default class Brand extends Component { |
|
|
onPressFilter= {this.props.onPressFilter}
|
|
|
brandFliter={this.props.brandFliter}
|
|
|
/>
|
|
|
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
renderSectionHeader(sectionData, sectionID) {
|
|
|
let title = sectionID;
|
|
|
if (sectionID == '0-9') {
|
|
|
title = '0';
|
|
|
}
|
|
|
let title = sectionID == '0-9' ? '0' : sectionID;
|
|
|
return (
|
|
|
<View style={styles.sessionTitle} onLayout={this.onLayout.bind(this, sectionID)}>
|
|
|
<Text style={styles.sessionText}>{title}</Text>
|
...
|
...
|
@@ -128,7 +118,7 @@ export default class Brand extends Component { |
|
|
return (
|
|
|
<AllBrandListCell rowData={rowData} onPressSlideItem={this.props.onPressSlideItem}/>
|
|
|
);
|
|
|
}else {
|
|
|
} else {
|
|
|
return (
|
|
|
<NewHotBannerListCell rowData={rowData} onPressSlideItem={this.props.onPressSlideItem}/>
|
|
|
);
|
...
|
...
|
@@ -157,45 +147,49 @@ export default class Brand extends Component { |
|
|
let data;
|
|
|
|
|
|
if (brandChannelFliter == 1) {
|
|
|
data = brandListForBoy?brandListForBoy.toJS():null;
|
|
|
data = brandListForBoy;
|
|
|
} else if (brandChannelFliter == 2) {
|
|
|
data = brandListForGirl?brandListForGirl.toJS():null;
|
|
|
data = brandListForGirl;
|
|
|
} else if (brandChannelFliter == 3) {
|
|
|
data = brandListForKid?brandListForKid.toJS():null;
|
|
|
data = brandListForKid;
|
|
|
} else if (brandChannelFliter == 4) {
|
|
|
data = brandListForLifeStyle?brandListForLifeStyle.toJS():null;
|
|
|
data = brandListForLifeStyle;
|
|
|
}
|
|
|
|
|
|
let list;
|
|
|
let keys;
|
|
|
let listDataSource;
|
|
|
let contentContainerStyle;
|
|
|
let renderSectionHeader = null;
|
|
|
let showIndexForListView = false;
|
|
|
|
|
|
if (brandFliter == 0) {
|
|
|
list = data?data.all_list:null;
|
|
|
keys = data?data.all_list_key:null;
|
|
|
listDataSource = list?this.dataSource.cloneWithRowsAndSections(list):null;
|
|
|
list = data ? data.get('all_list') : null;
|
|
|
let newList = {};
|
|
|
list && list.map((value, key) => {
|
|
|
newList[key] = value.toArray();
|
|
|
});
|
|
|
listDataSource = newList ? this.dataSource.cloneWithRowsAndSections(newList) : null;
|
|
|
|
|
|
contentContainerStyle = styles.contentContainerOne;
|
|
|
renderSectionHeader = this.renderSectionHeader;
|
|
|
|
|
|
showIndexForListView = true;
|
|
|
this.sectionData = list;
|
|
|
this.sectionDataKey = keys;
|
|
|
this.sectionData = newList;
|
|
|
this.sectionDataKey = data.get('all_list_key').toJS();
|
|
|
} else if (brandFliter == 1) {
|
|
|
list = data?data.new_list:null;
|
|
|
listDataSource = list?this.dataSource.cloneWithRows(list):null;
|
|
|
list = data ? data.get('new_list') : null;
|
|
|
listDataSource = list ? this.dataSource.cloneWithRows(list.toArray()) : null;
|
|
|
contentContainerStyle = styles.contentContainerTwo;
|
|
|
} else if (brandFliter == 2) {
|
|
|
list = data?data.hot_list:null;
|
|
|
listDataSource = list?this.dataSource.cloneWithRows(list):null;
|
|
|
list = data ? data.get('hot_list') : null;
|
|
|
listDataSource = list ? this.dataSource.cloneWithRows(list.toArray()) : null;
|
|
|
contentContainerStyle = styles.contentContainerTwo;
|
|
|
}
|
|
|
|
|
|
if (!list) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<ChannelFliter selectID={brandChannelFliter} onChannelPressFliter={this.props.onChannelPressFliter}/>
|
...
|
...
|
@@ -212,7 +206,7 @@ export default class Brand extends Component { |
|
|
renderHeader={this.renderHeader}
|
|
|
/>
|
|
|
|
|
|
{showIndexForListView?<IndexListView dataSource={Object.keys(list)} onLetterPress={this.scrollToSection}/>: null}
|
|
|
{showIndexForListView ? <IndexListView dataSource={list.keySeq().toArray()} onLetterPress={this.scrollToSection}/> : null}
|
|
|
|
|
|
<LoadingIndicator
|
|
|
isVisible={isFetching}
|
...
|
...
|
@@ -230,14 +224,13 @@ export default class Brand extends Component { |
|
|
}
|
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
let needScrollSection = null;
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
|
|
flex: 1,
|
|
|
backgroundColor: 'white',
|
|
|
},
|
|
|
contentContainerOne:{
|
|
|
contentContainerOne: {
|
|
|
|
|
|
},
|
|
|
contentContainerTwo: {
|
...
|
...
|
@@ -261,6 +254,4 @@ let styles = StyleSheet.create({ |
|
|
width,
|
|
|
backgroundColor: '#e5e5e5',
|
|
|
},
|
|
|
search: {
|
|
|
},
|
|
|
}); |
...
|
...
|
|