z8.3
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<view class="status" v-if="state">
|
||||
<view class="text">
|
||||
<view class="status-text">{{ s_object[state].text }}</view>
|
||||
<view class="time" v-if="orderInfo.view_type == 1">结束时间:{{ orderInfo.end_time }}</view>
|
||||
<view class="time" v-if="orderInfo.view_type == 1">距离结束:{{ countdown }}</view>
|
||||
</view>
|
||||
<image :src="s_object[state].image"></image>
|
||||
</view>
|
||||
@@ -116,6 +116,9 @@ export default {
|
||||
},
|
||||
orderInfo: {},
|
||||
oid: '',
|
||||
timer: '',
|
||||
countdown: '', // 倒计时
|
||||
isSpike: false, // 倒计时是否结束
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
@@ -126,7 +129,10 @@ export default {
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.getOrderInfo(this.oid);
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearInterval(this.timer);
|
||||
},
|
||||
methods: {
|
||||
viewState(value) {
|
||||
let state;
|
||||
@@ -154,12 +160,43 @@ export default {
|
||||
}
|
||||
this.state = state;
|
||||
},
|
||||
setSpikeTime(time) {
|
||||
// console.log(time);
|
||||
this.timer = setInterval(() => {
|
||||
let spikeTime = time * 1000 - new Date().getTime();
|
||||
// console.log(spikeTime);
|
||||
if(spikeTime <= 0) {
|
||||
this.isSpike = true;
|
||||
this.spikeTime = '00:00:00'
|
||||
clearInterval(this.timer);
|
||||
return false;
|
||||
};
|
||||
// 计算天数
|
||||
const days = Math.floor(spikeTime/(24*3600*1000));
|
||||
//计算出小时数
|
||||
const leave1 = spikeTime % (24*3600*1000) // 计算天数后剩余的毫秒数
|
||||
let hours = Math.floor(leave1/(3600*1000));
|
||||
//计算相差分钟数
|
||||
const leave2 = leave1 % (3600*1000) // 计算小时数后剩余的毫秒数
|
||||
let minutes = Math.floor(leave2 / (60*1000))
|
||||
//计算相差秒数
|
||||
const leave3 = leave2 % (60*1000) // 计算分钟数后剩余的毫秒数
|
||||
let seconds = Math.round(leave3 / 1000)
|
||||
// 把天数算在小时里
|
||||
hours = days * 24 + hours;
|
||||
if(hours < 10) hours = '0' + hours;
|
||||
if(minutes < 10) minutes = '0' + minutes;
|
||||
if(seconds < 10) seconds = '0' + seconds;
|
||||
this.countdown = hours + ':' + minutes + ':' + seconds;
|
||||
}, 1000)
|
||||
},
|
||||
getOrderInfo(id) {
|
||||
this.$u.api.getOrderInfo({
|
||||
order_id: id,
|
||||
}).then(res => {
|
||||
if(res.errCode == 0) {
|
||||
this.orderInfo = res.data;
|
||||
this.setSpikeTime(res.data.end_time);
|
||||
this.viewState(this.orderInfo.view_type);
|
||||
this.setTitle(this.orderInfo.view_type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user