's'
This commit is contained in:
@@ -57,6 +57,13 @@ function clearAnonymousUserCookie(): void {
|
||||
clearCookie(ANONYMOUS_USER_COOKIE);
|
||||
}
|
||||
|
||||
function getWechatUserIdFromStorage(): string {
|
||||
return (
|
||||
(getStorage("wechatUserId") || "").trim() ||
|
||||
(getStorage("userid") || "").trim()
|
||||
);
|
||||
}
|
||||
|
||||
function setPayOrderCookie(orderId: string): void {
|
||||
if (typeof document === "undefined") return;
|
||||
const normalizedOrderId = orderId.trim();
|
||||
@@ -194,6 +201,14 @@ export default function HomeClient() {
|
||||
setUserName(name);
|
||||
}, []);
|
||||
|
||||
const resolveVipLookupUserId = useCallback((fallback?: string | null): string => {
|
||||
// 业务优先级:email > 真实userid > user_id
|
||||
// check-by-user 仅接收 user_id 字段,因此这里至少保证 userid > user_id
|
||||
const wechatUserId = getWechatUserIdFromStorage();
|
||||
if (wechatUserId) return wechatUserId;
|
||||
return (fallback || "").trim();
|
||||
}, []);
|
||||
|
||||
const recoverAnonymousUserId = useCallback(
|
||||
async (params: { userId?: string; email?: string; wechatUserId?: string }) => {
|
||||
const payload: Record<string, string> = {};
|
||||
@@ -745,8 +760,7 @@ export default function HomeClient() {
|
||||
|
||||
// 校验逻辑:有本地存储(登录资料+VIP)时优先使用并校验;无身份/VIP 时点击按钮直接进入支付,不校验
|
||||
const wechatUserId =
|
||||
(getStorage("wechatUserId") || "").trim() ||
|
||||
(getStorage("userid") || "").trim();
|
||||
getWechatUserIdFromStorage();
|
||||
let anonymousCandidate = getStoredAnonymousUserId();
|
||||
// 参数 userid 是真实微信用户标识时,应优先用它校验 VIP,避免被历史/新生成 userId 干扰
|
||||
if (wechatUserId) {
|
||||
@@ -886,7 +900,9 @@ export default function HomeClient() {
|
||||
|
||||
// 仅当有本地存储的 userId 时才校验(无身份/VIP 时跳过,点击按钮直接进入支付流程)
|
||||
if (hadStoredUserId) {
|
||||
const userIdForCheck = getStoredAnonymousUserId() || getStorage("userId");
|
||||
const userIdForCheck = resolveVipLookupUserId(
|
||||
getStoredAnonymousUserId() || getStorage("userId")
|
||||
);
|
||||
if (userIdForCheck) {
|
||||
const found = await checkPaymentFromPB(userIdForCheck);
|
||||
if (found) {
|
||||
@@ -903,6 +919,7 @@ export default function HomeClient() {
|
||||
getOrCreateUserId,
|
||||
getStoredAnonymousUserId,
|
||||
checkPaymentFromPB,
|
||||
resolveVipLookupUserId,
|
||||
recoverAnonymousUserId,
|
||||
savePaidType,
|
||||
saveUserName,
|
||||
|
||||
Reference in New Issue
Block a user