From bed0e6c4be420963fecfc4c15cfcae5fb112d83f Mon Sep 17 00:00:00 2001 From: xingyy <64720302+Concur-max@users.noreply.github.com> Date: Fri, 28 Feb 2025 15:59:44 +0800 Subject: [PATCH 01/31] =?UTF-8?q?fix(payment):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E7=BB=93=E6=9E=9C=E9=A1=B5=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E8=BD=AE=E8=AF=A2=E9=80=BB=E8=BE=91=E5=92=8C=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=20URL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新了 Checkout 页面的返回 URL,使用动态获取的窗口位置替代硬编码的 IP 地址 - 优化了支付结果页面的轮询逻辑: - 增加了对 5 秒轮询时间的检查,避免长时间轮询 - 调整了轮询停止的条件,只在支付成功时停止轮询 - 对支付结果页面的 HTML 结构进行了轻微的调整,提高了代码的可读性 --- app/pages/payment/checkoutPage/index.vue | 2 +- app/pages/payment/result/index.vue | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/pages/payment/checkoutPage/index.vue b/app/pages/payment/checkoutPage/index.vue index 90da516..39f872a 100644 --- a/app/pages/payment/checkoutPage/index.vue +++ b/app/pages/payment/checkoutPage/index.vue @@ -41,7 +41,7 @@ async function handleSubmit(e) { const { error } = await stripe.confirmPayment({ elements: elements.value, confirmParams: { - return_url: "http://192.168.88.68:3000/payment/result?orderNo="+payUid.value, + return_url: `${window.location.origin}/payment/result?orderNo=${payUid.value}`, }, }) diff --git a/app/pages/payment/result/index.vue b/app/pages/payment/result/index.vue index a8f412a..db87be4 100644 --- a/app/pages/payment/result/index.vue +++ b/app/pages/payment/result/index.vue @@ -14,21 +14,28 @@ let timer = null let startTime = Date.now() const queryOrder = async () => { + // 首先检查是否已经超过5秒 + if (Date.now() - startTime > 5000) { + clearInterval(timer) + closeToast() + return + } + showLoadingToast({ message: '加载中...', forbidClick: true, }); - + try { const res = await orderQuery({ orderNo: route.query.orderNo }) - + if (res.status === 0) { resData.value = res.data - - // 如果状态为1或者超过5秒,停止轮询 - if (resData.value.status === 1 || Date.now() - startTime > 5000) { + + // 只在支付成功时停止轮询 + if (resData.value.status === 1) { clearInterval(timer) closeToast() } @@ -68,11 +75,12 @@ const goHome = () => {