fix:修复bug
This commit is contained in:
+65
-25
@@ -154,10 +154,11 @@
|
||||
},
|
||||
timer: null,
|
||||
statusCheckTimer: null,
|
||||
maxStatusChecks: 30,
|
||||
maxStatusChecks: 60,
|
||||
currentStatusChecks: 0,
|
||||
statusCheckInterval: 5000,
|
||||
statusCheckInterval: 3000,
|
||||
isPageActive: false,
|
||||
isLoadingOrder: false,
|
||||
expressThresholdSeconds: 180,
|
||||
countdownRemaining: 0,
|
||||
showExpressAction: false,
|
||||
@@ -552,11 +553,18 @@
|
||||
return
|
||||
}
|
||||
|
||||
// 防止并发请求
|
||||
if (this.isLoadingOrder) {
|
||||
console.log('正在加载订单,跳过重复请求')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
if (!this.orderInfo.orderId) {
|
||||
throw new Error(this.$t('order.orderIdRequired'))
|
||||
}
|
||||
|
||||
this.isLoadingOrder = true
|
||||
const result = await queryById(this.orderInfo.orderId)
|
||||
|
||||
if (result.code === 200 && result.data) {
|
||||
@@ -602,12 +610,15 @@
|
||||
this.goToHome()
|
||||
}, 1500)
|
||||
} finally {
|
||||
this.isLoadingOrder = false
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
|
||||
// 更新订单信息
|
||||
updateOrderInfo(orderData) {
|
||||
const oldStatus = this.orderInfo.orderStatus
|
||||
|
||||
this.orderInfo.usedTime = orderData.usedTime || '0分钟'
|
||||
this.orderInfo.currentFee = orderData.currentFee || orderData.actualDeviceAmount || orderData.payAmount || '0.00'
|
||||
this.orderInfo.orderStatus = orderData.orderStatus || ''
|
||||
@@ -638,21 +649,43 @@
|
||||
if (orderData.deviceNo && !this.deviceId) {
|
||||
this.deviceId = orderData.deviceNo
|
||||
}
|
||||
|
||||
// 如果订单状态从 'in_used' 变为其他状态,清理所有定时器
|
||||
if (oldStatus === 'in_used' && this.orderInfo.orderStatus !== 'in_used') {
|
||||
console.log('订单状态已从使用中变为:', this.orderInfo.orderStatus, ',清理所有定时器')
|
||||
this.clearTimer()
|
||||
this.clearStatusCheckTimer()
|
||||
this.clearExpressCountdown()
|
||||
this.removeFromOrderMonitor()
|
||||
|
||||
// 显示订单完成提示
|
||||
if (this.orderInfo.orderStatus === 'used_done' || this.orderInfo.orderStatus === 'used_down') {
|
||||
uni.showToast({
|
||||
title: '订单已完成',
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 更新使用时长的定时器
|
||||
// 更新使用时长的定时器(每30秒更新一次)
|
||||
startTimer() {
|
||||
this.clearTimer()
|
||||
this.timer = setInterval(() => {
|
||||
if (this.isPageActive) {
|
||||
console.log('执行定时更新订单信息')
|
||||
this.getOrderDetails()
|
||||
} else {
|
||||
if (!this.isPageActive) {
|
||||
console.log('页面已不活跃,停止计时器')
|
||||
this.clearTimer()
|
||||
return
|
||||
}
|
||||
}, 60000)
|
||||
console.log('已启动使用时长更新计时器')
|
||||
if (this.orderInfo.orderStatus !== 'in_used') {
|
||||
console.log('订单状态已变更,停止计时器')
|
||||
this.clearTimer()
|
||||
return
|
||||
}
|
||||
console.log('执行定时更新订单信息')
|
||||
this.getOrderDetails()
|
||||
}, 30000) // 改为30秒更新一次
|
||||
console.log('已启动使用时长更新计时器(30秒间隔)')
|
||||
},
|
||||
|
||||
// 清除定时器
|
||||
@@ -673,32 +706,39 @@
|
||||
}
|
||||
},
|
||||
|
||||
// 开始状态检查定时器
|
||||
// 开始状态检查定时器(优化版)
|
||||
startStatusCheckTimer() {
|
||||
this.currentStatusChecks = 0
|
||||
this.clearStatusCheckTimer()
|
||||
|
||||
this.statusCheckTimer = setInterval(() => {
|
||||
if (this.isPageActive) {
|
||||
this.currentStatusChecks++
|
||||
console.log(`执行归还状态检查 (${this.currentStatusChecks}/${this.maxStatusChecks})`)
|
||||
this.checkReturnStatus()
|
||||
|
||||
if (this.currentStatusChecks >= this.maxStatusChecks) {
|
||||
this.clearStatusCheckTimer()
|
||||
uni.showToast({
|
||||
title: '请手动刷新查看归还状态',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (!this.isPageActive) {
|
||||
console.log('页面已不活跃,停止状态检查计时器')
|
||||
this.clearStatusCheckTimer()
|
||||
return
|
||||
}
|
||||
|
||||
if (this.orderInfo.orderStatus !== 'in_used') {
|
||||
console.log('订单状态已变更,停止状态检查计时器')
|
||||
this.clearStatusCheckTimer()
|
||||
return
|
||||
}
|
||||
|
||||
this.currentStatusChecks++
|
||||
console.log(`执行归还状态检查 (${this.currentStatusChecks}/${this.maxStatusChecks})`)
|
||||
this.checkReturnStatus()
|
||||
|
||||
if (this.currentStatusChecks >= this.maxStatusChecks) {
|
||||
this.clearStatusCheckTimer()
|
||||
uni.showToast({
|
||||
title: '请手动刷新查看归还状态',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
})
|
||||
}
|
||||
}, this.statusCheckInterval)
|
||||
|
||||
console.log('已启动归还状态检查计时器')
|
||||
console.log('已启动归还状态检查计时器(3秒间隔)')
|
||||
},
|
||||
|
||||
// 通过设备号查询使用中的订单
|
||||
|
||||
Reference in New Issue
Block a user