Fix:旅居订单增加轮询
This commit is contained in:
@@ -486,7 +486,7 @@
|
|||||||
class="v12-font-24 v12-primary-text"
|
class="v12-font-24 v12-primary-text"
|
||||||
style="background: rgba(246,246,246,0.7); border-radius: 40rpx; padding: 12rpx ;"
|
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>
|
(驳回原因:{{ order.addressUpdateReason }})</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
v-if="Number(orderInfo.addressUpdateStatus) === 2"
|
v-if="Number(orderInfo.addressUpdateStatus) === 2"
|
||||||
class="v12-font-24 v12-primary-text"
|
class="v12-font-24 v12-primary-text"
|
||||||
style="background: rgba(246,246,246,0.7); border-radius: 40rpx; padding: 12rpx;"
|
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>
|
(驳回原因:{{ orderInfo.addressUpdateReason }})</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -241,19 +241,24 @@ export default {
|
|||||||
isView: 0,
|
isView: 0,
|
||||||
showExperienceCouponPopup: false,
|
showExperienceCouponPopup: false,
|
||||||
experienceCouponId: null,
|
experienceCouponId: null,
|
||||||
experienceCouponTimer: null
|
hasCheckedExperienceCoupon: false,
|
||||||
|
orderStatusTimer: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(otps) {
|
onLoad(otps) {
|
||||||
this.key = otps.id;
|
this.key = otps.id;
|
||||||
this.isView = otps.isView || 0;
|
this.isView = otps.isView || 0;
|
||||||
|
this.hasCheckedExperienceCoupon = false;
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
this.getSojoumOrderDetail();
|
this.getSojoumOrderDetail();
|
||||||
},
|
},
|
||||||
|
onHide() {
|
||||||
|
this.stopOrderStatusPolling();
|
||||||
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
uni.setStorageSync('needRefreshMyOrderList', 1)
|
uni.setStorageSync('needRefreshMyOrderList', 1)
|
||||||
this.stopExperienceCouponPolling();
|
this.stopOrderStatusPolling();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleDateRangeChange(dates) {
|
handleDateRangeChange(dates) {
|
||||||
@@ -325,37 +330,55 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* 获取旅居团购订单详情
|
* 获取旅居团购订单详情
|
||||||
*/
|
*/
|
||||||
async getSojoumOrderDetail() {
|
async getSojoumOrderDetail(options = {}) {
|
||||||
|
const { showLoading = true } = options;
|
||||||
const params = {
|
const params = {
|
||||||
key: this.key
|
key: this.key
|
||||||
}
|
}
|
||||||
uni.showLoading({
|
if (showLoading) {
|
||||||
title: '加载中...',
|
uni.showLoading({
|
||||||
mask: true,
|
title: '加载中...',
|
||||||
})
|
mask: true,
|
||||||
const res = await fetchSojoumOrderDetail(params);
|
})
|
||||||
if (res.status === 200) {
|
}
|
||||||
this.orderInfo = res.data;
|
try {
|
||||||
this.orderInfo.minBookingDays = this.getDaysCount();
|
const res = await fetchSojoumOrderDetail(params);
|
||||||
this.startExperienceCouponPolling();
|
if (res.status === 200) {
|
||||||
uni.hideLoading();
|
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() {
|
shouldPollOrderStatus() {
|
||||||
this.stopExperienceCouponPolling();
|
|
||||||
const statusType = this.orderInfo && this.orderInfo._status && this.orderInfo._status._type;
|
const statusType = this.orderInfo && this.orderInfo._status && this.orderInfo._status._type;
|
||||||
// if (![1, 2].includes(Number(statusType))) {
|
// 入住/核销成功后不再轮询
|
||||||
// return;
|
return !['3', '4'].includes(String(statusType || ''));
|
||||||
// }
|
},
|
||||||
this.checkExperienceCouponStatus();
|
startOrderStatusPolling() {
|
||||||
this.experienceCouponTimer = setInterval(() => {
|
if (!this.shouldPollOrderStatus()) {
|
||||||
this.checkExperienceCouponStatus();
|
this.stopOrderStatusPolling();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.orderStatusTimer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.orderStatusTimer = setInterval(() => {
|
||||||
|
this.getSojoumOrderDetail({ showLoading: false });
|
||||||
}, 5000);
|
}, 5000);
|
||||||
},
|
},
|
||||||
stopExperienceCouponPolling() {
|
stopOrderStatusPolling() {
|
||||||
if (this.experienceCouponTimer) {
|
if (this.orderStatusTimer) {
|
||||||
clearInterval(this.experienceCouponTimer);
|
clearInterval(this.orderStatusTimer);
|
||||||
this.experienceCouponTimer = null;
|
this.orderStatusTimer = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async checkExperienceCouponStatus() {
|
async checkExperienceCouponStatus() {
|
||||||
@@ -377,7 +400,6 @@ export default {
|
|||||||
if (!showPopup) {
|
if (!showPopup) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.stopExperienceCouponPolling();
|
|
||||||
this.experienceCouponId = data.couponId || null;
|
this.experienceCouponId = data.couponId || null;
|
||||||
this.showExperienceCouponPopup = true;
|
this.showExperienceCouponPopup = true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user