's'
This commit is contained in:
@@ -52,21 +52,48 @@ export default function JoinPage() {
|
||||
const [uploading, setUploading] = useState(false);
|
||||
const fileRef = useRef<HTMLInputElement>(null);
|
||||
const [submitted, setSubmitted] = useState(false);
|
||||
const [isVipSubmit, setIsVipSubmit] = useState(false);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [payRedirecting, setPayRedirecting] = useState(false);
|
||||
const [payEnv, setPayEnv] = useState<PayEnv | null>(null);
|
||||
const [payChannel, setPayChannel] = useState<PayChannel>("alipay");
|
||||
const [payChannel, setPayChannel] = useState<PayChannel>("wxpay");
|
||||
const [authOpen, setAuthOpen] = useState(false);
|
||||
const [pendingSubmit, setPendingSubmit] = useState(false);
|
||||
const [isAlreadyRecorded, setIsAlreadyRecorded] = useState(false);
|
||||
const [checkingStatus, setCheckingStatus] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window !== "undefined" && new URLSearchParams(window.location.search).get("paid") === "1") {
|
||||
setSubmitted(true);
|
||||
setCheckingStatus(false);
|
||||
return;
|
||||
}
|
||||
const checkExisting = async () => {
|
||||
const meRes = await fetch("/api/auth/me", { credentials: "include" });
|
||||
const meData = await meRes.json();
|
||||
if (!meData?.user) {
|
||||
setCheckingStatus(false);
|
||||
return;
|
||||
}
|
||||
const statusRes = await fetch("/api/join/status", { credentials: "include", cache: "no-store" });
|
||||
const statusData = await statusRes.json();
|
||||
if (statusData?.hasRecord && statusData?.isComplete) {
|
||||
setIsAlreadyRecorded(true);
|
||||
setSubmitted(true);
|
||||
}
|
||||
setCheckingStatus(false);
|
||||
};
|
||||
checkExisting();
|
||||
}, []);
|
||||
|
||||
usePayStatusPoll(() => setSubmitted(true));
|
||||
// 轮询到支付成功时跳转到 /join/paid,避免在 /join 重复显示成功页
|
||||
usePayStatusPoll(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
const path = window.location.pathname;
|
||||
const paidPath = path.replace(/\/join\/?$/, "") + "/join/paid";
|
||||
window.location.replace(paidPath);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
@@ -97,6 +124,15 @@ export default function JoinPage() {
|
||||
setSubmitted(true);
|
||||
return;
|
||||
}
|
||||
// 再次确认 VIP,防止 handleAuthSuccess 等路径绕过
|
||||
const vipRes2 = await fetch("/api/vip/check", { credentials: "include", cache: "no-store" });
|
||||
const vipData2 = await vipRes2.json();
|
||||
if (vipData2?.vip) {
|
||||
setIsVipSubmit(true);
|
||||
setSubmitted(true);
|
||||
setSubmitting(false);
|
||||
return;
|
||||
}
|
||||
setSubmitting(false);
|
||||
setPayRedirecting(true);
|
||||
const returnUrl = `${window.location.origin}${window.location.pathname}/paid`;
|
||||
@@ -127,6 +163,11 @@ export default function JoinPage() {
|
||||
setAuthOpen(true);
|
||||
return;
|
||||
}
|
||||
const vipRes = await fetch("/api/vip/check", { credentials: "include", cache: "no-store" });
|
||||
const vipData = await vipRes.json();
|
||||
if (vipData?.vip) {
|
||||
setIsVipSubmit(true);
|
||||
}
|
||||
await doSubmit();
|
||||
};
|
||||
|
||||
@@ -145,11 +186,11 @@ export default function JoinPage() {
|
||||
<div className="mx-auto mb-5 flex h-20 w-20 items-center justify-center rounded-full bg-emerald-50 dark:bg-emerald-900/30 text-5xl">
|
||||
✅
|
||||
</div>
|
||||
<h2 className="text-2xl font-bold text-slate-800 dark:text-slate-100">申请已提交</h2>
|
||||
<h2 className="text-2xl font-bold text-slate-800 dark:text-slate-100">
|
||||
{isAlreadyRecorded ? "资料已录入" : isVipSubmit ? "提交成功" : "支付成功"}
|
||||
</h2>
|
||||
<p className="mt-3 text-slate-500 dark:text-slate-400">
|
||||
我们会尽快审核你的信息
|
||||
<br />
|
||||
审核通过后将通过微信邀请你入群
|
||||
{isAlreadyRecorded ? "您的报名信息已录入,无需重复提交" : isVipSubmit ? "感谢您的参与" : "感谢您的支持"}
|
||||
</p>
|
||||
<Link
|
||||
href="/"
|
||||
@@ -162,6 +203,14 @@ export default function JoinPage() {
|
||||
);
|
||||
}
|
||||
|
||||
if (checkingStatus) {
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center bg-[#f0f4f8] dark:bg-gray-950 px-4">
|
||||
<div className="text-slate-500 dark:text-slate-400">加载中…</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-[#f0f4f8] dark:bg-gray-950">
|
||||
<div className="mx-auto max-w-2xl px-0 py-0 sm:px-6 sm:py-10 lg:py-14">
|
||||
|
||||
Reference in New Issue
Block a user