Fix:5004 【商城小程序】待使用订单核销后,当前页面未自动刷新更新订单状态
This commit is contained in:
@@ -121,7 +121,8 @@ export default {
|
|||||||
orderInfo: {},
|
orderInfo: {},
|
||||||
userLatitude: null,
|
userLatitude: null,
|
||||||
userLongitude: null,
|
userLongitude: null,
|
||||||
distanceText: ''
|
distanceText: '',
|
||||||
|
pollTimer: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -155,6 +156,12 @@ export default {
|
|||||||
}
|
}
|
||||||
this.getUserLocation()
|
this.getUserLocation()
|
||||||
},
|
},
|
||||||
|
onUnload() {
|
||||||
|
this.stopOrderPoll()
|
||||||
|
},
|
||||||
|
onHide() {
|
||||||
|
this.stopOrderPoll()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchDetail() {
|
fetchDetail() {
|
||||||
if (!this.orderId) {
|
if (!this.orderId) {
|
||||||
@@ -163,8 +170,31 @@ export default {
|
|||||||
getExperienceCouponOrderDetail(this.orderId).then(({ data }) => {
|
getExperienceCouponOrderDetail(this.orderId).then(({ data }) => {
|
||||||
this.orderInfo = data || {}
|
this.orderInfo = data || {}
|
||||||
this.updateDistance()
|
this.updateDistance()
|
||||||
|
if (!this.isCompleted && !this.isExpired) {
|
||||||
|
this.startOrderPoll()
|
||||||
|
} else {
|
||||||
|
this.stopOrderPoll()
|
||||||
|
}
|
||||||
}).catch(() => {})
|
}).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() {
|
getUserLocation() {
|
||||||
uni.getLocation({
|
uni.getLocation({
|
||||||
type: 'gcj02',
|
type: 'gcj02',
|
||||||
|
|||||||
Reference in New Issue
Block a user