fix:修复订单详情页快递归还按钮展示bug

This commit is contained in:
2025-11-28 11:52:37 +08:00
parent 64c9d933b1
commit 65a168daed
+42 -4
View File
@@ -75,6 +75,8 @@
<image src="/static/customer-service.png" class="icon" mode="aspectFit"></image> <image src="/static/customer-service.png" class="icon" mode="aspectFit"></image>
<text>{{ $t('user.customerService') }}</text> <text>{{ $t('user.customerService') }}</text>
</view> </view>
<!-- 只有支持快递归还时才显示倒计时和快递归还按钮 -->
<template v-if="orderInfo.isSupportExpressReturn !== 'no'">
<view v-if="!showExpressAction" class="countdown-btn"> <view v-if="!showExpressAction" class="countdown-btn">
{{ formatCountdown(countdownRemaining) }}{{ $t('order.canExpressReturn') }} {{ formatCountdown(countdownRemaining) }}{{ $t('order.canExpressReturn') }}
</view> </view>
@@ -85,6 +87,11 @@
{{ $t('order.quickReturn') }} {{ $t('order.quickReturn') }}
</view> </view>
</template> </template>
<!-- 不支持快递归还时只显示快速归还按钮 -->
<view v-else class="action-btn primary" @click="quickReturn">
{{ $t('order.quickReturn') }}
</view>
</template>
<!-- 已完成状态 --> <!-- 已完成状态 -->
<template v-if="isOrderCompleted()"> <template v-if="isOrderCompleted()">
@@ -150,7 +157,8 @@
isWithdrawn: false, isWithdrawn: false,
positionName: '', positionName: '',
returnPosition: '', returnPosition: '',
expressReturnStart: null expressReturnStart: null,
isSupportExpressReturn: 'yes'
}, },
timer: null, timer: null,
statusCheckTimer: null, statusCheckTimer: null,
@@ -216,7 +224,7 @@
}, },
onShow() { onShow() {
this.isPageActive = true this.isPageActive = true
if (this.orderInfo.orderStatus === 'in_used') { if (this.orderInfo.orderStatus === 'in_used' && this.orderInfo.isSupportExpressReturn !== 'no') {
this.startExpressCountdown() this.startExpressCountdown()
} }
}, },
@@ -325,8 +333,10 @@
// 快速归还 // 快速归还
quickReturn() { quickReturn() {
// 刷新订单状态,检查是否已归还 // 跳转到搜索页面查询周围设备
this.checkReturnStatus() uni.navigateTo({
url: '/pages/search/index'
})
}, },
// 再次租借 // 再次租借
@@ -438,6 +448,14 @@
// 启动快递归还倒计时 // 启动快递归还倒计时
startExpressCountdown() { startExpressCountdown() {
// 如果不支持快递归还,直接返回
if (this.orderInfo.isSupportExpressReturn === 'no') {
console.log('订单不支持快递归还,不启动倒计时')
this.showExpressAction = false
this.countdownRemaining = 0
return
}
this.clearExpressCountdown() this.clearExpressCountdown()
this.recomputeExpressCountdownFromStartTime() this.recomputeExpressCountdownFromStartTime()
if (this.showExpressAction) return if (this.showExpressAction) return
@@ -450,6 +468,13 @@
this.clearExpressCountdown() this.clearExpressCountdown()
return return
} }
// 再次检查是否支持快递归还
if (this.orderInfo.isSupportExpressReturn === 'no') {
this.clearExpressCountdown()
this.showExpressAction = false
this.countdownRemaining = 0
return
}
this.recomputeExpressCountdownFromStartTime() this.recomputeExpressCountdownFromStartTime()
if (this.showExpressAction) { if (this.showExpressAction) {
this.clearExpressCountdown() this.clearExpressCountdown()
@@ -500,6 +525,13 @@
// 重新计算倒计时 // 重新计算倒计时
recomputeExpressCountdownFromStartTime() { recomputeExpressCountdownFromStartTime() {
// 如果不支持快递归还,直接返回
if (this.orderInfo.isSupportExpressReturn === 'no') {
this.showExpressAction = false
this.countdownRemaining = 0
return
}
if (this.orderInfo.orderStatus !== 'in_used') { if (this.orderInfo.orderStatus !== 'in_used') {
this.showExpressAction = false this.showExpressAction = false
this.countdownRemaining = 0 this.countdownRemaining = 0
@@ -578,7 +610,10 @@
if (this.orderInfo.orderStatus === 'in_used') { if (this.orderInfo.orderStatus === 'in_used') {
this.startTimer() this.startTimer()
this.startStatusCheckTimer() this.startStatusCheckTimer()
// 只有支持快递归还时才启动倒计时
if (this.orderInfo.isSupportExpressReturn !== 'no') {
this.startExpressCountdown() this.startExpressCountdown()
}
uni.setStorageSync('activeOrderId', this.orderInfo.orderId) uni.setStorageSync('activeOrderId', this.orderInfo.orderId)
@@ -640,6 +675,9 @@
// 保存快递归还开始时间(小时为单位) // 保存快递归还开始时间(小时为单位)
this.orderInfo.expressReturnStart = orderData.expressReturnStart || null this.orderInfo.expressReturnStart = orderData.expressReturnStart || null
// 保存是否支持快递归还
this.orderInfo.isSupportExpressReturn = orderData.isSupportExpressReturn || 'yes'
// 如果有有效的 expressReturnStart,立即更新倒计时阈值(小时转秒) // 如果有有效的 expressReturnStart,立即更新倒计时阈值(小时转秒)
if (this.orderInfo.expressReturnStart && typeof this.orderInfo.expressReturnStart === 'number' && this.orderInfo.expressReturnStart > 0) { if (this.orderInfo.expressReturnStart && typeof this.orderInfo.expressReturnStart === 'number' && this.orderInfo.expressReturnStart > 0) {
this.expressThresholdSeconds = this.orderInfo.expressReturnStart * 3600 this.expressThresholdSeconds = this.orderInfo.expressReturnStart * 3600