fix(orderDetail): 修复页面关闭时未清除查询间隔的问题

- 在 onUnload 生命周期函数中添加了 clearQueryInterval 方法,确保页面卸载时清除查询间隔
- 在取消订单和支付流程中,添加了清除查询间隔的逻辑,避免不必要的请求
- 优化了订单状态查询的逻辑,提高了代码的可读性和性能
main
Tuzki 7 months ago
parent c781eb9aaa
commit 77d1e1cd6a
  1. 9
      pages/orderDetail/orderDetail.vue

@ -105,6 +105,7 @@
},
onUnload() {
// this.cancelOrder();
this.clearQueryInterval()
},
computed: {
errClass() {
@ -132,6 +133,7 @@
cancelOrder(that.orderDetail.orderInfo.orderNumber)
.then((res) => {
uni.hideLoading();
this.clearQueryInterval()
uni.showToast({
icon: 'none',
title: '已取消',
@ -160,6 +162,7 @@
}
this.interval = setInterval(() => {
getOrder(that.orderDetail.orderInfo.belongingPayOrderId).then((response) => {
console.log('response',response)
//
if (response.data.status === 10) {
that.clearQueryInterval();
@ -174,6 +177,7 @@
};
printTicket(ob)
.then((ress) => {
const datas = JSON.stringify(that.orderDetail.orderInfo
.ticketList);
// console.log(data)
@ -224,7 +228,6 @@
id: that.orderDetail.orderInfo.belongingPayOrderId,
returnUrl: ''
};
debugger
submitOrder(obj).then((res) => {
console.log('支付结果', res)
const data = res.data;
@ -235,7 +238,7 @@
title: '支付中...',
mask: true
});
this.createQueryInterval();
that.createQueryInterval();
// that.clearQueryInterval();
@ -314,10 +317,12 @@
let that = this;
cancelOrder(that.orderDetail.orderInfo.orderNumber)
.then((res) => {
this.clearQueryInterval()
console.log(res);
})
.catch((err) => {
console.log(err);
this.clearQueryInterval()
});
uni.navigateBack({
delta: 1

Loading…
Cancel
Save