...
|
...
|
@@ -14,6 +14,7 @@ import ReactNative, { |
|
|
} from 'react-native';
|
|
|
import Immutable, {Map} from 'immutable';
|
|
|
import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator';
|
|
|
import HeadTitleCell from '../cell/HeadTitleCell';
|
|
|
|
|
|
import Focus from '../floor/Focus';
|
|
|
import AppIconList from '../floor/AppIconList';
|
...
|
...
|
@@ -40,7 +41,7 @@ import NewUserFloor from '../floor/NewUserFloor'; |
|
|
import VipUserFloor from '../floor/VipUserFloor';
|
|
|
import ActivityProductFloor from '../floor/ActivityProductFloor';
|
|
|
import HotCategoryIndividualization from '../floor/HotCategoryIndividualization';
|
|
|
import BrandProductListCell from '../../../common/components/ListCell/ProductListCell';
|
|
|
import ProductListCell from '../../../common/components/ListCell/ProductListCell';
|
|
|
|
|
|
export default class Home extends Component {
|
|
|
|
...
|
...
|
@@ -52,6 +53,7 @@ export default class Home extends Component { |
|
|
this.trigggePullToRefresh = this.trigggePullToRefresh.bind(this);
|
|
|
this._floorCellRender = this._floorCellRender.bind(this);
|
|
|
this._currentChannelData = this._currentChannelData.bind(this);
|
|
|
this._renderSectionHeader = this._renderSectionHeader.bind(this);
|
|
|
|
|
|
this.dataSource = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
...
|
...
|
@@ -98,21 +100,23 @@ export default class Home extends Component { |
|
|
case 'floor': {
|
|
|
return this._floorCellRender(rowData);
|
|
|
}
|
|
|
break;
|
|
|
case 'favoriteHeader': {
|
|
|
return (
|
|
|
<HeadTitleCell title={'你可能喜欢'}/>
|
|
|
);
|
|
|
}
|
|
|
case 'favorite': {
|
|
|
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
|
|
|
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft} : {paddingLeft};
|
|
|
|
|
|
// return (
|
|
|
// <BrandProductListCell
|
|
|
// style={[styles.listContainer, customStyle]}
|
|
|
// key={'row' + rowID}
|
|
|
// rowID={rowID}
|
|
|
// data={rowData}
|
|
|
// onPressProduct={this.props.onPressProductListProduct}
|
|
|
// />
|
|
|
// );
|
|
|
return null;
|
|
|
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal*1.5 : rowMarginHorizontal*2;
|
|
|
let customStyle = {paddingLeft};
|
|
|
return (
|
|
|
<ProductListCell
|
|
|
style={[styles.listContainer, customStyle]}
|
|
|
key={'row' + rowID}
|
|
|
rowID={rowID}
|
|
|
data={rowData}
|
|
|
onPressProduct={this.props.onPressProductListProduct}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
break;
|
|
|
case 'lifeStyleFav': {
|
...
|
...
|
@@ -296,11 +300,12 @@ export default class Home extends Component { |
|
|
case 'shopRecommend':{
|
|
|
let data = this._currentChannelData();
|
|
|
return (
|
|
|
<ShopRecommend
|
|
|
<ShopRecommend
|
|
|
data={rowData.get('data')}
|
|
|
favoriteState={data.shop}
|
|
|
onPressShopRecommendItem={this.props.onPressShopRecommendItem}
|
|
|
onPressShopFavorite={this.props.onPressShopFavorite}
|
|
|
onPressShopFavorite={this.props.onPressShopFavorite}
|
|
|
onPressTitleMore={this.props.onPressTitleMore}
|
|
|
/>
|
|
|
)
|
|
|
}
|
...
|
...
|
@@ -367,6 +372,18 @@ export default class Home extends Component { |
|
|
);
|
|
|
}
|
|
|
|
|
|
_renderSectionHeader(sectionData, sectionID) {
|
|
|
let floor = [];
|
|
|
if (sectionID == 'floor') {
|
|
|
floor = sectionData;
|
|
|
}
|
|
|
if (sectionID == 'lifeStyleFav') {
|
|
|
|
|
|
}else {
|
|
|
return null
|
|
|
}
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
let channel = this.props.channel;
|
|
|
let data = this._currentChannelData();
|
...
|
...
|
@@ -386,6 +403,7 @@ export default class Home extends Component { |
|
|
let favoriteList = favorite.get('list');
|
|
|
dataSource = {
|
|
|
floor: floorList,
|
|
|
favoriteHeader: ['1'],
|
|
|
favorite: favoriteList.toArray()
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -401,6 +419,8 @@ export default class Home extends Component { |
|
|
contentContainerStyle={styles.contentContainer}
|
|
|
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
|
|
|
renderRow={this._renderRow}
|
|
|
renderSectionHeader={this._renderSectionHeader}
|
|
|
removeClippedSubviews={true}
|
|
|
enableEmptySections={true}
|
|
|
enablePullToRefresh={true}
|
|
|
isOnPullToRefresh={isPullToRefresh}
|
...
|
...
|
@@ -419,16 +439,16 @@ export default class Home extends Component { |
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
let rowWidth = Math.ceil(137.5 * width / 320);
|
|
|
let rowMarginHorizontal = (width - rowWidth * 2) / 3;
|
|
|
let rowMarginHorizontal = Math.ceil((width - rowWidth * 2)/7);
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
|
|
flex: 1,
|
|
|
backgroundColor: '#f0f0f0',
|
|
|
width: width,
|
|
|
backgroundColor: 'white',
|
|
|
},
|
|
|
contentContainer: {
|
|
|
|
|
|
flexDirection: 'row',
|
|
|
flexWrap: 'wrap',
|
|
|
},
|
|
|
listContainer: {
|
|
|
width: width / 2,
|
...
|
...
|
|