This commit is contained in:
eric
2026-03-13 05:14:28 -05:00
parent f66859c032
commit 8a095f7d45
13 changed files with 820 additions and 132 deletions

View File

@@ -5,6 +5,13 @@ import { Link } from "@/i18n/navigation";
const DEFAULT_PASSWORD = "12345678";
function clearPendingOrder(): void {
try {
localStorage.removeItem("join_pay_order");
} catch {}
document.cookie = "join_pay_order=; path=/; max-age=0";
}
/**
* 支付完成回跳页
* Z-Pay 的 return_url 不支持带查询参数,故使用 /join/paid 作为专用成功页
@@ -60,9 +67,17 @@ export default function JoinPaidPage() {
const run = async () => {
const cookie = document.cookie.split(";").find((c) => c.trim().startsWith("join_pay_order="));
const rawValue = cookie?.split("=")[1]?.trim();
const decoded = rawValue ? decodeURIComponent(rawValue) : "";
const storageValue = (() => {
try {
return localStorage.getItem("join_pay_order") || "";
} catch {
return "";
}
})();
const decoded = rawValue ? decodeURIComponent(rawValue) : storageValue;
const orderId = decoded.split("|")[0]?.trim() || "";
if (!orderId) {
clearPendingOrder();
window.location.replace(`/${window.location.pathname.split("/")[1] || "zh"}/join`);
return;
}
@@ -75,7 +90,7 @@ export default function JoinPaidPage() {
try {
const result = await tryComplete(orderId);
if (result.ok) {
document.cookie = "join_pay_order=; path=/; max-age=0";
clearPendingOrder();
if (!cancelled) setCompleteStatus("success");
return;
}