Authored by 张丽霞

秒杀商品列表页接口调整,review by redding

... ... @@ -18,18 +18,18 @@ export default class ProductListView extends Component {
constructor(props) {
super(props);
this._renderRow = this._renderRow.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1.key != r2.key,
});
this._renderSeparator = this._renderSeparator.bind(this);
this.tipMessage = '';
this.state = {
selectedIndex: 0,
};
}
_renderRow(rowData, sectionID, rowID) {
render() {
let {
rowData,
tipMessage,
} = this.props;
this.tipMessage = tipMessage;
let brandIconUrl = SlicedImage.getSlicedUrl(rowData.defaultImages, 152, 203, 2);
let tipState='';
let btnBgColor = '#d30018';
... ... @@ -53,7 +53,7 @@ export default class ProductListView extends Component {
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.onPressProductItem && this.props.onPressProductItem(rowData);
}}>
<View key={'row' + rowID} style={styles.rowContainer}>
<View style={styles.rowContainer}>
<Image style={styles.leftImage} source={{uri: brandIconUrl}} />
<View style={styles.rowRight}>
... ... @@ -110,37 +110,6 @@ export default class ProductListView extends Component {
</TouchableOpacity>
);
}
_renderSeparator(sectionID, rowID, adjacentRowHighlighted) {
return (
<View key={'sep' + rowID} style={styles.separator}>
</View>
);
}
render() {
let {
resource,
tipMessage,
} = this.props;
this.tipMessage = tipMessage;
let backgroundWidth = width;
let backgroundHeight = 64 + 20 + resource.length * rowHeight;
return (
<View style={{width: backgroundWidth, height: backgroundHeight, backgroundColor: '#f0f0f0'}}>
<ListView
contentContainerStyle={[styles.contentContainer]}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(resource)}
renderRow={this._renderRow}
renderSeparator={this._renderSeparator}
scrollEnabled={false}
scrollsToTop={false}
/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
... ... @@ -150,21 +119,9 @@ let rowHeight = backgroundHeight;
let imageWidth= 76;
let imageHeight = 101;
let styles = StyleSheet.create({
container: {
marginLeft: -1,
width: width + 2,
height: backgroundHeight,
borderTopColor: 'transparent',
borderBottomColor: '#e5e5e5',
borderWidth: 0.5,
backgroundColor:'white',
},
contentContainer: {
flexDirection: 'column',
},
rowContainer: {
flexDirection: 'row',
height: rowHeight,
height: 121,
backgroundColor:'white',
},
leftImage: {
... ... @@ -219,11 +176,6 @@ let styles = StyleSheet.create({
height: 25,
top: 10,
},
separator: {
width: width,
height: 1.5,
backgroundColor: '#e5e5e5',
},
productTitle: {
fontSize: 14,
color: '#444444',
... ...
... ... @@ -26,6 +26,7 @@ export default class Seckill extends Component {
this.renderRow = this.renderRow.bind(this);
this.renderSectionHeader = this.renderSectionHeader.bind(this);
this._renderSeparator = this._renderSeparator.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2),
... ... @@ -53,10 +54,9 @@ export default class Seckill extends Component {
componentWillReceiveProps(nextProps) {
if (nextProps.tipMessage && nextProps.tipMessage !== '') {
this._showToast && this._showToast(nextProps.tipMessage);
console.log(nextProps.tipMessage);
}
}
_showToast = (message) => {
if (this.toast) {
return;
... ... @@ -93,24 +93,25 @@ export default class Seckill extends Component {
}
}
renderRow(rowData, sectionID, rowID, highlightRow) {
if (Array.isArray(rowData) && rowData.length == 0 && !this.isFetching) {
switch (rowID) {
case 'ActivityProductList':
return (
<View style={styles.seckillEndView}>
<Text style={{fontSize:16}}>来晚啦~秒杀已结束</Text>
</View>
);
default:
}
_renderSeparator(sectionID, rowID, adjacentRowHighlighted) {
return (
<View key={'sep' + rowID} style={styles.separator}>
</View>
);
}
renderRow(rowData, sectionID, rowID, highlightRow) {
if (this.queryActivityInfo.secKillProductVoList.size == 0 && !this.isFetching) {
return (
<View style={styles.seckillEndView}>
<Text style={{fontSize:16}}>来晚啦~秒杀已结束</Text>
</View>
);
}
if (sectionID == 'ActivityProductList') {
return(
<ProductListView
resource={rowData}
rowData={rowData}
onPressProductItem={this.props.onPressProductItem}
onPressRemindBtn={this.props.onPressRemindBtn}
tipMessage={this.tipMessage}
... ... @@ -138,7 +139,7 @@ export default class Seckill extends Component {
this.tipMessage = tipMessage;
diff = localServerTimeDiff;
let dataSource = {
ActivityProductList: [queryProductList ? queryProductList : []],
ActivityProductList: queryProductList ? queryProductList : [],
};
let isPullToRefresh = ptr && isFetching;
return (
... ... @@ -159,6 +160,7 @@ export default class Seckill extends Component {
this.props.onRefresh && this.props.onRefresh();
}}
renderSectionHeader={this.renderSectionHeader}
renderSeparator={this._renderSeparator}
renderFooter={()=>{
return <View style={styles.descriptionContainer}>
<Text style={styles.descriptionText}>秒杀活动说明</Text>
... ... @@ -188,6 +190,7 @@ export default class Seckill extends Component {
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
renderRow={this.renderRow}
enablePullToRefresh={true}
renderSeparator={this._renderSeparator}
isOnPullToRefresh={isPullToRefresh}
onRefreshData={() => {
//强制刷新数据
... ... @@ -230,7 +233,7 @@ let styles = StyleSheet.create({
},
contentContainer:{
flexDirection: 'row',
flexDirection: 'column',
flexWrap: 'wrap',
},
seckillEndView: {
... ... @@ -251,7 +254,7 @@ let styles = StyleSheet.create({
borderWidth: 0.5,
},
descriptionContainer: {
marginTop: -40,
marginTop: 10,
marginBottom: 50,
marginLeft: 15,
},
... ... @@ -261,4 +264,9 @@ let styles = StyleSheet.create({
width: width - 20,
},
separator: {
width: width,
height: 1.5,
backgroundColor: '#e5e5e5',
},
});
... ...
... ... @@ -41,13 +41,10 @@ export default class SeckillTimeListView extends Component {
_scrollToFocusActivity = () => {
//focus
if (this.secKillProductVoList.length >= 1) {
console.log('------>_scrollToFocusActivity');
let listLength = this.secKillProductVoList.length;
let scrollX = 0;
scrollX = (this.curFocusActivity.get('index') - 1) * (rowContainerWidth + separatorWidth);
this.listView && this.listView.scrollTo({x: scrollX, y: 0, animated: true});
console.log('<<<<<<<<<_scrollToFocusActivity');
console.log(scrollX);
}
}
... ...