...
|
...
|
@@ -25,6 +25,7 @@ export default class SeckillTimeListView extends Component { |
|
|
rowHasChanged: (r1, r2) => r1.key != r2.key,
|
|
|
});
|
|
|
this.curFocusActivity = Immutable.fromJS({});
|
|
|
this.secKillProductVoList = Immutable.fromJS([]);
|
|
|
this.state = {
|
|
|
selectedIndex: 0,
|
|
|
tickHour: '00',
|
...
|
...
|
@@ -48,8 +49,12 @@ export default class SeckillTimeListView extends Component { |
|
|
|
|
|
if (offsetTime <= 0) {
|
|
|
this.setState({
|
|
|
tickHour: '00',
|
|
|
tickMinute: '00',
|
|
|
tickSecond: '00',
|
|
|
tickTimeOut: true,
|
|
|
});
|
|
|
this.props.onPressTimeItem && this.props.onPressTimeItem(this.curFocusActivity.toJS());
|
|
|
} else {
|
|
|
this.setState({
|
|
|
tickHour: hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : hour),
|
...
|
...
|
@@ -60,6 +65,24 @@ export default class SeckillTimeListView extends Component { |
|
|
}
|
|
|
|
|
|
}.bind(this), 1000);
|
|
|
|
|
|
//focus
|
|
|
if (this.secKillProductVoList.length >= 1) {
|
|
|
let listLength = this.secKillProductVoList.length;
|
|
|
let curFocusIndex = 0;
|
|
|
let scrollX = 0;
|
|
|
this.secKillProductVoList.forEach((activityItem, i) => {
|
|
|
if (activityItem.get('activityId') === this.curFocusActivity.get('activityId')) {
|
|
|
curFocusIndex = i;
|
|
|
}
|
|
|
});
|
|
|
if (curFocusIndex > 1 && curFocusIndex < listLength-2) {
|
|
|
scrollX = (curFocusIndex - 1) * rowContainerWidth;
|
|
|
this.listView.scrollTo({x: scrollX, y: 0, animated: false});
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
componentWillUnmount() {
|
...
|
...
|
@@ -68,7 +91,7 @@ export default class SeckillTimeListView extends Component { |
|
|
|
|
|
_renderRow(rowData, sectionID, rowID) {
|
|
|
rowData = rowData.toJS();
|
|
|
let colorStyle = rowData.focus ? {color: '#ff0000'} : {color: '#b0b0b0'};
|
|
|
let colorStyle = rowData.focus ? {color: '#d30018'} : {color: '#3e3e3e'};
|
|
|
return (
|
|
|
<TouchableOpacity onPress={() => {
|
|
|
if (rowData.focus) {
|
...
|
...
|
@@ -82,7 +105,7 @@ export default class SeckillTimeListView extends Component { |
|
|
<View key={'row' + rowID} style={styles.rowContainerFocus}>
|
|
|
{rowData.now ?
|
|
|
<View key={'row' + rowID} style={styles.rowContainerFocus}>
|
|
|
<Text style={colorStyle}>{rowData.time} 抢购中</Text>
|
|
|
<Text style={[colorStyle,{fontSize: 13}]}>{rowData.time} 抢购中</Text>
|
|
|
{!this.state.tickTimeOut ?
|
|
|
<View style={styles.tickTimeContainer}>
|
|
|
<Text style={colorStyle}>剩余:</Text>
|
...
|
...
|
@@ -100,13 +123,13 @@ export default class SeckillTimeListView extends Component { |
|
|
</View>
|
|
|
: null}
|
|
|
|
|
|
{rowData.over ? <Text style={colorStyle}>{rowData.time} 已开抢</Text> : null}
|
|
|
{rowData.over ? <Text style={[colorStyle,{fontSize: 10}]}>{rowData.time} 已开抢</Text> : null}
|
|
|
{rowData.wait ?
|
|
|
<View key={'row' + rowID} style={styles.rowContainerFocus}>
|
|
|
<Text style={colorStyle}>{rowData.time} 即将开抢</Text>
|
|
|
<Text style={[colorStyle,{fontSize: 13}]}>{rowData.time} 即将开抢</Text>
|
|
|
{!this.state.tickTimeOut ?
|
|
|
<View style={styles.tickTimeContainer}>
|
|
|
<Text style={colorStyle}>距开抢:</Text>
|
|
|
<Text style={[colorStyle,{fontSize: 10}]}>距开抢:</Text>
|
|
|
<View style={styles.tickTime}>
|
|
|
<Text style={styles.tickTimeText}>{this.state.tickHour}</Text>
|
|
|
</View>
|
...
|
...
|
@@ -122,10 +145,10 @@ export default class SeckillTimeListView extends Component { |
|
|
: null}
|
|
|
</View>
|
|
|
:<View key={'row' + rowID} style={styles.rowContainer}>
|
|
|
<Text style={colorStyle}>{rowData.time}</Text>
|
|
|
{rowData.now ? <Text style={colorStyle}>抢购中</Text> : null}
|
|
|
{rowData.over ? <Text style={colorStyle}>已开抢</Text> : null}
|
|
|
{rowData.wait ? <Text style={colorStyle}>即将开抢</Text> : null}
|
|
|
<Text style={[colorStyle,{fontSize: 13}]}>{rowData.time}</Text>
|
|
|
{rowData.now ? <Text style={[colorStyle,{fontSize: 10}]}>抢购中</Text> : null}
|
|
|
{rowData.over ? <Text style={[colorStyle,{fontSize: 10}]}>已开抢</Text> : null}
|
|
|
{rowData.wait ? <Text style={[colorStyle,{fontSize: 10}]}>即将开抢</Text> : null}
|
|
|
|
|
|
</View>
|
|
|
}
|
...
|
...
|
@@ -152,6 +175,7 @@ export default class SeckillTimeListView extends Component { |
|
|
this.curFocusActivity = focusActivity;
|
|
|
}
|
|
|
diffTime = diff;
|
|
|
this.secKillProductVoList = resource;
|
|
|
return (
|
|
|
<View style={[styles.container]}>
|
|
|
<ListView
|
...
|
...
|
@@ -170,8 +194,10 @@ export default class SeckillTimeListView extends Component { |
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
let backgroundWidth= width;
|
|
|
let backgroundHeight = Math.ceil((120 / 640) * width);
|
|
|
let backgroundHeight = 61;
|
|
|
let diffTime;
|
|
|
let rowContainerWidth = Math.ceil((223 * width) / 750);
|
|
|
let rowContainerFocusWidth = Math.ceil((294 * width) / 750);
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
...
|
...
|
@@ -190,7 +216,7 @@ let styles = StyleSheet.create({ |
|
|
flexDirection: 'column',
|
|
|
alignItems: 'center',
|
|
|
justifyContent: 'center',
|
|
|
width: Math.ceil(width / 4),
|
|
|
width: rowContainerWidth,
|
|
|
height: backgroundHeight,
|
|
|
backgroundColor:'white',
|
|
|
},
|
...
|
...
|
@@ -198,7 +224,7 @@ let styles = StyleSheet.create({ |
|
|
flexDirection: 'column',
|
|
|
alignItems: 'center',
|
|
|
justifyContent: 'center',
|
|
|
width: Math.ceil(width * 0.4),
|
|
|
width: rowContainerFocusWidth,
|
|
|
height: backgroundHeight,
|
|
|
backgroundColor:'white',
|
|
|
},
|
...
|
...
|
@@ -206,17 +232,18 @@ let styles = StyleSheet.create({ |
|
|
flexDirection: 'row',
|
|
|
},
|
|
|
tickTime: {
|
|
|
backgroundColor:'red',
|
|
|
backgroundColor:'#d30018',
|
|
|
alignItems: 'center',
|
|
|
justifyContent: 'center',
|
|
|
left:0,
|
|
|
marginLeft:6,
|
|
|
width:20,
|
|
|
height:20,
|
|
|
marginLeft:5,
|
|
|
width:15,
|
|
|
height:15,
|
|
|
borderRadius:3,
|
|
|
},
|
|
|
tickTimeText: {
|
|
|
color: 'white',
|
|
|
fontSize: 9,
|
|
|
},
|
|
|
bottomToolBar: {
|
|
|
top: 200,
|
...
|
...
|
@@ -231,8 +258,8 @@ let styles = StyleSheet.create({ |
|
|
},
|
|
|
separator: {
|
|
|
width: 1.5,
|
|
|
top: 10,
|
|
|
height: backgroundHeight - 20,
|
|
|
backgroundColor: '#e5e5e5',
|
|
|
top: 11,
|
|
|
height: backgroundHeight - 22,
|
|
|
backgroundColor: '#dfe3e2',
|
|
|
},
|
|
|
}); |
...
|
...
|
|