【优化】支付成功后跳转到的查询结构,从立即获取后反馈,调整为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: {
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);
}
});