Fix:5004 【商城小程序】待使用订单核销后,当前页面未自动刷新更新订单状态

This commit is contained in:
LinCyJang
2026-03-29 12:03:19 +08:00
parent cb260c7b56
commit a2f9ee2377
@@ -121,7 +121,8 @@ export default {
orderInfo: {},
userLatitude: null,
userLongitude: null,
distanceText: ''
distanceText: '',
pollTimer: null
}
},
computed: {
@@ -155,6 +156,12 @@ export default {
}
this.getUserLocation()
},
onUnload() {
this.stopOrderPoll()
},
onHide() {
this.stopOrderPoll()
},
methods: {
fetchDetail() {
if (!this.orderId) {
@@ -163,8 +170,31 @@ export default {
getExperienceCouponOrderDetail(this.orderId).then(({ data }) => {
this.orderInfo = data || {}
this.updateDistance()
if (!this.isCompleted && !this.isExpired) {
this.startOrderPoll()
} else {
this.stopOrderPoll()
}
}).catch(() => {})
},
startOrderPoll() {
if (this.pollTimer || !this.orderId) {
return
}
this.pollTimer = setInterval(() => {
if (this.isCompleted || this.isExpired) {
this.stopOrderPoll()
return
}
this.fetchDetail()
}, 5000)
},
stopOrderPoll() {
if (this.pollTimer) {
clearInterval(this.pollTimer)
this.pollTimer = null
}
},
getUserLocation() {
uni.getLocation({
type: 'gcj02',