...
|
...
|
@@ -14,15 +14,14 @@ import ReactNative, { |
|
|
Animated,
|
|
|
LayoutAnimation,
|
|
|
Platform,
|
|
|
InteractionManager,
|
|
|
InteractionManager
|
|
|
} from 'react-native';
|
|
|
import immutable from 'immutable';
|
|
|
import HotCategoryList from './HotCategoryList';
|
|
|
import HotBrandList from './HotBrandList';
|
|
|
import YH_Image from '../../../common/components/YH_Image';
|
|
|
import YH_PtrRefresh from '../../../common/components/YH_PtrRefresh';
|
|
|
|
|
|
|
|
|
import HotRecommendList from './HotRecommendList'
|
|
|
|
|
|
export default class CategoryBList extends Component {
|
|
|
|
...
|
...
|
@@ -35,7 +34,9 @@ export default class CategoryBList extends Component { |
|
|
this.trigggePullToRefresh = this.trigggePullToRefresh.bind(this);
|
|
|
this.stopPullToRefresh = this.stopPullToRefresh.bind(this);
|
|
|
|
|
|
this.dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => !immutable.is(r1, r2)});
|
|
|
this.dataSource = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => !immutable.is(r1, r2)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
trigggePullToRefresh(categoryId, categoryValue) {
|
...
|
...
|
@@ -66,50 +67,63 @@ export default class CategoryBList extends Component { |
|
|
}
|
|
|
let tabName = this.props.currentChannelValue;
|
|
|
let tabID = 0;
|
|
|
if (tabName == 'boy') {
|
|
|
tabID = '1';
|
|
|
}else if (tabName == 'girl') {
|
|
|
tabID = '2';
|
|
|
}else if (tabName == 'kid') {
|
|
|
tabID = '3';
|
|
|
}else if (tabName == 'leftStyle') {
|
|
|
tabID = '4';
|
|
|
}
|
|
|
if (tabName == 'boy') {
|
|
|
tabID = '1';
|
|
|
} else if (tabName == 'girl') {
|
|
|
tabID = '2';
|
|
|
} else if (tabName == 'kid') {
|
|
|
tabID = '3';
|
|
|
} else if (tabName == 'leftStyle') {
|
|
|
tabID = '4';
|
|
|
}
|
|
|
|
|
|
switch (rowID) {
|
|
|
case 'bannerInfo':
|
|
|
{
|
|
|
let data = rowData.get(0).get("data").get(0);
|
|
|
if(data){
|
|
|
if (data) {
|
|
|
let imageSrc = getSlicedUrl(data.get("src"), 400, 125, 2);
|
|
|
let url = data.get("url");
|
|
|
let params = {
|
|
|
P_NAME : pageName,
|
|
|
TAB_ID : tabID,
|
|
|
TAB_NAME : tabName,
|
|
|
F_ID : 1001,
|
|
|
F_INDEX : 1,
|
|
|
ACTION_URL : url,
|
|
|
exposureEnd : 1,
|
|
|
P_NAME: pageName,
|
|
|
TAB_ID: tabID,
|
|
|
TAB_NAME: tabName,
|
|
|
F_ID: 1001,
|
|
|
F_INDEX: 1,
|
|
|
ACTION_URL: url,
|
|
|
exposureEnd: 1
|
|
|
};
|
|
|
return(
|
|
|
return (
|
|
|
<TouchableOpacity yh_exposureData={params} activeOpacity={0.8} onPress={() => {
|
|
|
this.props.onPressBannerResourceItem && this.props.onPressBannerResourceItem(url)}}>
|
|
|
this.props.onPressBannerResourceItem && this.props.onPressBannerResourceItem(url)
|
|
|
}}>
|
|
|
<YH_Image style={styles.banner} url={imageSrc}/>
|
|
|
</TouchableOpacity>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
case 'salesInfo':
|
|
|
{
|
|
|
let params = {};
|
|
|
return (
|
|
|
<HotRecommendList
|
|
|
yh_exposureData={params}
|
|
|
title={'热门推荐'}
|
|
|
data={rowData}
|
|
|
onPressHotRecommendItem={this.props.onPressHotRecommendItem}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
case 'sortInfo':
|
|
|
{
|
|
|
let hotTitle = "全部" + this.props.currentCateValue;
|
|
|
let params = {
|
|
|
P_NAME : pageName,
|
|
|
TAB_ID : tabID,
|
|
|
TAB_NAME : tabName,
|
|
|
F_ID : 1002,
|
|
|
F_INDEX : 2,
|
|
|
exposureEnd : 1,
|
|
|
P_NAME: pageName,
|
|
|
TAB_ID: tabID,
|
|
|
TAB_NAME: tabName,
|
|
|
F_ID: 1002,
|
|
|
F_INDEX: 2,
|
|
|
exposureEnd: 1
|
|
|
};
|
|
|
return (
|
|
|
<HotCategoryList
|
...
|
...
|
@@ -117,26 +131,28 @@ export default class CategoryBList extends Component { |
|
|
title={hotTitle}
|
|
|
data={rowData}
|
|
|
onPressCategoryBMore={this.props.onPressCategoryBMore}
|
|
|
onPressHotCategoryItem={this.props.onPressHotCategoryItem}/>
|
|
|
onPressHotCategoryItem={this.props.onPressHotCategoryItem}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
case 'brandInfo':
|
|
|
{
|
|
|
let params = {
|
|
|
P_NAME : pageName,
|
|
|
TAB_ID : tabID,
|
|
|
TAB_NAME : tabName,
|
|
|
F_ID : 1003,
|
|
|
F_INDEX : 3,
|
|
|
exposureEnd : 1,
|
|
|
P_NAME: pageName,
|
|
|
TAB_ID: tabID,
|
|
|
TAB_NAME: tabName,
|
|
|
F_ID: 1003,
|
|
|
F_INDEX: 3,
|
|
|
exposureEnd: 1
|
|
|
};
|
|
|
return(
|
|
|
<HotBrandList
|
|
|
yh_exposureData={params}
|
|
|
hottype={"brand"}
|
|
|
data={rowData}
|
|
|
onPressHotBrandItem={this.props.onPressHotBrandItem}/>
|
|
|
);
|
|
|
return (
|
|
|
<HotBrandList
|
|
|
yh_exposureData={params}
|
|
|
hottype={"brand"}
|
|
|
data={rowData}
|
|
|
onPressHotBrandItem={this.props.onPressHotBrandItem}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
default:
|
...
|
...
|
@@ -146,20 +162,37 @@ export default class CategoryBList extends Component { |
|
|
}
|
|
|
|
|
|
renderRow(rowData, sectionID, rowID, highlightRow) {
|
|
|
let selectText = rowData ? rowData.get('category_name') : "";
|
|
|
let selectId = rowData ? rowData.get('category_id') : "";
|
|
|
|
|
|
let selectBg = this.props.currentCateId == selectId ? {backgroundColor: '#ffffff'} : {backgroundColor: '#f0f0f0'};
|
|
|
let selectText = rowData
|
|
|
? rowData.get('category_name')
|
|
|
: "";
|
|
|
let selectId = rowData
|
|
|
? rowData.get('category_id')
|
|
|
: "";
|
|
|
let selected = this.props.currentCateId == selectId;
|
|
|
let selectBg = selected
|
|
|
? {backgroundColor: '#ffffff'}
|
|
|
: {backgroundColor: '#f5f7f6'};
|
|
|
let titleColor = selected
|
|
|
? '#444444'
|
|
|
: '#b0b0b0';
|
|
|
let titleFont = selected
|
|
|
? 15
|
|
|
: 13;
|
|
|
|
|
|
return (
|
|
|
<TouchableOpacity
|
|
|
activeOpacity={1}
|
|
|
onPress={() => {
|
|
|
this.props.onSelectCategory && this.props.onSelectCategory(rowData.toJS());
|
|
|
}}
|
|
|
>
|
|
|
<View style={[styles.row, selectBg]} >
|
|
|
<Text style={styles.title} numberOfLines={1}>
|
|
|
<TouchableOpacity activeOpacity={1} onPress={() => {
|
|
|
this.props.onSelectCategory && this.props.onSelectCategory(rowData.toJS());
|
|
|
}}>
|
|
|
<View style={[styles.row, selectBg]}>
|
|
|
{selected
|
|
|
? <View style={styles.verticalBar}/>
|
|
|
: null}
|
|
|
<Text style={[
|
|
|
styles.title, {
|
|
|
color: titleColor,
|
|
|
fontSize: titleFont
|
|
|
}
|
|
|
]} numberOfLines={1}>
|
|
|
{selectText}
|
|
|
</Text>
|
|
|
</View>
|
...
|
...
|
@@ -167,27 +200,34 @@ export default class CategoryBList extends Component { |
|
|
);
|
|
|
}
|
|
|
|
|
|
|
|
|
renderSeparator(sectionID, rowID, adjacentRowHighlighted) {
|
|
|
return (
|
|
|
<View key={'sep' + rowID} style={styles.separator}></View>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
let {categoryList, currentCateId, currentCateValue, currentSubCateData, contentFetching} = this.props;
|
|
|
|
|
|
if(!categoryList || categoryList.length == 0 || !currentSubCateData || currentSubCateData.length == 0)
|
|
|
if (!categoryList || categoryList.length == 0 || !currentSubCateData || currentSubCateData.length == 0)
|
|
|
return;
|
|
|
|
|
|
let cateList = categoryList.get(this.props.currentChannelValue) ? categoryList.get(this.props.currentChannelValue).toArray() : [];
|
|
|
let cateList = categoryList.get(this.props.currentChannelValue)
|
|
|
? categoryList.get(this.props.currentChannelValue).toArray()
|
|
|
: [];
|
|
|
|
|
|
let detailDataSource = {
|
|
|
bannerInfo: currentSubCateData.get('bannerInfo'),
|
|
|
sortInfo: currentSubCateData.get('sortInfo') ? currentSubCateData.get('sortInfo').toArray() : [],
|
|
|
brandInfo: currentSubCateData.get('brandInfo') ? currentSubCateData.get('brandInfo').toArray() : [],
|
|
|
salesInfo: currentSubCateData.get('salesInfo')
|
|
|
? currentSubCateData.get('salesInfo').toArray()
|
|
|
: [],
|
|
|
sortInfo: currentSubCateData.get('sortInfo')
|
|
|
? currentSubCateData.get('sortInfo').toArray()
|
|
|
: [],
|
|
|
brandInfo: currentSubCateData.get('brandInfo')
|
|
|
? currentSubCateData.get('brandInfo').toArray()
|
|
|
: []
|
|
|
};
|
|
|
|
|
|
let isPullToRefresh = contentFetching;
|
...
|
...
|
@@ -204,9 +244,8 @@ export default class CategoryBList extends Component { |
|
|
renderSeparator={this.renderSeparator}
|
|
|
scrollsToTop={false}
|
|
|
/>
|
|
|
{
|
|
|
Platform.OS === 'ios' ?
|
|
|
<ListView
|
|
|
{Platform.OS === 'ios'
|
|
|
? <ListView
|
|
|
ref='subCategoryList'
|
|
|
style={styles.subContentContainer}
|
|
|
dataSource={this.dataSource.cloneWithRows(detailDataSource)}
|
...
|
...
|
@@ -221,44 +260,45 @@ export default class CategoryBList extends Component { |
|
|
isOnPullToRefresh={isPullToRefresh}
|
|
|
yh_viewVisible={true}
|
|
|
onFinishRefreshData={() => {
|
|
|
this.refs.subCategoryList && this.refs.subCategoryList.yh_updateVisibleSubViews && this.refs.subCategoryList.yh_updateVisibleSubViews();//ios 专用
|
|
|
}}//ios 专用
|
|
|
this.refs.subCategoryList && this.refs.subCategoryList.yh_updateVisibleSubViews && this.refs.subCategoryList.yh_updateVisibleSubViews();
|
|
|
}}
|
|
|
onRefreshData={() => {
|
|
|
this.props.onRefresh && this.props.onRefresh(currentCateId, currentCateValue);
|
|
|
this.props.onRefresh && this.props.onRefresh(currentCateId, currentCateValue);
|
|
|
}}
|
|
|
/>
|
|
|
:
|
|
|
<ListView
|
|
|
ref='subCategoryList'
|
|
|
style={styles.subContentContainer}
|
|
|
dataSource={this.dataSource.cloneWithRows(detailDataSource)}
|
|
|
enableEmptySections={true}
|
|
|
renderRow={this.subRenderRow}
|
|
|
onPressBannerResourceItem={this.props.onPressBannerResourceItem}
|
|
|
onPressCategoryBMore={this.props.onPressCategoryBMore}
|
|
|
onPressHotCategoryItem={this.props.onPressHotCategoryItem}
|
|
|
onPressHotBrandItem={this.props.onPressHotBrandItem}
|
|
|
scrollsToTop={false}
|
|
|
enablePullToRefresh={true}
|
|
|
isOnPullToRefresh={isPullToRefresh}
|
|
|
yh_viewVisible={true}
|
|
|
refreshControl={
|
|
|
<YH_PtrRefresh
|
|
|
refreshing={isPullToRefresh}
|
|
|
onRefresh={() => {
|
|
|
: <ListView
|
|
|
ref='subCategoryList'
|
|
|
style={styles.subContentContainer}
|
|
|
dataSource={this.dataSource.cloneWithRows(detailDataSource)}
|
|
|
enableEmptySections={true}
|
|
|
renderRow={this.subRenderRow}
|
|
|
onPressBannerResourceItem={this.props.onPressBannerResourceItem}
|
|
|
onPressCategoryBMore={this.props.onPressCategoryBMore}
|
|
|
onPressHotCategoryItem={this.props.onPressHotCategoryItem}
|
|
|
onPressHotBrandItem={this.props.onPressHotBrandItem}
|
|
|
scrollsToTop={false}
|
|
|
enablePullToRefresh={true}
|
|
|
isOnPullToRefresh={isPullToRefresh}
|
|
|
yh_viewVisible={true}
|
|
|
refreshControl={
|
|
|
< YH_PtrRefresh
|
|
|
refreshing = {isPullToRefresh}
|
|
|
onRefresh = {
|
|
|
() => {
|
|
|
this.props.onRefresh && this.props.onRefresh(currentCateId, currentCateValue);
|
|
|
}}
|
|
|
/>
|
|
|
}
|
|
|
/>
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/>
|
|
|
}
|
|
|
/>
|
|
|
}
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
const DEVICE_WIDTH_RATIO = width / 320;
|
|
|
const DEVICE_WIDTH_RATIO = width / 375;
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
...
|
...
|
@@ -266,46 +306,48 @@ let styles = StyleSheet.create({ |
|
|
flexDirection: 'row',
|
|
|
width: width,
|
|
|
height: height - 156,
|
|
|
backgroundColor: 'white',
|
|
|
backgroundColor: 'white'
|
|
|
},
|
|
|
contentContainer: {
|
|
|
backgroundColor: '#f0f0f0',
|
|
|
width: 100 * DEVICE_WIDTH_RATIO,
|
|
|
height: height - 156,
|
|
|
backgroundColor: '#f5f7f6',
|
|
|
width: 102.5 * DEVICE_WIDTH_RATIO,
|
|
|
height: height - 156
|
|
|
},
|
|
|
subContentContainer: {
|
|
|
backgroundColor: 'white',
|
|
|
width: 215 * DEVICE_WIDTH_RATIO,
|
|
|
height: height - 156 - 5,
|
|
|
marginLeft: 5 * DEVICE_WIDTH_RATIO,
|
|
|
marginTop: 5 * DEVICE_WIDTH_RATIO,
|
|
|
paddingRight: 5 * DEVICE_WIDTH_RATIO,
|
|
|
width: width - 102.5 * DEVICE_WIDTH_RATIO,
|
|
|
height: height - 156
|
|
|
},
|
|
|
row: {
|
|
|
flexDirection: 'row',
|
|
|
alignItems: 'center',
|
|
|
height: 49.5 * DEVICE_WIDTH_RATIO,
|
|
|
width: 100 * DEVICE_WIDTH_RATIO,
|
|
|
paddingLeft: 12 * DEVICE_WIDTH_RATIO,
|
|
|
backgroundColor: '#f0f0f0',
|
|
|
height: 60 * DEVICE_WIDTH_RATIO,
|
|
|
width: 102.5 * DEVICE_WIDTH_RATIO,
|
|
|
backgroundColor: '#f0f0f0'
|
|
|
},
|
|
|
verticalBar: {
|
|
|
width: 4,
|
|
|
height: 60 * DEVICE_WIDTH_RATIO,
|
|
|
backgroundColor: '#444444'
|
|
|
},
|
|
|
separator: {
|
|
|
width: width,
|
|
|
height: 0.5 * DEVICE_WIDTH_RATIO,
|
|
|
backgroundColor: '#e0e0e0',
|
|
|
height: 1,
|
|
|
backgroundColor: 'white'
|
|
|
},
|
|
|
title: {
|
|
|
flex: 1,
|
|
|
fontSize: 15,
|
|
|
color: '#444444',
|
|
|
width: 102.5 * DEVICE_WIDTH_RATIO - 8,
|
|
|
textAlign: 'center'
|
|
|
},
|
|
|
banner:{
|
|
|
width: 200 * DEVICE_WIDTH_RATIO,
|
|
|
height: 62.5 * DEVICE_WIDTH_RATIO,
|
|
|
banner: {
|
|
|
width: 234 * DEVICE_WIDTH_RATIO,
|
|
|
height: 73 * DEVICE_WIDTH_RATIO,
|
|
|
backgroundColor: '#ffffff',
|
|
|
marginLeft: 5 * DEVICE_WIDTH_RATIO,
|
|
|
marginTop: 5 * DEVICE_WIDTH_RATIO,
|
|
|
marginRight: 5 * DEVICE_WIDTH_RATIO,
|
|
|
marginBottom: 10 * DEVICE_WIDTH_RATIO,
|
|
|
},
|
|
|
marginBottom: 10 * DEVICE_WIDTH_RATIO
|
|
|
}
|
|
|
}); |
...
|
...
|
|