Browse Source

不需要同步-修改倒计时问题

master
liutong 1 year ago
parent
commit
4dd01949e7
  1. 51
      pages/order_details.vue

51
pages/order_details.vue

@ -193,7 +193,7 @@
<div class="l">等待付款</div>
<div class="r qx">
剩余时间
<span class="red">{{ min }}分钟 {{ sec }}</span>自动关闭
<span class="red">{{ hours }}小时 {{ min }}分钟 {{ sec }}</span>自动关闭
</div>
</div>
@ -674,8 +674,10 @@ export default {
label: "双皮奶",
},
],
min: "",
sec: "",
//
hours: "",//
min: "",//
sec: "",//
order_create_time: "",
logisticsData: {},
contentText: "",
@ -710,8 +712,11 @@ export default {
this.tableData.map((item) => {
item.buyer_messag = this.orderData.buyer_message;
});
this.order_create_time = res.data.create_time;
this.countdown();
this.order_create_time = res.data.create_time + res
.data.auto_close;
if(this.orderData.order_status == 0){
this.countdown2();
}
// -1- 1- 2- 3- 4- 5-
if (this.orderData.order_status == -1) {
this.orderType = -1;
@ -1005,6 +1010,42 @@ export default {
}, 1000);
}
},
countdown2() {
//
const now = new Date().getTime();
// order_create_time
const closeTime = this.order_create_time * 1000;
//
let distance = closeTime - now;
// 使 setInterval
const interval = setInterval(() => {
// 000:00:00
if (distance <= 0) {
clearInterval(interval);
this.hours = '00';
this.min = '00';
this.sec = '00';
return;
}
//
const hours = Math.floor(distance / (1000 * 60 * 60));
//
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
//
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
//
this.hours = String(hours).padStart(2, '0');
this.min = String(minutes).padStart(2, '0');
this.sec = String(seconds).padStart(2, '0');
//
distance -= 1000;
}, 1000); //
}
},
};
</script>

Loading…
Cancel
Save