...
|
...
|
@@ -73,7 +73,18 @@ export default class SeckillTimeListView extends Component { |
|
|
}
|
|
|
|
|
|
_caculateTimerState() {
|
|
|
if (this.curFocusActivity.get('index') == this.secKillProductVoList.length - 1 && this.curFocusActivity.has('now')) {
|
|
|
let nextActivity = undefined;
|
|
|
if (this.curFocusActivity.get('index') < this.secKillProductVoList.length - 1) {
|
|
|
nextActivity = this.secKillProductVoList[this.curFocusActivity.get('index') + 1];
|
|
|
}
|
|
|
let nowTime = Date.parse(new Date()) / 1000 + diffTime;
|
|
|
let time = this.curFocusActivity.has('now') ? this.curFocusActivity.get('endTime') / 1000 : this.curFocusActivity.get('startTime') / 1000;
|
|
|
let offsetTime = time - nowTime;
|
|
|
let hour = parseInt(offsetTime / (60 * 60), 10);
|
|
|
let minute = parseInt(offsetTime % (60 * 60) / 60, 10);
|
|
|
let second = offsetTime % 60;
|
|
|
|
|
|
if (offsetTime < 0) {
|
|
|
if (!this.state.tickTimeOut) {
|
|
|
this.setState({
|
|
|
tickHour: '',
|
...
|
...
|
@@ -81,47 +92,27 @@ export default class SeckillTimeListView extends Component { |
|
|
tickSecond: '',
|
|
|
tickTimeOut: true,
|
|
|
});
|
|
|
this.props.onRefresh && this.props.onRefresh();
|
|
|
}
|
|
|
} else {
|
|
|
|
|
|
let nextActivity = this.secKillProductVoList[this.curFocusActivity.get('index') + 1];
|
|
|
let nowTime = Date.parse(new Date()) / 1000 + diffTime;
|
|
|
let time = this.curFocusActivity.has('now') ? nextActivity.get('startTime')/1000: this.curFocusActivity.get('startTime') / 1000;
|
|
|
let offsetTime = time - nowTime;
|
|
|
let hour = parseInt(offsetTime / (60 * 60), 10);
|
|
|
let minute = parseInt(offsetTime % (60 * 60) / 60, 10);
|
|
|
let second = offsetTime % 60;
|
|
|
|
|
|
if (offsetTime < 0) {
|
|
|
if (!this.state.tickTimeOut) {
|
|
|
this.setState({
|
|
|
tickHour: '',
|
|
|
tickMinute: '',
|
|
|
tickSecond: '',
|
|
|
tickTimeOut: true,
|
|
|
});
|
|
|
if (this.curFocusActivity.has('now')) {
|
|
|
nextActivity = nextActivity.toJS();
|
|
|
nextActivity.focus = true;
|
|
|
this.curFocusActivity= Immutable.fromJS(nextActivity);
|
|
|
this._scrollToFocusActivity();
|
|
|
this.props.onFocusToCurStartedActivity && this.props.onFocusToCurStartedActivity(nextActivity);
|
|
|
if (this.curFocusActivity.has('now') && nextActivity != undefined) {
|
|
|
nextActivity = nextActivity.toJS();
|
|
|
nextActivity.focus = true;
|
|
|
this.curFocusActivity = Immutable.fromJS(nextActivity);
|
|
|
this._scrollToFocusActivity();
|
|
|
this.props.onFocusToCurStartedActivity && this.props.onFocusToCurStartedActivity(nextActivity);
|
|
|
|
|
|
} else {
|
|
|
this.props.onFocusToCurStartedActivity && this.props.onFocusToCurStartedActivity(this.curFocusActivity.toJS());
|
|
|
}
|
|
|
} else {
|
|
|
this.props.onFocusToCurStartedActivity && this.props.onFocusToCurStartedActivity(this.curFocusActivity.toJS());
|
|
|
}
|
|
|
} else {
|
|
|
this.setState({
|
|
|
tickHour: hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : (hour > 99 ? 99 : hour)),
|
|
|
tickMinute: minute < 0 ? '00' : (minute < 10 ? ('0' + minute) : minute),
|
|
|
tickSecond: second < 0 ? '00' : (second < 10 ? ('0' + second) : second),
|
|
|
tickTimeOut: false,
|
|
|
});
|
|
|
}
|
|
|
} else {
|
|
|
this.setState({
|
|
|
tickHour: hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : (hour > 99 ? 99 : hour)),
|
|
|
tickMinute: minute < 0 ? '00' : (minute < 10 ? ('0' + minute) : minute),
|
|
|
tickSecond: second < 0 ? '00' : (second < 10 ? ('0' + second) : second),
|
|
|
tickTimeOut: false,
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
...
|
...
|
@@ -139,7 +130,7 @@ export default class SeckillTimeListView extends Component { |
|
|
|
|
|
componentWillUnmount() {
|
|
|
this.timer && clearInterval(this.timer);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
this.curFocusActivity = nextProps.curActivity;
|
...
|
...
|
@@ -151,7 +142,7 @@ export default class SeckillTimeListView extends Component { |
|
|
|
|
|
_renderRow(rowData, sectionID, rowID) {
|
|
|
rowData = rowData.toJS();
|
|
|
|
|
|
|
|
|
return (
|
|
|
<TouchableOpacity activeOpacity={1.0} onPress={() => {
|
|
|
if (rowData.focus) {
|
...
|
...
|
@@ -164,9 +155,10 @@ export default class SeckillTimeListView extends Component { |
|
|
this.props.onPressTimeItem && this.props.onPressTimeItem(rowData);
|
|
|
}}>
|
|
|
|
|
|
{rowData.focus ? <TimeForFocus
|
|
|
{rowData.focus ? <TimeForFocus
|
|
|
key={'row' + rowID}
|
|
|
time={rowData.time}
|
|
|
endTime={rowData.endTime}
|
|
|
now={rowData.now}
|
|
|
over={rowData.over}
|
|
|
wait={rowData.wait}
|
...
|
...
|
@@ -174,18 +166,18 @@ export default class SeckillTimeListView extends Component { |
|
|
tickHour={this.state.tickHour}
|
|
|
tickMinute={this.state.tickMinute}
|
|
|
tickSecond={this.state.tickSecond}
|
|
|
lastNowTime={(rowID == this.secKillProductVoList.length -1) ? true : false}
|
|
|
lastNowTime={false}
|
|
|
/> : <TimeForLostFocus
|
|
|
key={'row' + rowID}
|
|
|
time={rowData.time}
|
|
|
now={rowData.now}
|
|
|
over={rowData.over}
|
|
|
wait={rowData.wait}
|
|
|
specialState = {
|
|
|
specialState={
|
|
|
rowData.specialState
|
|
|
}
|
|
|
/>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
</TouchableOpacity>
|
|
|
);
|
...
|
...
|
@@ -213,9 +205,9 @@ export default class SeckillTimeListView extends Component { |
|
|
|
|
|
return (
|
|
|
<View style={[styles.container]}>
|
|
|
<View style={{width: width,height: 0.5,backgroundColor: '#e5e5e5',}}/>
|
|
|
<View style={{width: width, height: 0.5, backgroundColor: '#e5e5e5',}}/>
|
|
|
<ListView
|
|
|
ref={(ref)=>this.listView=ref}
|
|
|
ref={(ref)=>this.listView = ref}
|
|
|
contentContainerStyle={[styles.contentContainer]}
|
|
|
enableEmptySections={true}
|
|
|
dataSource={this.dataSource.cloneWithRows(resource)}
|
...
|
...
|
@@ -226,14 +218,14 @@ export default class SeckillTimeListView extends Component { |
|
|
horizontal={true}
|
|
|
scrollsToTop={false}
|
|
|
/>
|
|
|
<View style={{width: width,height: 0.5,backgroundColor: '#e5e5e5',}}/>
|
|
|
<View style={{width: width, height: 0.5, backgroundColor: '#e5e5e5',}}/>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
let backgroundWidth= width;
|
|
|
let backgroundWidth = width;
|
|
|
let backgroundHeight = 61;
|
|
|
let diffTime;
|
|
|
let rowContainerWidth = Math.ceil((223 * width) / 750);
|
...
|
...
|
@@ -245,11 +237,11 @@ let styles = StyleSheet.create({ |
|
|
marginLeft: -1,
|
|
|
width: backgroundWidth + 2,
|
|
|
height: backgroundHeight,
|
|
|
backgroundColor:'white',
|
|
|
backgroundColor: 'white',
|
|
|
},
|
|
|
contentContainer: {
|
|
|
flexDirection: 'row',
|
|
|
backgroundColor:'white',
|
|
|
backgroundColor: 'white',
|
|
|
},
|
|
|
bottomToolBar: {
|
|
|
top: 200,
|
...
|
...
|
|