'style1'
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { postSalonApi } from "@/app/lib/salonApi";
|
||||
import { getAdminToken } from "@/app/lib/pocketbase/admin";
|
||||
import { getPocketBaseConfig } from "@/config/services.config";
|
||||
import { COOKIE_NAME } from "@/app/lib/auth-cookie";
|
||||
|
||||
function getUserIdFromCookie(request: NextRequest): string | null {
|
||||
@@ -13,42 +15,73 @@ function getUserIdFromCookie(request: NextRequest): string | null {
|
||||
}
|
||||
}
|
||||
|
||||
function generateAnonId(): string {
|
||||
return "anon_" + crypto.randomUUID().replace(/-/g, "");
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const userId = getUserIdFromCookie(request);
|
||||
if (!userId) {
|
||||
return NextResponse.json({ ok: false, error: "请先登录" }, { status: 401 });
|
||||
}
|
||||
const body = await request.json();
|
||||
const formData = body && typeof body === "object" ? body : {};
|
||||
|
||||
const record = {
|
||||
user_id: userId,
|
||||
nickname: formData.nickname || "",
|
||||
occupation: formData.profession || "",
|
||||
reason: formData.intro || "",
|
||||
single: formData.single || "",
|
||||
wechatId: formData.wechat || "",
|
||||
gender: formData.gender || "",
|
||||
education: formData.education || "",
|
||||
gradYear: formData.graduationYear || "",
|
||||
phone: formData.phone || "",
|
||||
media: formData.media || "",
|
||||
};
|
||||
const nickname = String(formData.nickname || "").trim();
|
||||
const city = String(formData.city || "").trim();
|
||||
const session = String(formData.session || "").trim();
|
||||
const ageRange = String(formData.age_range || "").trim();
|
||||
const wechatOrPhone = String(formData.wechat_or_phone || "").trim();
|
||||
const intro = String(formData.intro || "").trim();
|
||||
const firstTime = String(formData.first_time || "").trim();
|
||||
const agreeRules = !!formData.agree_rules;
|
||||
|
||||
const { status, data } = await postSalonApi(request, "/api/salon/join", record);
|
||||
if (status >= 500) {
|
||||
const payload = typeof data === "object" && data !== null ? (data as Record<string, unknown>) : {};
|
||||
if (!nickname || !wechatOrPhone || !intro || !session || !agreeRules) {
|
||||
return NextResponse.json(
|
||||
{ ok: false, error: (payload.detail as string) || (payload.error as string) || "提交失败" },
|
||||
{ status: 503 }
|
||||
{ ok: false, error: "请填写必填项" },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
if (status >= 400) {
|
||||
return NextResponse.json(data, { status });
|
||||
|
||||
const userId = getUserIdFromCookie(request) || generateAnonId();
|
||||
|
||||
const record = {
|
||||
user_id: userId,
|
||||
nickname,
|
||||
occupation: city,
|
||||
reason: intro,
|
||||
wechatId: wechatOrPhone,
|
||||
gender: "",
|
||||
education: "",
|
||||
gradYear: "",
|
||||
phone: wechatOrPhone,
|
||||
single: "",
|
||||
media: "",
|
||||
type: session,
|
||||
order_id: "",
|
||||
amount: 0,
|
||||
age_range: ageRange,
|
||||
first_time: firstTime,
|
||||
};
|
||||
|
||||
try {
|
||||
const { status, data } = await postSalonApi(request, "/api/salon/join", record);
|
||||
if (status >= 500) {
|
||||
const payload = typeof data === "object" && data !== null ? (data as Record<string, unknown>) : {};
|
||||
return NextResponse.json(
|
||||
{ ok: false, error: (payload.detail as string) || (payload.error as string) || "提交失败" },
|
||||
{ status: 503 }
|
||||
);
|
||||
}
|
||||
if (status >= 400) {
|
||||
const payload = typeof data === "object" && data !== null ? (data as Record<string, unknown>) : {};
|
||||
const errMsg = (payload.error as string) || (payload.detail as string) || "提交失败";
|
||||
if (status === 401) {
|
||||
return tryPocketBaseDirect(record, errMsg);
|
||||
}
|
||||
return NextResponse.json({ ok: false, error: errMsg }, { status });
|
||||
}
|
||||
return NextResponse.json({ ok: true });
|
||||
} catch {
|
||||
return tryPocketBaseDirect(record, "服务暂时不可用");
|
||||
}
|
||||
const payload = typeof data === "object" && data !== null ? (data as Record<string, unknown>) : {};
|
||||
return NextResponse.json({ ok: true, user_id: payload.user_id ?? userId });
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : String(e);
|
||||
console.error("Join API error:", e);
|
||||
@@ -58,3 +91,58 @@ export async function POST(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function tryPocketBaseDirect(
|
||||
record: Record<string, unknown>,
|
||||
fallbackError: string
|
||||
): Promise<NextResponse> {
|
||||
const token = await getAdminToken();
|
||||
if (!token) {
|
||||
return NextResponse.json({ ok: false, error: fallbackError }, { status: 503 });
|
||||
}
|
||||
|
||||
const pb = getPocketBaseConfig();
|
||||
const base = pb.url.replace(/\/$/, "");
|
||||
const url = `${base}/api/collections/${pb.joinCollection}/records`;
|
||||
|
||||
const body: Record<string, unknown> = {
|
||||
user_id: record.user_id,
|
||||
nickname: record.nickname,
|
||||
occupation: record.occupation ?? "",
|
||||
reason: [record.reason, record.age_range, record.first_time].filter(Boolean).join(" | "),
|
||||
wechatId: record.wechatId ?? "",
|
||||
gender: record.gender ?? "",
|
||||
education: record.education ?? "",
|
||||
gradYear: record.gradYear ?? "",
|
||||
phone: record.phone ?? "",
|
||||
single: record.single ?? "",
|
||||
media: record.media ?? "",
|
||||
type: record.type ?? "",
|
||||
order_id: record.order_id ?? "",
|
||||
amount: record.amount ?? 0,
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const errData = await res.json().catch(() => ({}));
|
||||
const msg = (errData as { message?: string }).message || fallbackError;
|
||||
return NextResponse.json({ ok: false, error: msg }, { status: res.status });
|
||||
}
|
||||
return NextResponse.json({ ok: true });
|
||||
} catch (e) {
|
||||
console.error("PocketBase direct write error:", e);
|
||||
return NextResponse.json(
|
||||
{ ok: false, error: fallbackError },
|
||||
{ status: 503 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ export default function Footer() {
|
||||
return (
|
||||
<footer className="border-t border-gray-200 dark:border-gray-800 mt-12 py-8">
|
||||
<div className="max-w-[1400px] mx-auto px-5 sm:px-10 text-center text-sm text-gray-500 dark:text-gray-400">
|
||||
<p>© {new Date().getFullYear()} Salon. 探索中国,远程工作,自由生活。</p>
|
||||
<p>© {new Date().getFullYear()} Salon. 北京周末新朋友活动。</p>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
|
||||
@@ -1,158 +1,8 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useCallback, useEffect, useRef } from "react";
|
||||
import Link from "next/link";
|
||||
import JoinModal from "./JoinModal";
|
||||
import {
|
||||
getPayEnv,
|
||||
redirectToPay,
|
||||
getDeviceFromEnv,
|
||||
} from "@/app/lib/payment";
|
||||
import type { PayChannel } from "@/app/lib/payment";
|
||||
|
||||
const avatarPhotos = [
|
||||
"https://i.pravatar.cc/150?img=32",
|
||||
"https://i.pravatar.cc/150?img=33",
|
||||
"https://i.pravatar.cc/150?img=25",
|
||||
"https://i.pravatar.cc/150?img=52",
|
||||
"https://i.pravatar.cc/150?img=44",
|
||||
];
|
||||
|
||||
function isPrivateDevHost(hostname: string): boolean {
|
||||
if (!hostname) return false;
|
||||
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1") return true;
|
||||
if (/^10\./.test(hostname) || /^192\.168\./.test(hostname)) return true;
|
||||
const match = hostname.match(/^172\.(\d{1,2})\./);
|
||||
if (!match) return false;
|
||||
const secondOctet = Number(match[1]);
|
||||
return secondOctet >= 16 && secondOctet <= 31;
|
||||
}
|
||||
|
||||
function buildPendingUserId(email: string): string {
|
||||
return (
|
||||
"pending_" +
|
||||
Array.from(new TextEncoder().encode(email))
|
||||
.map((b) => b.toString(16).padStart(2, "0"))
|
||||
.join("")
|
||||
);
|
||||
}
|
||||
|
||||
export default function HeroSection() {
|
||||
const [email, setEmail] = useState("");
|
||||
const [joinModalOpen, setJoinModalOpen] = useState(false);
|
||||
const [joinModalVipOnly, setJoinModalVipOnly] = useState(false);
|
||||
const [checking, setChecking] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const checkAuth = async () => {
|
||||
try {
|
||||
const res = await fetch("/api/auth/me", { credentials: "include" });
|
||||
const data = await res.json();
|
||||
setIsLoggedIn(!!data?.user);
|
||||
} catch {
|
||||
setIsLoggedIn(false);
|
||||
}
|
||||
};
|
||||
checkAuth();
|
||||
const onAuth = () => checkAuth();
|
||||
window.addEventListener("auth:updated", onAuth);
|
||||
return () => window.removeEventListener("auth:updated", onAuth);
|
||||
}, []);
|
||||
|
||||
const checkUserCacheRef = useRef<{ email: string; data: { exists: boolean; vip: boolean }; ts: number } | null>(null);
|
||||
const CACHE_TTL_MS = 60_000;
|
||||
|
||||
const handleCheckAndProceed = useCallback(
|
||||
async (em: string) => {
|
||||
if (checking) return;
|
||||
const trimmed = em.trim();
|
||||
if (!trimmed) {
|
||||
setError("请输入邮箱");
|
||||
return;
|
||||
}
|
||||
setError(null);
|
||||
setChecking(true);
|
||||
try {
|
||||
const cached = checkUserCacheRef.current;
|
||||
if (cached && cached.email === trimmed && Date.now() - cached.ts < CACHE_TTL_MS) {
|
||||
const { exists, vip } = cached.data;
|
||||
if (exists) {
|
||||
setJoinModalVipOnly(!!vip);
|
||||
setJoinModalOpen(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const checkRes = await fetch("/api/salon/check-user", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ email: trimmed }),
|
||||
credentials: "include",
|
||||
});
|
||||
const checkData = await checkRes.json();
|
||||
if (!checkRes.ok || !checkData?.ok) {
|
||||
throw new Error(checkData?.error || checkData?.detail || "操作失败");
|
||||
}
|
||||
if (checkData.exists) {
|
||||
checkUserCacheRef.current = { email: trimmed, data: { exists: true, vip: !!checkData.vip }, ts: Date.now() };
|
||||
setJoinModalVipOnly(!!checkData.vip);
|
||||
setJoinModalOpen(true);
|
||||
return;
|
||||
}
|
||||
const shouldPrecreateUser =
|
||||
typeof window !== "undefined" &&
|
||||
isPrivateDevHost(window.location.hostname);
|
||||
let user_id = buildPendingUserId(trimmed);
|
||||
if (shouldPrecreateUser) {
|
||||
const ensureRes = await fetch("/api/salon/ensure-user", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ email: trimmed }),
|
||||
credentials: "include",
|
||||
});
|
||||
const ensureData = await ensureRes.json();
|
||||
if (!ensureRes.ok || !ensureData?.ok || !ensureData?.user_id) {
|
||||
throw new Error(ensureData?.error || ensureData?.detail || "创建用户失败");
|
||||
}
|
||||
if (ensureData.is_new) {
|
||||
await fetch("/api/salon/set-needs-password-change", { method: "POST", credentials: "include" });
|
||||
}
|
||||
user_id = String(ensureData.user_id).trim();
|
||||
if (ensureData?.token && ensureData?.record) {
|
||||
await fetch("/api/auth/sync-session", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ token: ensureData.token, record: ensureData.record }),
|
||||
credentials: "include",
|
||||
});
|
||||
}
|
||||
}
|
||||
const returnUrl =
|
||||
typeof window !== "undefined" ? `${window.location.origin}/join/paid` : "/join/paid";
|
||||
const env = getPayEnv();
|
||||
const channel: PayChannel = "wxpay";
|
||||
redirectToPay({
|
||||
user_id,
|
||||
return_url: returnUrl,
|
||||
channel,
|
||||
device: getDeviceFromEnv(env),
|
||||
useJoinConfig: true,
|
||||
});
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "操作失败");
|
||||
} finally {
|
||||
setChecking(false);
|
||||
}
|
||||
},
|
||||
[checking]
|
||||
);
|
||||
|
||||
const handleJoinClick = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
handleCheckAndProceed(email);
|
||||
};
|
||||
|
||||
return (
|
||||
<section className="relative overflow-hidden">
|
||||
<div className="absolute inset-0 bg-gradient-to-b from-orange-50/70 via-white to-[#fafafa] dark:from-gray-950 dark:via-gray-900 dark:to-gray-950" />
|
||||
@@ -168,26 +18,26 @@ export default function HeroSection() {
|
||||
<div className="flex flex-col lg:flex-row lg:items-start lg:gap-10 xl:gap-16">
|
||||
<div className="flex-1 min-w-0">
|
||||
<span className="inline-flex items-center gap-1.5 text-xs font-semibold text-orange-700 dark:text-orange-400 bg-orange-100 dark:bg-orange-900/30 px-3 py-1.5 rounded-full mb-5">
|
||||
🏆 数字游民首选
|
||||
📍 北京周末
|
||||
</span>
|
||||
|
||||
<h1 className="text-3xl sm:text-4xl md:text-5xl lg:text-6xl font-bold tracking-tight leading-tight mb-5">
|
||||
<span className="hero-gradient-text">探索中国</span>
|
||||
<span className="hero-gradient-text">认识新朋友</span>
|
||||
<br />
|
||||
<span className="text-gray-900 dark:text-gray-100">远程工作,自由生活</span>
|
||||
<span className="text-gray-900 dark:text-gray-100">不尬聊,不乱收费</span>
|
||||
</h1>
|
||||
|
||||
<p className="text-base sm:text-lg text-gray-500 dark:text-gray-400 max-w-2xl mb-7 leading-relaxed">
|
||||
加入全球数字游民社区,发现中国最适合远程工作和生活的城市
|
||||
公开场地,小组活动,规则透明。先看场次,再决定要不要报名
|
||||
</p>
|
||||
|
||||
<div className="space-y-2.5 mb-8">
|
||||
{[
|
||||
{ icon: "🍹", text: "线下聚会与线上分享" },
|
||||
{ icon: "❤️", text: "结识志同道合的伙伴" },
|
||||
{ icon: "🧪", text: "探索新城市与新可能" },
|
||||
{ icon: "🌎", text: "全球数字游民网络" },
|
||||
{ icon: "💬", text: "社区互助与资源共享" },
|
||||
{ icon: "📍", text: "公开场地,地址提前告知" },
|
||||
{ icon: "👥", text: "小组活动,人数可控" },
|
||||
{ icon: "📋", text: "规则透明,先了解再报名" },
|
||||
{ icon: "✍️", text: "填个简单表单即可,无需注册登录" },
|
||||
{ icon: "🌸", text: "女生友好的表达方式" },
|
||||
].map((f) => (
|
||||
<div key={f.icon} className="flex items-start gap-2.5">
|
||||
<span className="text-base sm:text-lg shrink-0 mt-0.5">{f.icon}</span>
|
||||
@@ -198,72 +48,34 @@ export default function HeroSection() {
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3 mb-8">
|
||||
<div className="flex -space-x-2">
|
||||
{avatarPhotos.slice(0, 8).map((src, i) => (
|
||||
<img
|
||||
key={i}
|
||||
src={src}
|
||||
alt=""
|
||||
className="w-8 h-8 sm:w-9 sm:h-9 rounded-full border-2 border-white dark:border-gray-800 shadow-sm object-cover"
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<span className="text-sm text-gray-500 dark:text-gray-400">
|
||||
已有 5,000+ 成员加入
|
||||
</span>
|
||||
</div>
|
||||
<Link
|
||||
href="/join"
|
||||
className="inline-flex items-center gap-2 bg-[#ff4d4f] hover:bg-[#ff3333] dark:hover:bg-[#ff5c5e] text-white px-6 py-3 rounded-lg text-sm font-semibold transition-colors active:scale-[0.98]"
|
||||
>
|
||||
查看本周场次,去报名 →
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="lg:w-[360px] xl:w-[400px] shrink-0 mt-10 lg:mt-4">
|
||||
<div className="bg-white dark:bg-gray-900 rounded-2xl shadow-xl overflow-hidden border border-gray-100 dark:border-gray-800">
|
||||
<div className="relative h-48 sm:h-56 bg-gradient-to-br from-emerald-400 via-teal-500 to-cyan-600 flex items-center justify-center overflow-hidden">
|
||||
<button className="relative w-16 h-16 rounded-full bg-white/95 flex items-center justify-center shadow-lg hover:scale-110 transition-transform">
|
||||
<svg className="w-7 h-7 text-emerald-600 ml-1" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M8 5v14l11-7z" />
|
||||
</svg>
|
||||
</button>
|
||||
<div className="text-center text-white px-6">
|
||||
<p className="text-lg sm:text-xl font-semibold mb-2">轻报名</p>
|
||||
<p className="text-sm opacity-90">不先登录,不先付款</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!isLoggedIn ? (
|
||||
<form onSubmit={handleJoinClick} className="p-4 sm:p-5">
|
||||
<input
|
||||
type="email"
|
||||
value={email}
|
||||
onChange={(e) => { setEmail(e.target.value); setError(null); }}
|
||||
placeholder="输入邮箱,加入社区"
|
||||
className="w-full border border-gray-200 dark:border-gray-700 rounded-lg px-4 py-3 text-sm placeholder-gray-400 dark:placeholder-gray-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-[#ff4d4f]/20 focus:border-[#ff4d4f] transition-colors mb-3"
|
||||
/>
|
||||
{error && (
|
||||
<p className="mb-3 text-sm text-red-600 dark:text-red-400">{error}</p>
|
||||
)}
|
||||
<button
|
||||
type="submit"
|
||||
disabled={checking}
|
||||
className="w-full bg-[#ff4d4f] hover:bg-[#ff3333] dark:hover:bg-[#ff5c5e] text-white py-3 rounded-lg text-sm font-semibold transition-colors active:scale-[0.98] disabled:opacity-70"
|
||||
>
|
||||
{checking ? "处理中…" : "加入社区 →"}
|
||||
</button>
|
||||
</form>
|
||||
) : (
|
||||
<div className="p-4 sm:p-5 text-center">
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400">
|
||||
您已登录,可前往社区参与互动
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<JoinModal
|
||||
isOpen={joinModalOpen}
|
||||
onClose={() => { setJoinModalOpen(false); setJoinModalVipOnly(false); }}
|
||||
initialEmail={email.trim()}
|
||||
vipOnly={joinModalVipOnly}
|
||||
/>
|
||||
|
||||
<div className="mt-4 flex flex-wrap gap-2 justify-center">
|
||||
<Link href="/join" className="text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 bg-white dark:bg-gray-800 rounded-full px-3 py-1.5 border border-gray-100 dark:border-gray-700 transition-colors min-h-[2rem] inline-flex items-center">
|
||||
💬 加入社区
|
||||
</Link>
|
||||
<div className="p-4 sm:p-5">
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400 mb-4">
|
||||
选好场次,填个简单表单即可参与
|
||||
</p>
|
||||
<Link
|
||||
href="/join"
|
||||
className="block w-full text-center bg-[#ff4d4f] hover:bg-[#ff3333] dark:hover:bg-[#ff5c5e] text-white py-3 rounded-lg text-sm font-semibold transition-colors active:scale-[0.98]"
|
||||
>
|
||||
去报名 →
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,138 +1,79 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useRef, useEffect, type FormEvent, type ChangeEvent } from "react";
|
||||
import { useState, useEffect, type FormEvent } from "react";
|
||||
import Link from "next/link";
|
||||
import {
|
||||
getPayEnv,
|
||||
redirectToPay,
|
||||
getDeviceFromEnv,
|
||||
} from "@/app/lib/payment";
|
||||
import { usePayStatusPoll } from "@/app/lib/payment/usePayStatusPoll";
|
||||
import AuthModal from "@/app/components/AuthModal";
|
||||
import { SESSIONS } from "@/config/home.config";
|
||||
|
||||
const genderOptions = ["男", "女"];
|
||||
const singleOptions = ["单身", "恋爱中", "已婚"];
|
||||
const educationOptions = ["高中及以下", "大专", "本科", "硕士", "博士"];
|
||||
const graduationYears = Array.from({ length: 41 }, (_, i) => String(2026 - i));
|
||||
const ageOptions = ["18-24", "25-30", "31-35", "36-40", "40+"];
|
||||
const firstTimeOptions = ["是,第一次参加", "否,参加过类似活动"];
|
||||
|
||||
interface FormData {
|
||||
city: string;
|
||||
session: string;
|
||||
nickname: string;
|
||||
gender: string;
|
||||
single: string;
|
||||
profession: string;
|
||||
ageRange: string;
|
||||
wechatOrPhone: string;
|
||||
intro: string;
|
||||
wechat: string;
|
||||
education: string;
|
||||
graduationYear: string;
|
||||
phone: string;
|
||||
firstTime: string;
|
||||
agreeRules: boolean;
|
||||
}
|
||||
|
||||
interface MediaInfo {
|
||||
preview: string;
|
||||
url: string;
|
||||
type: "image" | "video";
|
||||
function getSessionFromUrl(): string {
|
||||
if (typeof window === "undefined") return "";
|
||||
return new URLSearchParams(window.location.search).get("session") || "";
|
||||
}
|
||||
|
||||
function getSessionInfo(sessionId: string) {
|
||||
return SESSIONS.find((s) => s.id === sessionId);
|
||||
}
|
||||
|
||||
export default function JoinPage() {
|
||||
const [form, setForm] = useState<FormData>({
|
||||
city: "北京",
|
||||
session: "",
|
||||
nickname: "",
|
||||
gender: "",
|
||||
single: "",
|
||||
profession: "",
|
||||
ageRange: "",
|
||||
wechatOrPhone: "",
|
||||
intro: "",
|
||||
wechat: "",
|
||||
education: "",
|
||||
graduationYear: "",
|
||||
phone: "",
|
||||
firstTime: "",
|
||||
agreeRules: false,
|
||||
});
|
||||
const [media, setMedia] = useState<MediaInfo | null>(null);
|
||||
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 [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();
|
||||
const sid = getSessionFromUrl();
|
||||
if (sid) setForm((prev) => ({ ...prev, session: sid }));
|
||||
}, []);
|
||||
|
||||
usePayStatusPoll((orderId) => {
|
||||
if (typeof window === "undefined") return;
|
||||
const paidPath = "/join/paid";
|
||||
const url = orderId ? `${paidPath}?order_id=${encodeURIComponent(orderId)}` : paidPath;
|
||||
window.location.replace(url);
|
||||
});
|
||||
|
||||
const set = (key: keyof FormData, value: string) =>
|
||||
const set = (key: keyof FormData, value: string | boolean) =>
|
||||
setForm((prev) => ({ ...prev, [key]: value }));
|
||||
|
||||
const doSubmit = async () => {
|
||||
const handleSubmit = async (e: FormEvent) => {
|
||||
e.preventDefault();
|
||||
setError(null);
|
||||
setSubmitting(true);
|
||||
try {
|
||||
const res = await fetch("/api/join", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ ...form, media: media?.url }),
|
||||
credentials: "include",
|
||||
body: JSON.stringify({
|
||||
city: form.city,
|
||||
session: form.session,
|
||||
nickname: form.nickname,
|
||||
age_range: form.ageRange,
|
||||
wechat_or_phone: form.wechatOrPhone,
|
||||
intro: form.intro,
|
||||
first_time: form.firstTime,
|
||||
agree_rules: form.agreeRules,
|
||||
}),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok || !data?.ok) {
|
||||
throw new Error(data?.error || "提交失败,请稍后重试");
|
||||
}
|
||||
const userId = data.user_id;
|
||||
if (!userId) {
|
||||
setSubmitted(true);
|
||||
return;
|
||||
}
|
||||
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}/join/paid`;
|
||||
const env = getPayEnv();
|
||||
const channel = "wxpay";
|
||||
const device = getDeviceFromEnv(env);
|
||||
redirectToPay({
|
||||
user_id: userId,
|
||||
return_url: returnUrl,
|
||||
channel,
|
||||
device,
|
||||
useJoinConfig: true,
|
||||
});
|
||||
return;
|
||||
setSubmitted(true);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "网络错误,请重试");
|
||||
} finally {
|
||||
@@ -140,30 +81,7 @@ export default function JoinPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = async (e: FormEvent) => {
|
||||
e.preventDefault();
|
||||
const meRes = await fetch("/api/auth/me", { credentials: "include" });
|
||||
const meData = await meRes.json();
|
||||
if (!meData?.user) {
|
||||
setPendingSubmit(true);
|
||||
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();
|
||||
};
|
||||
|
||||
const handleAuthSuccess = () => {
|
||||
setAuthOpen(false);
|
||||
if (pendingSubmit) {
|
||||
setPendingSubmit(false);
|
||||
doSubmit();
|
||||
}
|
||||
};
|
||||
const selectedSession = getSessionInfo(form.session);
|
||||
|
||||
if (submitted) {
|
||||
return (
|
||||
@@ -172,11 +90,9 @@ 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">
|
||||
{isAlreadyRecorded ? "资料已录入" : isVipSubmit ? "提交成功" : "支付成功"}
|
||||
</h2>
|
||||
<h2 className="text-2xl font-bold text-slate-800 dark:text-slate-100">报名成功</h2>
|
||||
<p className="mt-3 text-slate-500 dark:text-slate-400">
|
||||
{isAlreadyRecorded ? "您的报名信息已录入,无需重复提交" : isVipSubmit ? "感谢您的参与" : "感谢您的支持"}
|
||||
我们会尽快通过您留下的联系方式与您确认
|
||||
</p>
|
||||
<Link
|
||||
href="/"
|
||||
@@ -189,47 +105,76 @@ 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">
|
||||
<div className="overflow-hidden bg-white dark:bg-gray-900 shadow-sm sm:rounded-t-2xl">
|
||||
<div className="relative h-40 overflow-hidden bg-gradient-to-br from-sky-400 via-cyan-500 to-teal-400 sm:h-52">
|
||||
<div className="absolute inset-0 flex flex-col items-center justify-center text-white">
|
||||
<div className="text-6xl sm:text-7xl">🌍</div>
|
||||
<div className="text-6xl sm:text-7xl">📍</div>
|
||||
<div className="mt-2 text-sm font-medium opacity-80">
|
||||
数字游民社区
|
||||
北京周末新朋友活动
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="px-5 py-5 text-center sm:px-8 sm:py-7">
|
||||
<h1 className="text-xl font-bold text-slate-800 dark:text-slate-100 sm:text-2xl">
|
||||
🌍 数字游民社区报名
|
||||
活动报名
|
||||
</h1>
|
||||
<p className="mt-3 whitespace-pre-line text-sm leading-relaxed text-slate-400 dark:text-slate-500 sm:text-base">
|
||||
{"💼 结识志同道合的伙伴\n📍 线下聚会 + 线上分享\n🤝 互助成长,资源共享"}
|
||||
填个简单表单即可,无需注册登录
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{selectedSession && (
|
||||
<div className="mt-5 rounded-2xl bg-white dark:bg-gray-900 px-5 py-4 shadow-sm border border-gray-100 dark:border-gray-800">
|
||||
<p className="text-xs text-slate-500 dark:text-slate-500 mb-1">已选场次</p>
|
||||
<p className="font-medium text-slate-800 dark:text-slate-100">{selectedSession.title}</p>
|
||||
<p className="text-sm text-slate-500 dark:text-slate-500">{selectedSession.date} {selectedSession.time} · {selectedSession.place}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<form
|
||||
onSubmit={handleSubmit}
|
||||
className="mt-0 bg-white dark:bg-gray-900 px-5 pb-8 pt-2 shadow-sm sm:mt-5 sm:rounded-2xl sm:px-8 sm:py-8 sm:shadow-md border border-gray-100 dark:border-gray-800"
|
||||
>
|
||||
<div className="grid gap-0 sm:grid-cols-2 sm:gap-6">
|
||||
<Field label="🌟 昵称">
|
||||
<Field label="📍 城市">
|
||||
<input
|
||||
type="text"
|
||||
maxLength={140}
|
||||
placeholder="请输入您的昵称"
|
||||
placeholder="如:北京"
|
||||
value={form.city}
|
||||
onChange={(e) => set("city", e.target.value)}
|
||||
required
|
||||
className="form-input"
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field label="📅 想参加的场次">
|
||||
<select
|
||||
value={form.session}
|
||||
onChange={(e) => set("session", e.target.value)}
|
||||
required
|
||||
className={`form-input appearance-none ${form.session ? "text-slate-800 dark:text-slate-100" : "text-slate-400 dark:text-slate-500"}`}
|
||||
>
|
||||
<option value="" disabled>请选择</option>
|
||||
{SESSIONS.map((s) => (
|
||||
<option key={s.id} value={s.id}>
|
||||
{s.title} · {s.date} {s.time}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-0 sm:grid-cols-2 sm:gap-6">
|
||||
<Field label="昵称">
|
||||
<input
|
||||
type="text"
|
||||
maxLength={40}
|
||||
placeholder="活动中使用的称呼"
|
||||
value={form.nickname}
|
||||
onChange={(e) => set("nickname", e.target.value)}
|
||||
required
|
||||
@@ -237,222 +182,81 @@ export default function JoinPage() {
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field label="👤 性别">
|
||||
<Field label="年龄段">
|
||||
<select
|
||||
value={form.gender}
|
||||
onChange={(e) => set("gender", e.target.value)}
|
||||
value={form.ageRange}
|
||||
onChange={(e) => set("ageRange", e.target.value)}
|
||||
required
|
||||
className={`form-input appearance-none ${form.gender ? "text-slate-800 dark:text-slate-100" : "text-slate-400 dark:text-slate-500"}`}
|
||||
className={`form-input appearance-none ${form.ageRange ? "text-slate-800 dark:text-slate-100" : "text-slate-400 dark:text-slate-500"}`}
|
||||
>
|
||||
<option value="" disabled>请选择</option>
|
||||
{genderOptions.map((o) => (
|
||||
{ageOptions.map((o) => (
|
||||
<option key={o} value={o}>{o}</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-0 sm:grid-cols-2 sm:gap-6">
|
||||
<Field label="💕 感情状态">
|
||||
<select
|
||||
value={form.single}
|
||||
onChange={(e) => set("single", e.target.value)}
|
||||
required
|
||||
className={`form-input appearance-none ${form.single ? "text-slate-800 dark:text-slate-100" : "text-slate-400 dark:text-slate-500"}`}
|
||||
>
|
||||
<option value="" disabled>请选择</option>
|
||||
{singleOptions.map((o) => (
|
||||
<option key={o} value={o}>{o}</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
|
||||
<Field label="💼 职业">
|
||||
<input
|
||||
type="text"
|
||||
maxLength={140}
|
||||
placeholder="您的职业或专业"
|
||||
value={form.profession}
|
||||
onChange={(e) => set("profession", e.target.value)}
|
||||
required
|
||||
className="form-input"
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-0 sm:grid-cols-2 sm:gap-6">
|
||||
<Field label="💬 微信号">
|
||||
<input
|
||||
type="text"
|
||||
maxLength={140}
|
||||
placeholder="用于拉群"
|
||||
value={form.wechat}
|
||||
onChange={(e) => set("wechat", e.target.value)}
|
||||
required
|
||||
className="form-input"
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field label="📱 手机号">
|
||||
<input
|
||||
type="tel"
|
||||
maxLength={11}
|
||||
pattern="^\d{11}$"
|
||||
placeholder="请输入11位手机号"
|
||||
value={form.phone}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value.replace(/\D/g, "").slice(0, 11);
|
||||
set("phone", v);
|
||||
}}
|
||||
required
|
||||
className="form-input"
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<div className="border-b border-slate-100 dark:border-gray-700 py-4 sm:py-5">
|
||||
<label className="mb-2 block text-base font-bold text-slate-700 dark:text-slate-300 sm:text-[17px]">
|
||||
📝 自我介绍
|
||||
微信号或手机号
|
||||
</label>
|
||||
<div className="relative">
|
||||
<textarea
|
||||
maxLength={500}
|
||||
rows={5}
|
||||
placeholder="分享您的经历、兴趣或加入原因,越详细越好哦~"
|
||||
value={form.intro}
|
||||
onChange={(e) => set("intro", e.target.value)}
|
||||
className="form-input min-h-[120px] resize-none sm:min-h-[140px]"
|
||||
/>
|
||||
<span className="absolute right-3 bottom-3 text-xs text-slate-300 dark:text-slate-500">
|
||||
{form.intro.length}/500
|
||||
</span>
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
maxLength={50}
|
||||
placeholder="用于活动联系"
|
||||
value={form.wechatOrPhone}
|
||||
onChange={(e) => set("wechatOrPhone", e.target.value)}
|
||||
required
|
||||
className="form-input"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-0 sm:grid-cols-2 sm:gap-6">
|
||||
<Field label="🎓 学历">
|
||||
<select
|
||||
value={form.education}
|
||||
onChange={(e) => set("education", e.target.value)}
|
||||
className={`form-input appearance-none ${form.education ? "text-slate-800 dark:text-slate-100" : "text-slate-400 dark:text-slate-500"}`}
|
||||
>
|
||||
<option value="" disabled>请选择</option>
|
||||
{educationOptions.map((o) => (
|
||||
<option key={o} value={o}>{o}</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<div className="border-b border-slate-100 dark:border-gray-700 py-4 sm:py-5">
|
||||
<label className="mb-2 block text-base font-bold text-slate-700 dark:text-slate-300 sm:text-[17px]">
|
||||
一句话自我介绍
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
maxLength={140}
|
||||
placeholder="简单介绍一下自己"
|
||||
value={form.intro}
|
||||
onChange={(e) => set("intro", e.target.value)}
|
||||
required
|
||||
className="form-input"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Field label="📅 毕业时间">
|
||||
<select
|
||||
value={form.graduationYear}
|
||||
onChange={(e) => set("graduationYear", e.target.value)}
|
||||
className={`form-input appearance-none ${form.graduationYear ? "text-slate-800 dark:text-slate-100" : "text-slate-400 dark:text-slate-500"}`}
|
||||
>
|
||||
<option value="" disabled>请选择</option>
|
||||
{graduationYears.map((y) => (
|
||||
<option key={y} value={y}>{y}</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<div className="border-b border-slate-100 dark:border-gray-700 py-4 sm:py-5">
|
||||
<label className="mb-2 block text-base font-bold text-slate-700 dark:text-slate-300 sm:text-[17px]">
|
||||
是否第一次参加类似活动
|
||||
</label>
|
||||
<select
|
||||
value={form.firstTime}
|
||||
onChange={(e) => set("firstTime", e.target.value)}
|
||||
required
|
||||
className={`form-input appearance-none ${form.firstTime ? "text-slate-800 dark:text-slate-100" : "text-slate-400 dark:text-slate-500"}`}
|
||||
>
|
||||
<option value="" disabled>请选择</option>
|
||||
{firstTimeOptions.map((o) => (
|
||||
<option key={o} value={o}>{o}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div className="py-4 sm:py-5">
|
||||
<label className="mb-1 block text-[15px] font-bold text-slate-700 dark:text-slate-300 sm:text-[17px]">
|
||||
📷 头像 / 自拍视频
|
||||
<span className="ml-2 text-xs font-normal text-slate-400 dark:text-slate-500">(可选)</span>
|
||||
<label className="flex items-start gap-3 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.agreeRules}
|
||||
onChange={(e) => set("agreeRules", e.target.checked)}
|
||||
required
|
||||
className="mt-1 rounded border-gray-300 text-[#ff4d4f] focus:ring-[#ff4d4f]"
|
||||
/>
|
||||
<span className="text-sm text-slate-600 dark:text-slate-400">
|
||||
我已阅读并同意活动规则(公开场地、尊重边界、如有不适可随时离开)
|
||||
</span>
|
||||
</label>
|
||||
<p className="mb-3 text-xs text-slate-400 dark:text-slate-500">
|
||||
支持图片(JPG/PNG)或短视频(MP4),最大 20MB
|
||||
</p>
|
||||
|
||||
<input
|
||||
ref={fileRef}
|
||||
type="file"
|
||||
accept="image/jpeg,image/png,image/webp,video/mp4,video/quicktime"
|
||||
className="hidden"
|
||||
onChange={async (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
if (file.size > 20 * 1024 * 1024) {
|
||||
alert("文件大小不能超过 20MB");
|
||||
return;
|
||||
}
|
||||
const isVideo = file.type.startsWith("video/");
|
||||
const preview = URL.createObjectURL(file);
|
||||
setMedia({ preview, url: "", type: isVideo ? "video" : "image" });
|
||||
setUploading(true);
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append("file", file);
|
||||
const res = await fetch("/api/upload-media", {
|
||||
method: "POST",
|
||||
body: fd,
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok || !data?.ok) {
|
||||
throw new Error(data?.error || "上传失败");
|
||||
}
|
||||
setMedia((m) => (m ? { ...m, url: data.url } : null));
|
||||
} catch (err) {
|
||||
alert(err instanceof Error ? err.message : "上传失败");
|
||||
URL.revokeObjectURL(preview);
|
||||
setMedia(null);
|
||||
if (fileRef.current) fileRef.current.value = "";
|
||||
} finally {
|
||||
setUploading(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
{media ? (
|
||||
<div className="relative inline-block">
|
||||
{uploading && (
|
||||
<div className="absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-black/40 text-sm font-medium text-white">
|
||||
上传中…
|
||||
</div>
|
||||
)}
|
||||
{media.type === "image" ? (
|
||||
<img
|
||||
src={media.preview}
|
||||
alt="preview"
|
||||
className="h-32 w-32 rounded-xl border border-slate-200 dark:border-gray-700 object-cover sm:h-40 sm:w-40"
|
||||
/>
|
||||
) : (
|
||||
<video
|
||||
src={media.preview}
|
||||
className="h-32 w-32 rounded-xl border border-slate-200 dark:border-gray-700 object-cover sm:h-40 sm:w-40"
|
||||
muted
|
||||
playsInline
|
||||
controls
|
||||
/>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
disabled={uploading}
|
||||
onClick={() => {
|
||||
URL.revokeObjectURL(media.preview);
|
||||
setMedia(null);
|
||||
if (fileRef.current) fileRef.current.value = "";
|
||||
}}
|
||||
className="absolute -top-2 -right-2 flex h-6 w-6 items-center justify-center rounded-full bg-red-500 text-xs text-white shadow-md transition-colors hover:bg-red-600 disabled:opacity-50"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
disabled={uploading}
|
||||
onClick={() => fileRef.current?.click()}
|
||||
className="flex h-32 w-32 flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-slate-200 dark:border-gray-700 text-slate-400 dark:text-slate-500 transition-colors hover:border-sky-300 hover:text-sky-500 disabled:opacity-50 sm:h-40 sm:w-40"
|
||||
>
|
||||
<svg className="h-8 w-8" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
<span className="text-xs">{uploading ? "上传中…" : "点击上传"}</span>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-8 sm:mt-10">
|
||||
@@ -463,10 +267,10 @@ export default function JoinPage() {
|
||||
)}
|
||||
<button
|
||||
type="submit"
|
||||
disabled={submitting || uploading || payRedirecting}
|
||||
className="w-full rounded-full bg-[#1aad19] py-3.5 text-lg font-semibold text-white shadow-md shadow-emerald-500/20 transition-all hover:bg-[#179b16] hover:shadow-lg hover:shadow-emerald-500/25 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-70 sm:py-4"
|
||||
disabled={submitting}
|
||||
className="w-full rounded-full bg-[#ff4d4f] py-3.5 text-lg font-semibold text-white shadow-md transition-all hover:bg-[#ff3333] active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-70 sm:py-4"
|
||||
>
|
||||
{uploading ? "媒体上传中…" : payRedirecting ? "跳转支付中…" : submitting ? "提交中…" : "提交申请"}
|
||||
{submitting ? "提交中…" : "提交报名"}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -477,12 +281,6 @@ export default function JoinPage() {
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<AuthModal
|
||||
isOpen={authOpen}
|
||||
onClose={() => { setAuthOpen(false); setPendingSubmit(false); }}
|
||||
onSuccess={handleAuthSuccess}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ import type { Metadata } from "next";
|
||||
import "./globals.css";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Salon - 探索中国",
|
||||
description: "加入数字游民社区,探索中国最适合远程工作的城市",
|
||||
title: "Salon - 北京周末新朋友活动",
|
||||
description: "同城小组活动,公开场地,规则透明。认识新朋友,不尬聊,不乱收费。",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
|
||||
118
app/page.tsx
118
app/page.tsx
@@ -3,29 +3,115 @@
|
||||
import Link from "next/link";
|
||||
import HeroSection from "./components/HeroSection";
|
||||
import Footer from "./components/Footer";
|
||||
import { COMMUNITY_STATS } from "@/config/home.config";
|
||||
import { SESSIONS } from "@/config/home.config";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div className="min-h-screen bg-[#fafafa] dark:bg-gray-950">
|
||||
<HeroSection />
|
||||
|
||||
<div className="max-w-[1400px] mx-auto px-5 sm:px-10 py-8">
|
||||
<Link href="/join" className="right-item block max-w-md">
|
||||
<div className="right-item-header">加入社区</div>
|
||||
<div className="flex flex-col items-center justify-center text-center p-2 sm:p-5 h-[calc(100%-38px)] sm:h-[calc(100%-42px)]">
|
||||
<span className="text-2xl sm:text-5xl mb-1 sm:mb-3">💬</span>
|
||||
<p className="text-[10px] sm:text-sm text-gray-600 dark:text-gray-400 mb-0.5">
|
||||
加入数字游民社区,结识志同道合的伙伴
|
||||
</p>
|
||||
<p className="text-[9px] sm:text-xs text-gray-400 dark:text-gray-500 mb-1.5 sm:mb-4">
|
||||
{COMMUNITY_STATS.onlineMembers} 人在线
|
||||
</p>
|
||||
<span className="bg-[#ff4d4f] text-white px-2.5 sm:px-6 py-1 sm:py-2 rounded-lg text-[10px] sm:text-sm font-semibold whitespace-nowrap">
|
||||
加入社区 →
|
||||
</span>
|
||||
<div className="max-w-[1400px] mx-auto px-5 sm:px-10 py-8 space-y-8">
|
||||
{/* 信任信息条 */}
|
||||
<div className="flex flex-wrap justify-center gap-4 sm:gap-8 text-sm text-gray-600 dark:text-gray-400">
|
||||
<span>📍 公开场地</span>
|
||||
<span>👥 小组活动</span>
|
||||
<span>📋 规则透明</span>
|
||||
<span>✍️ 无需注册</span>
|
||||
</div>
|
||||
|
||||
{/* 本周活动场次 */}
|
||||
<section>
|
||||
<h2 className="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4">本周活动场次</h2>
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{SESSIONS.map((s) => (
|
||||
<Link
|
||||
key={s.id}
|
||||
href={`/join?session=${encodeURIComponent(s.id)}`}
|
||||
className="right-item block"
|
||||
>
|
||||
<div className="right-item-header">{s.title}</div>
|
||||
<div className="p-4 sm:p-5">
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400 mb-1">{s.date} {s.time}</p>
|
||||
<p className="text-xs text-gray-500 dark:text-gray-500 mb-3">{s.place}</p>
|
||||
<span className="inline-block bg-[#ff4d4f] text-white px-3 py-1.5 rounded-lg text-xs font-semibold">
|
||||
报名 →
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</Link>
|
||||
</section>
|
||||
|
||||
{/* 为什么很多人更愿意来这种局 */}
|
||||
<section>
|
||||
<h2 className="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4">为什么很多人更愿意来这种局</h2>
|
||||
<div className="right-item">
|
||||
<div className="right-item-header">先了解,再决定</div>
|
||||
<div className="p-4 sm:p-5 space-y-2 text-sm text-gray-600 dark:text-gray-400">
|
||||
<p>• 场地公开,地址提前告知,不用担心安全问题</p>
|
||||
<p>• 人数可控,小组活动,不会太吵也不会冷场</p>
|
||||
<p>• 规则透明,活动前会说明流程和边界</p>
|
||||
<p>• 填个简单表单即可,无需注册登录,更不用先付款</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* 安全与边界规则 */}
|
||||
<section>
|
||||
<h2 className="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4">安全与边界规则</h2>
|
||||
<div className="right-item">
|
||||
<div className="right-item-header">活动规则</div>
|
||||
<div className="p-4 sm:p-5 space-y-2 text-sm text-gray-600 dark:text-gray-400">
|
||||
<p>• 活动在公开场地进行,不私下约见</p>
|
||||
<p>• 尊重他人边界,不追问隐私、不强行加微信</p>
|
||||
<p>• 如有不适可随时离开,主办方会协助处理</p>
|
||||
<p>• 报名即同意以上规则</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* 主理人说明 */}
|
||||
<section>
|
||||
<h2 className="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4">主理人说明</h2>
|
||||
<div className="right-item">
|
||||
<div className="right-item-header">关于我们</div>
|
||||
<div className="p-4 sm:p-5 text-sm text-gray-600 dark:text-gray-400">
|
||||
<p>我们是一群在北京的朋友,定期组织周末小聚,让想认识新朋友的人有个轻松、靠谱的场合。活动不设门槛,不搞暧昧,就是单纯聊天、互相认识。</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* FAQ */}
|
||||
<section>
|
||||
<h2 className="text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4">常见问题</h2>
|
||||
<div className="space-y-2">
|
||||
{[
|
||||
{ q: "需要先注册吗?", a: "不需要。填个简单表单即可,无需注册登录。" },
|
||||
{ q: "需要先付款吗?", a: "不需要。先看场次,再决定要不要报名,报名不收费。" },
|
||||
{ q: "活动地点在哪里?", a: "报名后会通过微信或短信告知具体地址,均为公开场地。" },
|
||||
{ q: "第一次参加可以吗?", a: "可以。我们欢迎第一次参加类似活动的朋友。" },
|
||||
].map((faq, i) => (
|
||||
<div key={i} className="right-item">
|
||||
<div className="right-item-header">{faq.q}</div>
|
||||
<div className="p-3 sm:p-4 text-sm text-gray-600 dark:text-gray-400">{faq.a}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* 底部 CTA */}
|
||||
<section className="pt-4">
|
||||
<Link href="/join" className="right-item block max-w-md">
|
||||
<div className="right-item-header">去报名</div>
|
||||
<div className="flex flex-col items-center justify-center text-center p-2 sm:p-5 h-[calc(100%-38px)] sm:h-[calc(100%-42px)]">
|
||||
<span className="text-2xl sm:text-5xl mb-1 sm:mb-3">✍️</span>
|
||||
<p className="text-[10px] sm:text-sm text-gray-600 dark:text-gray-400 mb-0.5">
|
||||
选好场次,填个简单表单即可参与
|
||||
</p>
|
||||
<span className="bg-[#ff4d4f] text-white px-2.5 sm:px-6 py-1 sm:py-2 rounded-lg text-[10px] sm:text-sm font-semibold whitespace-nowrap">去报名 →</span>
|
||||
</div>
|
||||
</Link>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<Footer />
|
||||
|
||||
@@ -1,43 +1,6 @@
|
||||
export const HOME_STATS = {
|
||||
cities: "18",
|
||||
nomads: "5,000+",
|
||||
meetups: "8+",
|
||||
homeMeetups: "50+",
|
||||
cost: "¥3,000",
|
||||
};
|
||||
|
||||
export const COMMUNITY_STATS = {
|
||||
onlineMembers: "3,200+",
|
||||
messagesPerMonth: "3,200+",
|
||||
};
|
||||
|
||||
export const MEMBER_PHOTOS = [
|
||||
{ name: "林晓", photo: "https://i.pravatar.cc/150?img=5" },
|
||||
{ name: "张浩", photo: "https://i.pravatar.cc/150?img=3" },
|
||||
{ name: "陈悦", photo: "https://i.pravatar.cc/150?img=9" },
|
||||
{ name: "周杰", photo: "https://i.pravatar.cc/150?img=7" },
|
||||
{ name: "吴婷", photo: "https://i.pravatar.cc/150?img=1" },
|
||||
];
|
||||
|
||||
export const MEETUPS = [
|
||||
{ city: "大理", emoji: "🏯", date: "3月9日", count: 12 },
|
||||
{ city: "成都", emoji: "🐼", date: "3月12日", count: 8 },
|
||||
{ city: "深圳", emoji: "🌃", date: "3月14日", count: 15 },
|
||||
];
|
||||
|
||||
export const ROUTES = [
|
||||
{
|
||||
titleZh: "云南慢生活线",
|
||||
titleEn: "Yunnan Slow Life",
|
||||
citiesZh: ["昆明", "大理", "丽江"],
|
||||
citiesEn: ["Kunming", "Dali", "Lijiang"],
|
||||
emojis: ["🌸", "🏯", "🏔️"],
|
||||
durationZh: "3-6个月",
|
||||
durationEn: "3-6 months",
|
||||
costZh: "¥3,200/月起",
|
||||
costEn: "From ¥3,200/month",
|
||||
descZh: "从春城昆明出发,感受最纯粹的慢生活",
|
||||
descEn: "From Kunming, experience the purest slow life",
|
||||
gradient: "from-purple-500 to-pink-500",
|
||||
},
|
||||
/** 本周活动场次 - 同城活动用 */
|
||||
export const SESSIONS = [
|
||||
{ id: "session-1", date: "3月16日 周六", time: "14:00", place: "朝阳区某咖啡馆", title: "周末咖啡局" },
|
||||
{ id: "session-2", date: "3月17日 周日", time: "15:00", place: "海淀区某书店", title: "读书分享" },
|
||||
{ id: "session-3", date: "3月22日 周六", time: "14:00", place: "东城区某空间", title: "新朋友见面会" },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user