...
|
...
|
@@ -16,15 +16,13 @@ import ReactNative, { |
|
|
import LoadingIndicator from '../../../common/components/LoadingIndicator';
|
|
|
import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator';
|
|
|
import Immutable, {Map} from 'immutable';
|
|
|
import RecommendCell from './RecommendCell'
|
|
|
import BrandProductListCell from '../../../common/components/ListCell/ProductListCell';
|
|
|
import NewArrivalFilter from './NewArrivalFilter'
|
|
|
import NewArrivalCategoryList from './NewArrivalCategoryList'
|
|
|
import TagsCell from './TagsCell'
|
|
|
import ShopCell from './ShopCell'
|
|
|
import ArticleCell from './ArticleCell'
|
|
|
import FeaturedView from './FeaturedView'
|
|
|
import BannerCell from './BannerCell'
|
|
|
import NewArrivalHeader from './NewArrivalHeader';
|
|
|
|
|
|
export default class NewArrival extends Component {
|
|
|
|
...
|
...
|
@@ -34,6 +32,7 @@ export default class NewArrival extends Component { |
|
|
this._renderRow = this._renderRow.bind(this);
|
|
|
this._renderSectionHeader = this._renderSectionHeader.bind(this);
|
|
|
this._onPressProductFilter = this._onPressProductFilter.bind(this);
|
|
|
this._renderHeader = this._renderHeader.bind(this);
|
|
|
|
|
|
this.dataSource = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
...
|
...
|
@@ -62,148 +61,25 @@ export default class NewArrival extends Component { |
|
|
|
|
|
}
|
|
|
|
|
|
_renderHeader() {
|
|
|
let {
|
|
|
isFetching,
|
|
|
topPart,
|
|
|
} = this.props;
|
|
|
|
|
|
return (
|
|
|
<NewArrivalHeader
|
|
|
data={topPart}
|
|
|
onPressBanner={this.props.onPressBanner}
|
|
|
onPressShop={this.props.onPressShop}
|
|
|
goToRecommendForYou={this.props.goToRecommendForYou}
|
|
|
onPressCarouselItem={this.props.onPressCarouselItem}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
_renderRow(rowData, sectionID, rowID) {
|
|
|
switch (sectionID) {
|
|
|
case 'banner': {
|
|
|
return (
|
|
|
<View style={{width,height:132}}>
|
|
|
<BannerCell
|
|
|
style={styles.bannerImage}
|
|
|
width={width}
|
|
|
height={117}
|
|
|
data={rowData}
|
|
|
onPress={this.props.onPressBanner}
|
|
|
/>
|
|
|
<View style={styles.separator}/>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
break;
|
|
|
case 'recommend': {
|
|
|
return (
|
|
|
<RecommendCell
|
|
|
data={rowData}
|
|
|
onPressShop={this.props.onPressShop}
|
|
|
goToRecommendForYou={this.props.goToRecommendForYou}
|
|
|
/>
|
|
|
)
|
|
|
}
|
|
|
break;
|
|
|
case 'featured': {
|
|
|
let data = [];
|
|
|
for (var i = 0; i < rowData.size; i++) {
|
|
|
let src = rowData.get(i).get('src');
|
|
|
if (src) {
|
|
|
src = src.replace('{width}', width).replace('{height}', height).replace('{mode}',2);
|
|
|
data.push(src);
|
|
|
}
|
|
|
}
|
|
|
let featurelist = rowData?rowData.toJS():[];
|
|
|
|
|
|
if(data.length==1){
|
|
|
let yh_exposureData = list[0].yh_exposureData;
|
|
|
return (
|
|
|
<View style={{
|
|
|
width,
|
|
|
height: Platform.OS === 'ios'? featuredHigh + 50 : featuredHigh + 65,
|
|
|
marginBottom: 15,
|
|
|
alignItems: 'center',
|
|
|
}}>
|
|
|
<Text style={styles.headerText} >
|
|
|
精选抢先看
|
|
|
</Text>
|
|
|
<TouchableOpacity
|
|
|
yh_exposureData={yh_exposureData}
|
|
|
activeOpacity={0.8}
|
|
|
onPress={() => {
|
|
|
let item = rowData.get(0);
|
|
|
let url = item.get('url');
|
|
|
this.props.onPressCarouselItem&&this.props.onPressCarouselItem(url);
|
|
|
}}
|
|
|
>
|
|
|
<Image
|
|
|
style={styles.carouselSectionImage}
|
|
|
source={{uri: data[0]}}
|
|
|
resizeMode={'cover'}
|
|
|
/>
|
|
|
</TouchableOpacity>
|
|
|
<View style={styles.separator}/>
|
|
|
</View>
|
|
|
)
|
|
|
}else if(data.length==2){
|
|
|
let yh_exposureData0 = list[0].yh_exposureData;
|
|
|
let yh_exposureData1 = list[1].yh_exposureData;
|
|
|
return (
|
|
|
<View style={{
|
|
|
width,
|
|
|
height: Platform.OS === 'ios'? (((width-48) / 2)*220)/330+58 : (((width-48) / 2)*220)/330+64,
|
|
|
}}>
|
|
|
<Text style={styles.headerText} >
|
|
|
精选抢先看
|
|
|
</Text>
|
|
|
<View style={{
|
|
|
width,
|
|
|
height: (((width-48) / 2)*220)/330,
|
|
|
flexDirection:'row',
|
|
|
marginLeft:8,
|
|
|
marginRight:8,
|
|
|
marginBottom:8,
|
|
|
}}>
|
|
|
<TouchableOpacity
|
|
|
activeOpacity={0.8}
|
|
|
yh_exposureData={yh_exposureData0}
|
|
|
onPress={() => {
|
|
|
let item = rowData.get(0);
|
|
|
let url = item.get('url');
|
|
|
this.props.onPressCarouselItem&&this.props.onPressCarouselItem(url);
|
|
|
}}
|
|
|
>
|
|
|
<Image
|
|
|
style={styles.carouselSection2Image}
|
|
|
source={{uri: data[0]}}
|
|
|
resizeMode={'cover'}
|
|
|
/>
|
|
|
</TouchableOpacity>
|
|
|
<TouchableOpacity
|
|
|
activeOpacity={0.8}
|
|
|
yh_exposureData={yh_exposureData1}
|
|
|
onPress={() => {
|
|
|
let item = rowData.get(1);
|
|
|
let url = item.get('url');
|
|
|
this.props.onPressCarouselItem&&this.props.onPressCarouselItem(url);
|
|
|
}}
|
|
|
>
|
|
|
<Image
|
|
|
style={styles.carouselSection2Image}
|
|
|
source={{uri: data[1]}}
|
|
|
resizeMode={'cover'}
|
|
|
/>
|
|
|
</TouchableOpacity>
|
|
|
</View>
|
|
|
<View style={styles.separator}/>
|
|
|
</View>
|
|
|
)
|
|
|
}else{
|
|
|
return (
|
|
|
<View style={{
|
|
|
width,
|
|
|
height: 181,
|
|
|
}}>
|
|
|
<FeaturedView
|
|
|
style={styles.carouselSection}
|
|
|
items={featurelist}
|
|
|
onClick={(info) => {
|
|
|
let item = rowData.get(info.index);
|
|
|
let url = item.get('url');
|
|
|
this.props.onPressCarouselItem&&this.props.onPressCarouselItem(url);
|
|
|
}}
|
|
|
/>
|
|
|
<View style={styles.separator}/>
|
|
|
</View>
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case 'latest': {
|
|
|
|
|
|
if (this.props.topPart.isFetching||!rowData) {
|
...
|
...
|
@@ -322,18 +198,9 @@ export default class NewArrival extends Component { |
|
|
recommendForYou,
|
|
|
} = this.props;
|
|
|
|
|
|
let banner = topPart.get('topList')&&topPart.get('topList').size?[topPart.get('topList')]:[];
|
|
|
let latest = productList.get('list')&&productList.get('list').size?productList.get('list').toArray():[0];
|
|
|
let recommend = [];
|
|
|
if (topPart.get('brandList')&&topPart.get('brandList').size) {
|
|
|
recommend = [topPart.get('brandList')];
|
|
|
}
|
|
|
let featured = topPart.get('featuredList')&&topPart.get('featuredList').size?[topPart.get('featuredList')]:[];
|
|
|
|
|
|
let dataSource = {
|
|
|
banner,
|
|
|
recommend,
|
|
|
featured,
|
|
|
latest,
|
|
|
}
|
|
|
let isLoadingMore = productList.isFetching && productList.currentPage > 0;
|
...
|
...
|
@@ -351,6 +218,7 @@ export default class NewArrival extends Component { |
|
|
renderRow={this._renderRow}
|
|
|
enableEmptySections={true}
|
|
|
renderSectionHeader={this._renderSectionHeader}
|
|
|
renderHeader={this._renderHeader}
|
|
|
renderFooter={()=>{
|
|
|
if (endReached) {
|
|
|
return <View style={styles.placeholder} />;
|
...
|
...
|
@@ -376,7 +244,6 @@ export default class NewArrival extends Component { |
|
|
this.setState({showBackToTopButton: true});
|
|
|
}
|
|
|
}}
|
|
|
onEndReachedThreshold={2000}
|
|
|
/>
|
|
|
{productList.isFilter ?
|
|
|
<NewArrivalCategoryList
|
...
|
...
|
@@ -421,13 +288,12 @@ export default class NewArrival extends Component { |
|
|
let {width, height} = Dimensions.get('window');
|
|
|
width = Math.ceil(width);
|
|
|
height = Math.ceil(height);
|
|
|
let bannerHeight = Math.ceil((363 / 750) * width);
|
|
|
|
|
|
let yPosition = 0;
|
|
|
let rowWidth = Math.ceil(137.5 * width / 320);
|
|
|
let rowHeight = Math.ceil(254 * width / 320);
|
|
|
let rowMarginTop = Math.ceil(10 * width / 320);
|
|
|
let rowMarginHorizontal = (width - rowWidth * 2) / 3;
|
|
|
let featuredHigh=Math.ceil(((width-30)*220)/690);
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
...
|
...
|
@@ -435,16 +301,6 @@ let styles = StyleSheet.create({ |
|
|
width: width,
|
|
|
height: height - 64,
|
|
|
},
|
|
|
bannerImage: {
|
|
|
width: width,
|
|
|
height: 117,
|
|
|
backgroundColor: 'gray',
|
|
|
},
|
|
|
separator: {
|
|
|
width: width,
|
|
|
height: 15,
|
|
|
backgroundColor: '#f0f0f0',
|
|
|
},
|
|
|
placeholder: {
|
|
|
width,
|
|
|
height: 15,
|
...
|
...
|
@@ -456,26 +312,6 @@ let styles = StyleSheet.create({ |
|
|
flexDirection: 'row',
|
|
|
flexWrap: 'wrap',
|
|
|
},
|
|
|
carouselSection: {
|
|
|
width,
|
|
|
height: 166,
|
|
|
},
|
|
|
carouselSectionImage:{
|
|
|
width:width-30,
|
|
|
height: featuredHigh,
|
|
|
marginLeft:8,
|
|
|
marginRight:8,
|
|
|
marginBottom:8,
|
|
|
borderRadius:3,
|
|
|
},
|
|
|
carouselSection2Image:{
|
|
|
width:(width-48) / 2,
|
|
|
height: (((width-48) / 2)*220)/330,
|
|
|
flex:1,
|
|
|
marginLeft:8,
|
|
|
marginRight:8,
|
|
|
borderRadius:3,
|
|
|
},
|
|
|
brandFilterContainer: {
|
|
|
marginLeft: -1,
|
|
|
width: width + 2,
|
...
|
...
|
@@ -488,12 +324,4 @@ let styles = StyleSheet.create({ |
|
|
width: 44,
|
|
|
height: 44,
|
|
|
},
|
|
|
headerText: {
|
|
|
fontSize: 14,
|
|
|
color: 'black',
|
|
|
width: width,
|
|
|
textAlign: 'center',
|
|
|
marginTop:10,
|
|
|
marginBottom:10,
|
|
|
},
|
|
|
}); |
...
|
...
|
|