Fix:旅居订单增加轮询

This commit is contained in:
LinCyJang
2026-04-24 09:17:49 +08:00
committed by linxi
parent 0a70e4af6c
commit 75e9c404fc
3 changed files with 50 additions and 28 deletions
+1 -1
View File
@@ -486,7 +486,7 @@
class="v12-font-24 v12-primary-text"
style="background: rgba(246,246,246,0.7); border-radius: 40rpx; padding: 12rpx ;"
>修改地址审核未通过,商家将按原地址发货,
<text v-if="order.isFastPost !== 0">预计{{ getTime(order.isFastPost) }}发货</text>
<text v-if="order.isFastPost !== 0">预计{{ getTime(order.isFastPost) }}发货</text>
(驳回原因:{{ order.addressUpdateReason }})</view>
</view>
</view>
+1 -1
View File
@@ -87,7 +87,7 @@
v-if="Number(orderInfo.addressUpdateStatus) === 2"
class="v12-font-24 v12-primary-text"
style="background: rgba(246,246,246,0.7); border-radius: 40rpx; padding: 12rpx;"
>修改地址审核未通过商家将按原地址发货<text v-if="orderInfo.isFastPost !== 0">预计{{ getTime(orderInfo.isFastPost) }}发货</text>
>修改地址审核未通过商家将按原地址发货<text v-if="orderInfo.isFastPost !== 0">预计{{ getTime(orderInfo.isFastPost) }}发货</text>
(驳回原因{{ orderInfo.addressUpdateReason }})</view>
</view>
</view>
+48 -26
View File
@@ -241,19 +241,24 @@ export default {
isView: 0,
showExperienceCouponPopup: false,
experienceCouponId: null,
experienceCouponTimer: null
hasCheckedExperienceCoupon: false,
orderStatusTimer: null
}
},
onLoad(otps) {
this.key = otps.id;
this.isView = otps.isView || 0;
this.hasCheckedExperienceCoupon = false;
},
onShow() {
this.getSojoumOrderDetail();
},
onHide() {
this.stopOrderStatusPolling();
},
onUnload() {
uni.setStorageSync('needRefreshMyOrderList', 1)
this.stopExperienceCouponPolling();
this.stopOrderStatusPolling();
},
methods: {
handleDateRangeChange(dates) {
@@ -325,37 +330,55 @@ export default {
/**
* 获取旅居团购订单详情
*/
async getSojoumOrderDetail() {
async getSojoumOrderDetail(options = {}) {
const { showLoading = true } = options;
const params = {
key: this.key
}
uni.showLoading({
title: '加载中...',
mask: true,
})
const res = await fetchSojoumOrderDetail(params);
if (res.status === 200) {
this.orderInfo = res.data;
this.orderInfo.minBookingDays = this.getDaysCount();
this.startExperienceCouponPolling();
uni.hideLoading();
if (showLoading) {
uni.showLoading({
title: '加载中...',
mask: true,
})
}
try {
const res = await fetchSojoumOrderDetail(params);
if (res.status === 200) {
this.orderInfo = res.data;
this.orderInfo.minBookingDays = this.getDaysCount();
this.startOrderStatusPolling();
if (!this.hasCheckedExperienceCoupon) {
this.hasCheckedExperienceCoupon = true;
this.checkExperienceCouponStatus();
}
}
} finally {
if (showLoading) {
uni.hideLoading();
}
}
},
startExperienceCouponPolling() {
this.stopExperienceCouponPolling();
shouldPollOrderStatus() {
const statusType = this.orderInfo && this.orderInfo._status && this.orderInfo._status._type;
// if (![1, 2].includes(Number(statusType))) {
// return;
// }
this.checkExperienceCouponStatus();
this.experienceCouponTimer = setInterval(() => {
this.checkExperienceCouponStatus();
// 入住/核销成功后不再轮询
return !['3', '4'].includes(String(statusType || ''));
},
startOrderStatusPolling() {
if (!this.shouldPollOrderStatus()) {
this.stopOrderStatusPolling();
return;
}
if (this.orderStatusTimer) {
return;
}
this.orderStatusTimer = setInterval(() => {
this.getSojoumOrderDetail({ showLoading: false });
}, 5000);
},
stopExperienceCouponPolling() {
if (this.experienceCouponTimer) {
clearInterval(this.experienceCouponTimer);
this.experienceCouponTimer = null;
stopOrderStatusPolling() {
if (this.orderStatusTimer) {
clearInterval(this.orderStatusTimer);
this.orderStatusTimer = null;
}
},
async checkExperienceCouponStatus() {
@@ -377,7 +400,6 @@ export default {
if (!showPopup) {
return;
}
this.stopExperienceCouponPolling();
this.experienceCouponId = data.couponId || null;
this.showExperienceCouponPopup = true;
} catch (e) {