's'
This commit is contained in:
@@ -141,6 +141,8 @@ export default function JoinPage() {
|
||||
const [fromVolunteer, setFromVolunteer] = useState(false);
|
||||
const [paying, setPaying] = useState(false);
|
||||
const initialWechatCheckDone = useRef(false);
|
||||
const lastSubmitTime = useRef(0);
|
||||
const SUBMIT_THROTTLE_MS = 2000;
|
||||
|
||||
const fetchByWechat = async (w: string) => {
|
||||
if (!w.trim()) return;
|
||||
@@ -243,6 +245,26 @@ export default function JoinPage() {
|
||||
const handleSubmit = async (e: FormEvent) => {
|
||||
e.preventDefault();
|
||||
setError(null);
|
||||
|
||||
const now = Date.now();
|
||||
if (now - lastSubmitTime.current < SUBMIT_THROTTLE_MS) {
|
||||
return;
|
||||
}
|
||||
if (userRecord?.hasRecord) {
|
||||
setError("该微信号已报名,请勿重复提交");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const checkRes = await fetch(`/api/join/by-wechat?wechat_id=${encodeURIComponent(wechat.trim())}`, { cache: "no-store" });
|
||||
const checkData = await checkRes.json();
|
||||
if (checkData?.hasRecord) {
|
||||
setError("该微信号已报名,请勿重复提交");
|
||||
fetchByWechat(wechat.trim());
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
/* 校验失败时继续提交,由后端兜底 */
|
||||
}
|
||||
if (xiaohongshuUrl.trim() && urlError) {
|
||||
setError("请先修正小红书链接");
|
||||
return;
|
||||
@@ -263,6 +285,7 @@ export default function JoinPage() {
|
||||
setError("请选择性别");
|
||||
return;
|
||||
}
|
||||
lastSubmitTime.current = now;
|
||||
setSubmitting(true);
|
||||
try {
|
||||
const formGenderFemale = gender === "女" || gender === "female";
|
||||
|
||||
Reference in New Issue
Block a user