Commit b6a59fea authored by youjie's avatar youjie

详情倒计时

parent 2e3cc651
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
{{ orderStatus.text }} {{ orderStatus.text }}
</text> </text>
</view> </view>
<view class="RemainderBox" v-if="remainingSeconds&&orderData.directOrder.OrderStatus==1"> <view class="RemainderBox" v-if="remainingSeconds">
<text>剩余:</text> <text>剩余:</text>
<text>{{formattedTime}}</text> <text>{{formattedTime}}</text>
</view> </view>
...@@ -314,11 +314,14 @@ ...@@ -314,11 +314,14 @@
}, },
computed: { computed: {
formattedTime() { formattedTime() {
const minutes = Math.floor(this.remainingSeconds / 60/1000) const minutes = Math.floor(this.remainingSeconds / 60)
const seconds = this.remainingSeconds % 60%1000 const seconds = this.remainingSeconds % 60
return `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}` return `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`
} }
}, },
beforeDestroy() {
this.clearInterval()
},
created() { created() {
this.Up = uni.getStorageSync("mall_UserInfo") ? this.Up = uni.getStorageSync("mall_UserInfo") ?
uni.getStorageSync("mall_UserInfo").UserPageType : uni.getStorageSync("mall_UserInfo").UserPageType :
...@@ -532,9 +535,10 @@ ...@@ -532,9 +535,10 @@
this.orderData.directOrder.CreateTime = this.$utils.formatDates(new Date(tempData.directOrder.CreateTime), 'yyyy-MM-dd hh:mm:ss') this.orderData.directOrder.CreateTime = this.$utils.formatDates(new Date(tempData.directOrder.CreateTime), 'yyyy-MM-dd hh:mm:ss')
// 支付倒计时 // 支付倒计时
if (tempData.directOrder.OrderStatus == 1) { if (this.orderData.directOrder.CreateTime&&tempData.directOrder.OrderStatus==1) {
const now = Date.now(); const now = Date.now();
const customStr = this.orderData.directOrder.CreateTime//'2025-05-12 10:17:00' // const customStr = '2025-05-12 14:33:47'
const customStr = this.orderData.directOrder.CreateTime
const [date, time] = customStr.split(' ') const [date, time] = customStr.split(' ')
const [year, month, day] = date.split('-') const [year, month, day] = date.split('-')
const [hours, minutes, seconds] = time.split(':') const [hours, minutes, seconds] = time.split(':')
...@@ -542,7 +546,8 @@ ...@@ -542,7 +546,8 @@
this.orderTime = parsedDate.getTime() this.orderTime = parsedDate.getTime()
const diff = this.orderTime + 5 * 60 * 1000 - now; // 5分钟倒计时 const diff = this.orderTime + 5 * 60 * 1000 - now; // 5分钟倒计时
this.remainingSeconds = Math.max(diff, 0); // 确保不出现负数 let remainingSeconds = Math.max(diff, 0); // 确保不出现负数
this.remainingSeconds = Math.floor(remainingSeconds/1000)
// 启动倒计时 // 启动倒计时
if(this.remainingSeconds) this.startCountdown() if(this.remainingSeconds) this.startCountdown()
else this.handleTimeout() else this.handleTimeout()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment