fix:修复bug
This commit is contained in:
@@ -549,12 +549,12 @@
|
||||
// 调用微信支付分小程序
|
||||
const payResult = await initiateWeChatScorePayment(res);
|
||||
console.log('支付分调用结果', payResult);
|
||||
// 成功则跳转等待页,轮询在等待页处理
|
||||
// 成功则跳转到等待页面
|
||||
if (payResult.errCode == '0' && payResult.extraData && Object.keys(payResult.extraData).length > 0) {
|
||||
console.log('支付分授权成功,准备跳转,时间:', new Date().toLocaleTimeString());
|
||||
// 直接跳转(订阅消息已经在前面完成了)
|
||||
console.log('支付分授权成功,准备跳转到等待页,时间:', new Date().toLocaleTimeString());
|
||||
// 跳转到等待页面(订阅消息已经在前面完成了)
|
||||
uni.redirectTo({
|
||||
url: `/pages/waiting/index?orderNo=${order.orderNo}&deviceId=${deviceId.value}`
|
||||
url: `/pages/waiting/index?orderNo=${order.orderNo}&orderId=${order.orderId}&deviceId=${deviceId.value}`
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
<!-- 自定义导航栏 -->
|
||||
<view class="custom-navbar" :style="{ paddingTop: statusBarHeight + 'px' }">
|
||||
<view class="navbar-content" :style="{ height: navBarHeight + 'px' }">
|
||||
<text class="navbar-title">{{ $t('home.title') }}</text>
|
||||
<!-- <text class="navbar-title">{{ $t('home.title') }}</text> -->
|
||||
<text class="navbar-title">风电者共享风扇</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
+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秒间隔)')
|
||||
},
|
||||
|
||||
// 通过设备号查询使用中的订单
|
||||
|
||||
+27
-3
@@ -32,6 +32,8 @@
|
||||
const leftRotateDeg = ref(0)
|
||||
const rightRotateDeg = ref(0)
|
||||
const orderNo = ref('')
|
||||
const orderId = ref('')
|
||||
const deviceId = ref('')
|
||||
let progressTimer = null
|
||||
let pollTimer = null
|
||||
let timeoutTimer = null
|
||||
@@ -76,7 +78,10 @@
|
||||
progress.value = 100
|
||||
updateRotate(progress.value)
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({ url: '/pages/order/index' })
|
||||
// 跳转到订单详情页面,传递 orderId 和 deviceId
|
||||
const url = `/pages/order/detail?orderId=${orderId.value || orderNo.value}&deviceId=${deviceId.value}`
|
||||
console.log('等待完成,跳转到订单详情:', url)
|
||||
uni.redirectTo({ url })
|
||||
}, 400)
|
||||
}
|
||||
|
||||
@@ -98,6 +103,16 @@
|
||||
if (!orderNo.value) return
|
||||
const res = await getOrderByOrderNoScorePayStatus(orderNo.value)
|
||||
if (res && res.data) {
|
||||
// 如果还没有 orderId,从返回数据中获取
|
||||
if (!orderId.value && res.data.orderId) {
|
||||
orderId.value = res.data.orderId
|
||||
console.log('从订单状态中获取 orderId:', orderId.value)
|
||||
}
|
||||
if (!deviceId.value && res.data.deviceNo) {
|
||||
deviceId.value = res.data.deviceNo
|
||||
console.log('从订单状态中获取 deviceId:', deviceId.value)
|
||||
}
|
||||
|
||||
if (res.data.orderStatus == 'in_used') {
|
||||
stopAllTimers()
|
||||
handleSuccess()
|
||||
@@ -125,8 +140,17 @@
|
||||
uni.setNavigationBarTitle({
|
||||
title: $t('waiting.title')
|
||||
})
|
||||
if (query && query.orderNo) {
|
||||
orderNo.value = query.orderNo
|
||||
if (query) {
|
||||
if (query.orderNo) {
|
||||
orderNo.value = query.orderNo
|
||||
}
|
||||
if (query.orderId) {
|
||||
orderId.value = query.orderId
|
||||
}
|
||||
if (query.deviceId) {
|
||||
deviceId.value = query.deviceId
|
||||
}
|
||||
console.log('等待页面参数:', { orderNo: orderNo.value, orderId: orderId.value, deviceId: deviceId.value })
|
||||
}
|
||||
startProgress()
|
||||
startPolling()
|
||||
|
||||
Reference in New Issue
Block a user