diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/payment/result/result.vue b/CoreCms.Net.Uni-App/CoreShop/pages/payment/result/result.vue index 0b36311d..fc52f50f 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/payment/result/result.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/payment/result/result.vue @@ -68,14 +68,25 @@ }, methods: { doGetData() { + const _this = this; + let time = '', i = 0; uni.showLoading({ title: '获取支付结果中', mask: true }); - var _this = this; - setTimeout(function () { + // 3秒轮询一次,最多5次,防止微信回调及接口业务处理与支付结果实际不一致 + time = setInterval(function () { + i++; + if (i == 5 || _this.paymentInfo.status == 2) { + clearInterval(time); + setTimeout(function () { + uni.hideLoading(); + }, 500); + return; + } _this.getPaymentInfo(); - }, 2000); + }, 3000); + }, getPaymentInfo() { if (!this.paymentId) { @@ -102,13 +113,7 @@ this.orderId = info.sourceId; this.status = true; this.paymentInfo = info; - setTimeout(function () { - uni.hideLoading(); - }, 500); } else { - setTimeout(function () { - uni.hideLoading(); - }, 500); this.$u.toast(res.msg); } });