From 77d1e1cd6ac91e61ffae368201e3ff8d9d9a42df Mon Sep 17 00:00:00 2001 From: Tuzki <1720599558@qq.com> Date: Mon, 17 Mar 2025 16:47:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(orderDetail):=20=E4=BF=AE=E5=A4=8D=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=85=B3=E9=97=AD=E6=97=B6=E6=9C=AA=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=97=B4=E9=9A=94=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 onUnload 生命周期函数中添加了 clearQueryInterval 方法,确保页面卸载时清除查询间隔 - 在取消订单和支付流程中,添加了清除查询间隔的逻辑,避免不必要的请求 - 优化了订单状态查询的逻辑,提高了代码的可读性和性能 --- pages/orderDetail/orderDetail.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pages/orderDetail/orderDetail.vue b/pages/orderDetail/orderDetail.vue index 838f458..f756c49 100644 --- a/pages/orderDetail/orderDetail.vue +++ b/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