's'
This commit is contained in:
@@ -80,7 +80,7 @@ export async function GET(request: NextRequest) {
|
|||||||
try {
|
try {
|
||||||
const { status, data } = await getSalonApi(
|
const { status, data } = await getSalonApi(
|
||||||
request,
|
request,
|
||||||
`/api/salon/join/by-wechat?wechat_id=${encodeURIComponent(wechatId)}`,
|
`/api/salon/join/by-wechat?wechat_id=${encodeURIComponent(wechatId)}&_=${Date.now()}`,
|
||||||
{ timeoutMs: 6000 }
|
{ timeoutMs: 6000 }
|
||||||
);
|
);
|
||||||
if (status === 200 && data && typeof data === "object") {
|
if (status === 200 && data && typeof data === "object") {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { usePathname } from "next/navigation";
|
||||||
|
|
||||||
const WECHAT_STORAGE_KEY = "salon_join_wechat";
|
const WECHAT_STORAGE_KEY = "salon_join_wechat";
|
||||||
|
|
||||||
@@ -76,6 +77,8 @@ export default function MyRegistrationStatus() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const pathname = usePathname();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof window === "undefined") return;
|
if (typeof window === "undefined") return;
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
@@ -90,16 +93,23 @@ export default function MyRegistrationStatus() {
|
|||||||
if (e.persisted && !cancelled) fetchStatus();
|
if (e.persisted && !cancelled) fetchStatus();
|
||||||
};
|
};
|
||||||
window.addEventListener("vip:updated", onUpdate);
|
window.addEventListener("vip:updated", onUpdate);
|
||||||
|
window.addEventListener("registration:refresh", onUpdate);
|
||||||
document.addEventListener("visibilitychange", onVisibilityChange);
|
document.addEventListener("visibilitychange", onVisibilityChange);
|
||||||
window.addEventListener("pageshow", onPageShow);
|
window.addEventListener("pageshow", onPageShow);
|
||||||
return () => {
|
return () => {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
window.removeEventListener("vip:updated", onUpdate);
|
window.removeEventListener("vip:updated", onUpdate);
|
||||||
|
window.removeEventListener("registration:refresh", onUpdate);
|
||||||
document.removeEventListener("visibilitychange", onVisibilityChange);
|
document.removeEventListener("visibilitychange", onVisibilityChange);
|
||||||
window.removeEventListener("pageshow", onPageShow);
|
window.removeEventListener("pageshow", onPageShow);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// 每次进入首页时强制重新拉取,避免预取/缓存导致显示旧状态
|
||||||
|
useEffect(() => {
|
||||||
|
if (pathname === "/") fetchStatus();
|
||||||
|
}, [pathname]);
|
||||||
|
|
||||||
if (loading || !data?.hasRecord || !data.record) return null;
|
if (loading || !data?.hasRecord || !data.record) return null;
|
||||||
|
|
||||||
const rec = data.record;
|
const rec = data.record;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState, useEffect, useRef, type FormEvent } from "react";
|
import { useState, useEffect, useRef, type FormEvent } from "react";
|
||||||
|
import { usePathname } from "next/navigation";
|
||||||
import { useCompleteOrderPolling } from "@/app/hooks/useCompleteOrderPolling";
|
import { useCompleteOrderPolling } from "@/app/hooks/useCompleteOrderPolling";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import ThemeToggle from "../components/ThemeToggle";
|
import ThemeToggle from "../components/ThemeToggle";
|
||||||
@@ -524,6 +525,15 @@ export default function JoinPage() {
|
|||||||
retryDelays: [500, 1000, 1500, 2500, 4000],
|
retryDelays: [500, 1000, 1500, 2500, 4000],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const pathname = usePathname();
|
||||||
|
// 每次进入报名页时强制重新拉取,避免预取/缓存导致显示旧状态
|
||||||
|
useEffect(() => {
|
||||||
|
if (pathname === "/join") {
|
||||||
|
const w = (localStorage.getItem(WECHAT_STORAGE_KEY) || "").trim();
|
||||||
|
if (w && WECHAT_REGEX.test(w)) fetchByWechatRef.current(w);
|
||||||
|
}
|
||||||
|
}, [pathname]);
|
||||||
|
|
||||||
// 微信内/手机浏览器支付后:页面可能被关闭或跳转,返回时 notify 可能未到。轮询 fetchByWechat 检测支付成功
|
// 微信内/手机浏览器支付后:页面可能被关闭或跳转,返回时 notify 可能未到。轮询 fetchByWechat 检测支付成功
|
||||||
// 手机浏览器唤醒微信 app 支付完成后,用户可能直接回 /join,故 h5 也需轮询(参考 nomadvip)
|
// 手机浏览器唤醒微信 app 支付完成后,用户可能直接回 /join,故 h5 也需轮询(参考 nomadvip)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export function applyCompleteSuccess(data: { token?: string; record?: { wechatId
|
|||||||
}
|
}
|
||||||
window.dispatchEvent(new CustomEvent("auth:updated"));
|
window.dispatchEvent(new CustomEvent("auth:updated"));
|
||||||
window.dispatchEvent(new CustomEvent("vip:updated"));
|
window.dispatchEvent(new CustomEvent("vip:updated"));
|
||||||
|
window.dispatchEvent(new CustomEvent("registration:refresh"));
|
||||||
if (record?.wechatId) {
|
if (record?.wechatId) {
|
||||||
try {
|
try {
|
||||||
localStorage.setItem(WECHAT_STORAGE_KEY, record.wechatId);
|
localStorage.setItem(WECHAT_STORAGE_KEY, record.wechatId);
|
||||||
|
|||||||
Reference in New Issue
Block a user