...
|
...
|
@@ -21,6 +21,7 @@ export default class Recommend extends Component { |
|
|
super(props);
|
|
|
|
|
|
this.renderRow = this.renderRow.bind(this);
|
|
|
this._renderSectionHeader = this._renderSectionHeader.bind(this);
|
|
|
|
|
|
this.dataSource = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
...
|
...
|
@@ -30,6 +31,28 @@ export default class Recommend extends Component { |
|
|
this.listView = null;
|
|
|
}
|
|
|
|
|
|
_renderSectionHeader(sectionData, sectionID) {
|
|
|
switch (sectionID) {
|
|
|
case 'categoryList': {
|
|
|
let {productList} = this.props.data;
|
|
|
let selectedCategoryIndex = productList.selectedCategoryIndex;
|
|
|
let categoryList = productList.msort_list.unshift(hotRecommend);
|
|
|
return (
|
|
|
<CategorySelector
|
|
|
data={categoryList}
|
|
|
selectedCategoryIndex={selectedCategoryIndex}
|
|
|
onPressCategory={(rowData, rowID) => {
|
|
|
// this.listView && this.listView.scrollTo({x: 0, y: 0, animated: false});
|
|
|
this.props.onPressCategory && this.props.onPressCategory(rowData, rowID);
|
|
|
}}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
default:
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
renderRow(rowData, sectionID, rowID) {
|
|
|
let sliderHeight = 118 * DEVICE_WIDTH_RATIO;
|
|
|
let imageUrl = YH_Image.getSlicedUrl(this.props.src, width, sliderHeight, 2);
|
...
|
...
|
@@ -50,21 +73,7 @@ export default class Recommend extends Component { |
|
|
</TouchableOpacity>
|
|
|
);
|
|
|
}
|
|
|
case 'categoryList': {
|
|
|
let {productList} = this.props.data;
|
|
|
let selectedCategoryIndex = productList.selectedCategoryIndex;
|
|
|
let categoryList = productList.msort_list.unshift(hotRecommend);
|
|
|
return (
|
|
|
<CategorySelector
|
|
|
data={categoryList}
|
|
|
selectedCategoryIndex={selectedCategoryIndex}
|
|
|
onPressCategory={(rowData, rowID) => {
|
|
|
// this.listView && this.listView.scrollTo({x: 0, y: 0, animated: false});
|
|
|
this.props.onPressCategory && this.props.onPressCategory(rowData, rowID);
|
|
|
}}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
case 'productList': {
|
|
|
return (
|
|
|
<ProductCell
|
...
|
...
|
@@ -97,6 +106,7 @@ export default class Recommend extends Component { |
|
|
ref={(c) => {
|
|
|
this.listView = c;
|
|
|
}}
|
|
|
renderSectionHeader={this._renderSectionHeader}
|
|
|
enableEmptySections={true}
|
|
|
yh_viewVisible={true}
|
|
|
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
|
...
|
...
|
|