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

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

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

Loading…
Cancel
Save