sync:订单结果页添加支付询问对话框,版本获取方法修改,更新README https://gitee.com/sheepjs/shopro-uniapp/commit/024f311235266334063d25b7fec604b22e613ea9

This commit is contained in:
YunaiV
2025-04-28 00:01:33 +08:00
parent 9e96df4651
commit e9ebe236e6
8 changed files with 123 additions and 96 deletions
+25 -6
View File
@@ -97,6 +97,24 @@
}
});
function showRepayModal() {
if (state.result !== 'failed') return;
uni.showModal({
title: '确认支付',
content: '未检测到您的支付结果,请确认您是否已经支付完成?',
cancelText: '取消',
confirmText: '我已支付',
success: function (res) {
if (res.confirm) {
state.counter = 0;
setTimeout(() => {
getOrderInfo(state.orderId);
}, 100);
}
},
});
}
// 获得订单信息
async function getOrderInfo(id) {
state.counter++;
@@ -137,15 +155,16 @@
return;
}
}
// 2.1 情况三一:未支付,且轮询次数小于次,则继续轮询
if (state.counter < 3 && state.result === 'unpaid') {
// 2.1 情况三一:未支付,且轮询次数小于次,则继续轮询
if (state.counter < 5 && state.result === 'unpaid') {
setTimeout(() => {
getOrderInfo(id);
}, 1500);
}, 2000);
}
// 2.2 情况二:超过次检测才判断为支付失败
if (state.counter >= 3) {
// 2.2 情况二:超过次检测才判断为支付失败
if (state.counter >= 5) {
state.result = 'failed';
showRepayModal();
}
}
@@ -203,7 +222,7 @@
if (options.payState === 'fail') {
state.result = 'failed';
} else {
// 轮询次检测订单支付结果
// 轮询次检测订单支付结果
await getOrderInfo(state.id);
}
});