【优化】支付成功后跳转到的查询结构,从立即获取后反馈,调整为3秒轮询一次,最多5次,防止微信回调及接口业务处理与支付结果存在时间差导致实际显示不一致。

This commit is contained in:
jianweie code
2023-07-03 21:37:34 +08:00
parent 75958d1dac
commit 29ae6010b6

View File

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