This commit is contained in:
eric
2026-03-16 05:41:47 -05:00
parent ff31ef8001
commit c54d46517c
16 changed files with 796 additions and 286 deletions

View File

@@ -22,7 +22,7 @@
### 后端 (payjsapi)
- 与 cnomadcna 相同,需配置 PocketBase、支付渠道等
- **PocketBase 需创建 `solanRed` 集合**(可克隆自 solan字段user_id, nickname, occupation, reason, wechatId, gender, education, gradYear, phone, single, media, type, order_id, amount
- **PocketBase 需创建 `solanRed` 集合**(可克隆自 solan字段user_id, nickname, occupation, reason, wechatId, gender, education, gradYear, phone, single, media, type, order_id, amount, is_volunteer布尔, xiaohongshu_url
## 启动

View File

@@ -45,6 +45,7 @@ export async function POST(request: NextRequest) {
const whyJoin = String(formData.why_join || "").trim();
const region = String(formData.region || "").trim();
const availableTime = String(formData.available_time || "").trim();
const isVolunteer = !!formData.is_volunteer;
if (!intro && (status || activityType || whyJoin || region || availableTime)) {
const extra = [status && `状态:${status}`, activityType && `活动偏好:${activityType}`, whyJoin && `原因:${whyJoin}`, region && `区域:${region}`, availableTime && `时间:${availableTime}`].filter(Boolean).join(" | ");
intro = extra;
@@ -52,39 +53,22 @@ export async function POST(request: NextRequest) {
const isDigitalNomad = session === "digital-nomad";
const contact = wechatOrPhone || wechat || phone;
if (!nickname || !intro || !session || !agreeRules || !xiaohongshuUrl) {
if (!nickname || !session || !agreeRules) {
return NextResponse.json(
{ ok: false, error: "请填写必填项(含小红书主页地址、自我介绍)" },
{ ok: false, error: "请填写必填项" },
{ status: 400 }
);
}
if (!contact) {
return NextResponse.json(
{ ok: false, error: "请填写微信号或手机号" },
{ status: 400 }
);
}
if (isDigitalNomad && (!education || !graduationYear)) {
return NextResponse.json(
{ ok: false, error: "请选择学历和毕业时间" },
{ ok: false, error: "请填写微信号" },
{ status: 400 }
);
}
const userId = getUserIdFromCookie(request) || generateAnonId();
const EDUCATION_GRAD_AGE: Record<string, number> = {
"高中及以下": 18,
大专: 21,
本科: 22,
硕士: 25,
博士: 28,
};
const gradAge = EDUCATION_GRAD_AGE[education] ?? 22;
const estimatedAge = new Date().getFullYear() - parseInt(graduationYear, 10) + gradAge;
const ageRangeForRecord = isDigitalNomad && education && graduationYear
? `推算约${estimatedAge}岁(学历${education}+${graduationYear}毕业)`
: ageRange;
const ageRangeForRecord = ageRange || "";
const record = {
user_id: userId,
@@ -104,6 +88,7 @@ export async function POST(request: NextRequest) {
amount: 0,
age_range: ageRangeForRecord,
first_time: firstTime,
is_volunteer: isVolunteer,
};
try {
@@ -167,6 +152,8 @@ async function tryPocketBaseDirect(
type: record.type ?? "",
order_id: record.order_id ?? "",
amount: record.amount ?? 0,
is_volunteer: record.is_volunteer ?? false,
xiaohongshu_url: record.xiaohongshu_url ?? "",
};
try {

View File

@@ -37,9 +37,9 @@ export async function GET(request: NextRequest) {
const total = typeof data?.totalItems === "number" ? data.totalItems : items.length;
stats[s.id] = {
count: total,
joiners: items.slice(0, 6).map((r: { nickname?: string; xiaohongshu_nickname?: string; xiaohongshu_avatar?: string; xiaohongshu_url?: string }) => ({
joiners: items.slice(0, 6).map((r: { nickname?: string; xiaohongshu_nickname?: string; xiaohongshu_avatar?: string; xiaohongshu_url?: string; media?: string }) => ({
nickname: String(r?.xiaohongshu_nickname || r?.nickname || "").trim() || "匿名",
avatar: String(r?.xiaohongshu_avatar || "").trim() || undefined,
avatar: String(r?.xiaohongshu_avatar || r?.media || "").trim() || undefined,
xiaohongshu_url: String(r?.xiaohongshu_url || "").trim() || undefined,
})),
};

View File

@@ -0,0 +1,40 @@
import { NextResponse } from "next/server";
import { getAdminToken } from "@/app/lib/pocketbase/admin";
import { getPocketBaseConfig } from "@/config/services.config";
/** 获取志愿者列表 - solanRed 中 is_volunteer=true 的记录 */
export async function GET() {
const token = await getAdminToken();
if (!token) {
return NextResponse.json({ ok: true, volunteers: [] }, { status: 200 });
}
const pb = getPocketBaseConfig();
const base = pb.url.replace(/\/$/, "");
try {
const filter = encodeURIComponent('is_volunteer=true');
const res = await fetch(
`${base}/api/collections/${pb.joinCollection}/records?filter=${filter}&sort=-created&perPage=20`,
{
headers: { Authorization: `Bearer ${token}` },
cache: "no-store",
}
);
if (!res.ok) {
return NextResponse.json({ ok: true, volunteers: [] }, { status: 200 });
}
const data = await res.json();
const items = Array.isArray(data?.items) ? data.items : [];
const volunteers = items.map(
(r: { nickname?: string; xiaohongshu_nickname?: string; media?: string; xiaohongshu_url?: string }) => ({
nickname: String(r?.xiaohongshu_nickname || r?.nickname || "").trim() || "志愿者",
avatar: String(r?.media || "").trim() || undefined,
xiaohongshu_url: String(r?.xiaohongshu_url || "").trim() || undefined,
})
);
return NextResponse.json({ ok: true, volunteers });
} catch {
return NextResponse.json({ ok: true, volunteers: [] }, { status: 200 });
}
}

View File

@@ -1,5 +1,7 @@
"use client";
import { HONGSHAN_COORDS } from "@/config/home.config";
interface AddressLinkProps {
place: string;
city: string;
@@ -8,8 +10,10 @@ interface AddressLinkProps {
/** 可点击的地址,点击打开地图(使用 span 避免嵌套在 Link 内时的 a 标签冲突) */
export default function AddressLink({ place, city, className = "" }: AddressLinkProps) {
const query = encodeURIComponent(`${city}${place}`);
const mapUrl = `https://www.google.com/maps/search/?api=1&query=${query}`;
const isHongshan = place.includes("红山");
const mapUrl = isHongshan
? `https://www.google.com/maps?q=${HONGSHAN_COORDS.lat},${HONGSHAN_COORDS.lng}`
: `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(`${city}${place}`)}`;
return (
<span

View File

@@ -5,12 +5,13 @@ import Image from "next/image";
import Link from "next/link";
import SessionCoverImage from "./SessionCoverImage";
import AddressLink from "./AddressLink";
import { SESSIONS, RECENT_JOINERS } from "@/config/home.config";
import { getSessionsWithDates, RECENT_JOINERS } from "@/config/home.config";
const MOCK_JOINERS = RECENT_JOINERS.slice(0, 3);
export default function HeroSection() {
const mainSession = SESSIONS[0];
const sessions = getSessionsWithDates();
const mainSession = sessions[0];
const [stats, setStats] = useState<{ count: number; joiners: { nickname: string }[] } | null>(null);
useEffect(() => {
@@ -34,96 +35,121 @@ export default function HeroSection() {
<div className="flex flex-col lg:flex-row lg:items-center lg:gap-12 xl:gap-16">
<div className="flex-1 min-w-0">
<h1 className="text-2xl sm:text-3xl md:text-4xl lg:text-[2.5rem] xl:text-[2.75rem] font-bold tracking-tight leading-[1.25]">
<span className="hero-gradient-text"></span>
<span className="hero-gradient-text">2</span>
<br />
<span className="text-stone-800 dark:text-stone-100"></span>
<span className="text-stone-800 dark:text-stone-100"></span>
</h1>
<p className="mt-4 sm:mt-5 text-stone-600 dark:text-stone-400 text-sm sm:text-base max-w-lg leading-relaxed">
· 68
· 48
</p>
<p className="mt-1.5 text-stone-500 dark:text-stone-450 text-xs sm:text-sm max-w-lg">
· · ·
· · ·
</p>
<div className="mt-6 sm:mt-8">
<Link
href="/join"
className="inline-flex items-center justify-center bg-amber-600 hover:bg-amber-700 text-white px-5 py-2.5 sm:px-6 sm:py-3 rounded-xl text-sm font-medium shadow-lg shadow-amber-900/20 transition-all active:scale-[0.98]"
>
</Link>
</div>
</div>
{mainSession && (
<div className="w-full lg:w-[280px] xl:w-[300px] shrink-0 mt-8 lg:mt-0">
<div className="w-full lg:w-[520px] xl:w-[580px] shrink-0 mt-8 lg:mt-0">
<Link
href={`/join?session=${mainSession.id}`}
className="block rounded-2xl overflow-hidden border border-stone-200 dark:border-stone-700 bg-white dark:bg-stone-900 shadow-lg shadow-stone-900/5 hover:shadow-xl hover:shadow-amber-900/10 transition-all ring-1 ring-stone-100 dark:ring-stone-800"
className="group flex flex-col lg:flex-row rounded-2xl overflow-hidden bg-white dark:bg-stone-900 shadow-xl shadow-stone-200/60 dark:shadow-stone-950/80 border border-stone-100 dark:border-stone-800 hover:shadow-2xl hover:shadow-amber-900/15 transition-all duration-300 hover:-translate-y-1"
>
<div className="relative aspect-[4/3] w-full bg-stone-100 dark:bg-stone-800 overflow-hidden">
{/* 图片区 - 左侧/上方 */}
<div className="relative lg:w-[44%] aspect-[4/3] lg:aspect-auto lg:min-h-[180px] w-full bg-stone-100 dark:bg-stone-800 overflow-hidden shrink-0">
{mainSession.coverImage ? (
<SessionCoverImage
src={mainSession.coverImage}
alt={mainSession.title}
type={mainSession.type}
fill
sizes="(max-width: 1024px) 100vw, 300px"
className="object-cover"
sizes="(max-width: 1024px) 100vw, 260px"
className="object-cover transition-transform duration-500 group-hover:scale-105"
/>
) : (
<div className="absolute inset-0 flex items-center justify-center text-3xl bg-stone-200 dark:bg-stone-700">
<div className="absolute inset-0 flex items-center justify-center text-4xl bg-stone-200 dark:bg-stone-700">
</div>
)}
<div className="absolute top-2 left-2 right-2 flex flex-wrap gap-1">
<span className="inline-block text-[10px] font-medium bg-white/90 dark:bg-stone-900/90 backdrop-blur px-2 py-0.5 rounded text-stone-700 dark:text-stone-200">
</span>
<span className="inline-block text-[10px] font-medium bg-white/90 dark:bg-stone-900/90 backdrop-blur px-2 py-0.5 rounded text-stone-700 dark:text-stone-200">
68
</span>
<span className="inline-block text-[10px] font-medium bg-white/90 dark:bg-stone-900/90 backdrop-blur px-2 py-0.5 rounded text-stone-700 dark:text-stone-200">
</span>
<div className="absolute inset-0 bg-gradient-to-r from-black/20 via-transparent to-transparent lg:from-transparent lg:via-transparent lg:to-black/30" aria-hidden />
<div className="absolute bottom-2 left-2 flex flex-wrap gap-1.5 lg:bottom-3 lg:left-3">
{["周末", "4人成行"].map((tag) => (
<span
key={tag}
className="inline-block text-[10px] font-semibold bg-white/95 dark:bg-stone-900/95 backdrop-blur-sm px-2.5 py-1 rounded-md text-stone-700 dark:text-stone-200"
>
{tag}
</span>
))}
</div>
</div>
<div className="p-4 sm:p-5 border-t border-stone-100 dark:border-stone-800">
<p className="text-[10px] sm:text-xs font-medium text-amber-600 dark:text-amber-400/90 uppercase tracking-wider mb-1">
</p>
<h3 className="font-semibold text-stone-800 dark:text-stone-100 text-sm sm:text-base">{mainSession.title}</h3>
<p className="text-xs sm:text-sm text-stone-500 dark:text-stone-400 mt-0.5">
{mainSession.date} {mainSession.time} · <AddressLink place={mainSession.place} city={mainSession.city} />
</p>
<span className="inline-flex items-center gap-1 mt-3 text-amber-600 dark:text-amber-400 font-medium text-xs sm:text-sm">
</span>
<div className="mt-3 flex items-center gap-2">
<div className="flex -space-x-2 shrink-0">
{(stats?.joiners?.length ? stats.joiners : MOCK_JOINERS).slice(0, 5).map((j, i) => {
const nickname = "name" in j ? (j as { name: string }).name : (j as { nickname: string }).nickname;
const avatar = "avatar" in j ? (j as { avatar: string }).avatar : (j as { avatar?: string }).avatar;
const xhUrl = (j as { xiaohongshu_url?: string }).xiaohongshu_url;
const showAvatar = avatar && avatar.length > 0;
return (
<span
key={i}
className={`relative w-7 h-7 rounded-full overflow-hidden border-2 border-white dark:border-stone-900 ring-1 ring-stone-200/50 dark:ring-stone-700/50 shrink-0 inline-block cursor-default ${showAvatar ? "" : "bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center text-xs font-medium text-amber-700 dark:text-amber-300"}`}
title={nickname}
data-xiaohongshu-url={xhUrl}
onClick={(e) => e.preventDefault()}
>
{showAvatar ? (
<Image src={avatar} alt="" fill sizes="28px" className="object-cover" unoptimized />
) : (
<span className="flex items-center justify-center w-full h-full">{nickname.slice(0, 1) || "?"}</span>
)}
</span>
);
})}
{/* 内容区 - 右侧/下方 */}
<div className="flex-1 flex flex-col justify-center p-5 lg:p-6 lg:pl-6 min-w-0">
<div className="inline-flex items-center gap-2 mb-3">
<span className="w-1 h-4 rounded-full bg-amber-500 dark:bg-amber-500" aria-hidden />
<p className="text-[10px] font-semibold text-amber-600 dark:text-amber-400 uppercase tracking-[0.2em]">
</p>
</div>
<h3 className="font-bold text-stone-800 dark:text-stone-100 text-lg lg:text-xl leading-tight tracking-tight">
{mainSession.title}
</h3>
<div className="mt-3 space-y-1.5">
<p className="text-sm text-stone-500 dark:text-stone-400">
<span className="inline-block w-14 text-stone-400 dark:text-stone-500"></span>
{mainSession.date}
</p>
<p className="text-sm text-stone-500 dark:text-stone-400">
<span className="inline-block w-14 text-stone-400 dark:text-stone-500"></span>
{mainSession.time}
</p>
<p className="text-sm text-stone-500 dark:text-stone-400">
<span className="inline-block w-14 text-stone-400 dark:text-stone-500"></span>
<AddressLink place={mainSession.place} city={mainSession.city} />
</p>
</div>
<div className="mt-4 pt-4 border-t border-stone-100 dark:border-stone-800 flex items-center justify-between gap-4">
<div className="flex items-center gap-3 min-w-0">
<div className="flex -space-x-2.5 shrink-0">
{(stats?.joiners?.length ? stats.joiners : MOCK_JOINERS).slice(0, 5).map((j, i) => {
const nickname = "name" in j ? (j as { name: string }).name : (j as { nickname: string }).nickname;
const avatar = "avatar" in j ? (j as { avatar: string }).avatar : (j as { avatar?: string }).avatar;
const xhUrl = (j as { xiaohongshu_url?: string }).xiaohongshu_url;
const showAvatar = avatar && avatar.length > 0;
return (
<span
key={i}
className={`relative w-8 h-8 rounded-full overflow-hidden border-2 border-white dark:border-stone-900 shrink-0 inline-block transition-transform hover:scale-110 ${xhUrl ? "cursor-pointer" : "cursor-default"} ${showAvatar ? "" : "bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center text-xs font-medium text-amber-700 dark:text-amber-300"}`}
title={nickname}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
if (xhUrl) window.open(xhUrl, "_blank", "noopener,noreferrer");
}}
>
{showAvatar ? (
<Image src={avatar} alt="" fill sizes="32px" className="object-cover" unoptimized />
) : (
<span className="flex items-center justify-center w-full h-full">{nickname.slice(0, 1) || "?"}</span>
)}
</span>
);
})}
</div>
<span className="text-xs text-stone-500 dark:text-stone-400 truncate">
{stats?.count ? `${stats.count} 人已报名` : "有人报名中"}
</span>
</div>
<span className="text-xs text-stone-500 dark:text-stone-400">
{stats?.count ? `${stats.count} 人已报名` : "有人报名中"}
<span className="shrink-0 inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 font-semibold text-sm group-hover:bg-amber-100 dark:group-hover:bg-amber-900/30 transition-all group-hover:gap-2">
<span className="text-amber-500 dark:text-amber-400"></span>
</span>
</div>
</div>

View File

@@ -5,7 +5,7 @@ import Image from "next/image";
import Link from "next/link";
import SessionCoverImage from "./SessionCoverImage";
import AddressLink from "./AddressLink";
import { SESSIONS, ACTIVITY_TYPES, SESSION_TAGS, RECENT_JOINERS } from "@/config/home.config";
import { getSessionsWithDates, ACTIVITY_TYPES, SESSION_TAGS, RECENT_JOINERS } from "@/config/home.config";
interface JoinStats {
count: number;
@@ -18,7 +18,7 @@ export default function SessionCard({
session,
index,
}: {
session: (typeof SESSIONS)[0];
session: (ReturnType<typeof getSessionsWithDates>)[0];
index: number;
}) {
const [stats, setStats] = useState<JoinStats | null>(null);
@@ -35,7 +35,7 @@ export default function SessionCard({
href={`/join?session=${encodeURIComponent(session.id)}`}
className="group flex flex-col sm:flex-row gap-3 sm:gap-4 p-4 sm:p-5 rounded-xl sm:rounded-2xl bg-white dark:bg-stone-900/80 border border-stone-200/80 dark:border-stone-700/80 hover:border-amber-200 dark:hover:border-amber-900/50 hover:shadow-lg hover:shadow-amber-900/5 transition-all"
>
<div className="relative w-full sm:w-24 sm:h-24 shrink-0 aspect-[16/10] sm:aspect-square rounded-lg sm:rounded-xl overflow-hidden bg-stone-100 dark:bg-stone-800">
<div className="relative w-full sm:w-32 sm:min-w-[128px] shrink-0 aspect-[16/10] rounded-lg sm:rounded-xl overflow-hidden bg-stone-100 dark:bg-stone-800">
{session.coverImage ? (
<SessionCoverImage
src={session.coverImage}
@@ -89,10 +89,17 @@ export default function SessionCard({
return (
<span
key={i}
className={`relative w-7 h-7 rounded-full overflow-hidden border-2 border-white dark:border-stone-900 ring-1 ring-stone-200/50 dark:ring-stone-700/50 shrink-0 inline-block cursor-default ${showAvatar ? "" : "bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center text-xs font-medium text-amber-700 dark:text-amber-300"}`}
className={`relative w-7 h-7 rounded-full overflow-hidden border-2 border-white dark:border-stone-900 ring-1 ring-stone-200/50 dark:ring-stone-700/50 shrink-0 inline-block ${xhUrl ? "cursor-pointer" : "cursor-default"}`}
title={nickname}
data-xiaohongshu-url={xhUrl}
onClick={(e) => e.preventDefault()}
onClick={(e) => {
if (xhUrl) {
e.preventDefault();
e.stopPropagation();
window.open(xhUrl, "_blank", "noopener,noreferrer");
} else {
e.preventDefault();
}
}}
>
{showAvatar ? (
<Image src={avatar} alt="" fill sizes="28px" className="object-cover" unoptimized />

View File

@@ -1,6 +1,7 @@
"use client";
import { useParams } from "next/navigation";
import { useParams, useRouter } from "next/navigation";
import { useEffect } from "react";
import Image from "next/image";
import Link from "next/link";
import Header from "../../components/Header";
@@ -9,9 +10,20 @@ import { HOSTS } from "@/config/home.config";
export default function HostDetailPage() {
const params = useParams();
const router = useRouter();
const id = typeof params.id === "string" ? params.id : "";
const host = HOSTS.find((h) => h.id === id);
useEffect(() => {
if (host && "link" in host && host.link) {
if (host.link.startsWith("http")) {
window.location.href = host.link;
} else {
router.replace(host.link);
}
}
}, [host, router]);
if (!host) {
return (
<div className="min-h-screen bg-[#faf8f5] dark:bg-stone-950 flex items-center justify-center">
@@ -25,6 +37,14 @@ export default function HostDetailPage() {
);
}
if ("link" in host && host.link) {
return (
<div className="min-h-screen bg-[#faf8f5] dark:bg-stone-950 flex items-center justify-center">
<p className="text-stone-500 dark:text-stone-400"></p>
</div>
);
}
return (
<div className="min-h-screen bg-[#faf8f5] dark:bg-stone-950">
<Header />
@@ -54,11 +74,13 @@ export default function HostDetailPage() {
<p className="mt-2 text-sm text-amber-600 dark:text-amber-400">
{host.bio}
</p>
<div className="mt-6 pt-6 border-t border-stone-100 dark:border-stone-700 text-left">
<p className="text-sm text-stone-600 dark:text-stone-400 leading-relaxed">
{host.intro}
</p>
</div>
{"intro" in host && host.intro && (
<div className="mt-6 pt-6 border-t border-stone-100 dark:border-stone-700 text-left">
<p className="text-sm text-stone-600 dark:text-stone-400 leading-relaxed">
{host.intro}
</p>
</div>
)}
</div>
</article>

View File

@@ -5,16 +5,7 @@ import Link from "next/link";
import ThemeToggle from "../components/ThemeToggle";
import { DIGITAL_NOMAD_WECHAT_QR } from "@/config/home.config";
/** 各学历对应的典型毕业年龄,用于推算年龄 */
const EDUCATION_GRAD_AGE: Record<string, number> = {
"高中及以下": 18,
"大专": 21,
"本科": 22,
"硕士": 25,
"博士": 28,
};
const educationOptions = ["高中及以下", "大专", "本科", "硕士", "博士"];
const graduationYears = Array.from({ length: 41 }, (_, i) => String(2026 - i));
const ageRangeOptions = ["18-22", "23-27", "28-32", "33-37", "38+"];
function getDisplayCount(text?: string, value?: number | string, suffix = ""): string | null {
if (typeof text === "string" && text.trim()) {
@@ -36,10 +27,8 @@ export default function JoinPage() {
const [xiaohongshuUrl, setXiaohongshuUrl] = useState("");
const [profession, setProfession] = useState("");
const [wechat, setWechat] = useState("");
const [phone, setPhone] = useState("");
const [intro, setIntro] = useState("");
const [education, setEducation] = useState("");
const [graduationYear, setGraduationYear] = useState("");
const [gender, setGender] = useState("");
const [ageRange, setAgeRange] = useState("");
const [agreeRules, setAgreeRules] = useState(false);
const [urlError, setUrlError] = useState<string | null>(null);
const [profile, setProfile] = useState<{
@@ -129,28 +118,24 @@ export default function JoinPage() {
e.preventDefault();
setError(null);
if (!xiaohongshuUrl.trim()) {
setError("请填写小红书主页链接");
return;
}
if (urlError) {
if (xiaohongshuUrl.trim() && urlError) {
setError("请先修正小红书链接");
return;
}
if (!education || !graduationYear) {
setError("请选择学历和毕业时间");
return;
}
if (!profession.trim()) {
setError("请填写职业");
return;
}
if (!wechat.trim() && !phone.trim()) {
setError("请填写微信号或手机号");
if (!wechat.trim()) {
setError("请填写微信号");
return;
}
if (!intro.trim()) {
setError("请填写自我介绍");
if (!gender) {
setError("请选择性别");
return;
}
if (!ageRange) {
setError("请选择年龄区间");
return;
}
if (!agreeRules) {
@@ -160,29 +145,26 @@ export default function JoinPage() {
setSubmitting(true);
try {
const gradAge = EDUCATION_GRAD_AGE[education] ?? 22;
const estimatedAge = new Date().getFullYear() - parseInt(graduationYear, 10) + gradAge;
const ageOk = estimatedAge < 28;
const isFemale = profile?.gender === "female";
const genderLabel = getGenderLabel(profile?.gender);
const postCountOk = (profile?.postCount ?? 0) > 5;
const postCountLabel = getDisplayCount(profile?.postCountText, profile?.postCount) ?? "0";
const submitXiaohongshuUrl = profile?.resolvedUrl || xiaohongshuUrl.trim();
const formGenderFemale = gender === "女" || gender === "female";
const xiaohongshuGenderFemale = profile?.gender === "female";
const postCountOk = (profile?.postCount ?? 0) > 10;
const ipInGuangdong = profile?.ipLocation?.includes("广东") ?? false;
const qualify =
formGenderFemale &&
xiaohongshuGenderFemale &&
postCountOk &&
ipInGuangdong;
const reasonParts = [
intro,
`学历:${education}`,
`毕业:${graduationYear}`,
profile?.gender && `性别:${profile.gender}`,
`发帖:${profile?.postCount ?? 0}`,
].filter(Boolean);
const genderLabel = gender === "女" ? "女" : gender === "男" ? "男" : "无";
const postCountLabel = getDisplayCount(profile?.postCountText, profile?.postCount) ?? "0";
const submitXiaohongshuUrl = profile?.resolvedUrl || xiaohongshuUrl.trim() || "";
const submitReasonParts = [
reasonParts[0],
`\u5b66\u5386:${education}`,
`\u6bd5\u4e1a:${graduationYear}`,
`\u6027\u522b:${genderLabel}`,
`\u53d1\u5e16:${postCountLabel}`,
`职业:${profession.trim()}`,
`性别:${genderLabel}`,
`年龄:${ageRange}`,
profile && `发帖:${postCountLabel}`,
profile?.ipLocation && `IP:${profile.ipLocation}`,
].filter(Boolean);
const res = await fetch("/api/join", {
@@ -191,16 +173,17 @@ export default function JoinPage() {
body: JSON.stringify({
nickname: profile?.nickname || "匿名",
wechat: wechat.trim(),
phone: phone.trim(),
phone: "",
profession: profession.trim(),
xiaohongshu_url: submitXiaohongshuUrl,
xiaohongshu_avatar_url: profile?.avatarUrl || "",
gender: genderLabel,
intro: submitReasonParts.join(" | "),
age_range: ageRange,
city: "深圳",
session: "digital-nomad",
education,
graduation_year: graduationYear,
education: "",
graduation_year: "",
agree_rules: true,
first_time: "",
status: "",
@@ -216,7 +199,7 @@ export default function JoinPage() {
throw new Error(data?.error || "提交失败,请稍后重试");
}
setQualify(isFemale && ageOk && postCountOk);
setQualify(qualify);
setSubmitted(true);
} catch (err) {
setError(err instanceof Error ? err.message : "网络错误,请重试");
@@ -229,7 +212,6 @@ export default function JoinPage() {
const followersDisplay = getDisplayCount(profile?.followersText, profile?.followers);
const likesDisplay = getDisplayCount(profile?.likesAndCollectsText, profile?.likesAndCollects);
const safePostCountDisplay = getDisplayCount(profile?.postCountText, profile?.postCount, " \u7bc7");
const postCountDisplay = getDisplayCount(profile?.postCountText, profile?.postCount, " 篇");
const profileGenderLabel = getGenderLabel(profile?.gender);
@@ -240,13 +222,13 @@ export default function JoinPage() {
{qualify ? (
<>
<div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-emerald-50 dark:bg-emerald-900/30 text-4xl">
🎉
</div>
<h2 className="text-xl sm:text-2xl font-bold text-stone-800 dark:text-stone-100">
</h2>
<p className="mt-2 text-sm text-stone-500 dark:text-stone-400">
</p>
<div className="mt-6 flex justify-center">
<img
@@ -256,7 +238,7 @@ export default function JoinPage() {
/>
</div>
<p className="mt-4 text-xs text-stone-400 dark:text-stone-500">
📝
</p>
</>
) : (
@@ -268,15 +250,19 @@ export default function JoinPage() {
</h2>
<p className="mt-2 text-sm text-stone-500 dark:text-stone-400">
1-3
24
</p>
</>
)}
<p className="mt-6 text-xs text-stone-400 dark:text-stone-500 leading-relaxed">
💰 29/宿/<br />
</p>
<Link
href="/"
className="mt-6 sm:mt-8 inline-flex items-center gap-2 rounded-xl bg-amber-600 px-6 sm:px-8 py-2.5 sm:py-3 font-medium text-white text-sm sm:text-base transition-colors hover:bg-amber-700"
>
🏠
</Link>
</div>
</div>
@@ -306,8 +292,11 @@ export default function JoinPage() {
<form onSubmit={handleSubmit} className="space-y-5">
<div>
<label className="block text-sm font-medium text-stone-700 dark:text-stone-300 mb-2">
<span className="text-red-500">*</span>
📱
</label>
<p className="text-xs text-stone-500 dark:text-stone-400 mb-1.5">
💡
</p>
<input
type="url"
value={xiaohongshuUrl}
@@ -317,18 +306,17 @@ export default function JoinPage() {
}}
onBlur={handleUrlBlur}
placeholder="https://www.xiaohongshu.com/user/profile/xxx"
required
className="form-input"
/>
{validating && (
<p className="mt-1.5 text-xs text-amber-600 dark:text-amber-400"></p>
<p className="mt-1.5 text-xs text-amber-600 dark:text-amber-400">🔄 </p>
)}
{urlError && !validating && (
<p className="mt-1.5 text-xs text-red-600 dark:text-red-400">{urlError}</p>
<p className="mt-1.5 text-xs text-red-600 dark:text-red-400"> {urlError}</p>
)}
{profile && !urlError && (
<p className="mt-1.5 text-xs text-emerald-600 dark:text-emerald-400">
{"\u2713 \u5df2\u83b7\u53d6\uff1a"}{profile.nickname}
{profile.nickname}
{profile.redbookId && ` \u00b7 @${profile.redbookId}`}
{profile.ipLocation && ` \u00b7 ${profile.ipLocation}`}
{profile.personalLink && ` \u00b7 ${profile.personalLink}`}
@@ -339,24 +327,11 @@ export default function JoinPage() {
{` \u00b7 ${profileGenderLabel}`}
</p>
)}
{((profile) => false ? (
<p className="mt-1.5 text-xs text-emerald-600 dark:text-emerald-400">
{profile.nickname}
{profile.redbookId && ` · @${profile.redbookId}`}
{profile.ipLocation && ` · ${profile.ipLocation}`}
{profile.personalLink && ` · ${profile.personalLink}`}
{profile.following != null && ` · 关注 ${profile.following}`}
{profile.followers != null && ` · 粉丝 ${profile.followers}`}
{profile.likesAndCollects != null && ` · 获赞与收藏 ${profile.likesAndCollects}`}
{profile.postCount != null && ` · 发帖 ${profile.postCount}`}
{profile.gender && ` · ${profile.gender === "female" ? "女" : "男"}`}
</p>
) : null)(profile as NonNullable<typeof profile>)}
</div>
<div>
<label className="block text-sm font-medium text-stone-700 dark:text-stone-300 mb-2">
<span className="text-red-500">*</span>
💼 <span className="text-red-500">*</span>
</label>
<input
type="text"
@@ -369,94 +344,54 @@ export default function JoinPage() {
/>
</div>
<div className="grid sm:grid-cols-2 gap-4">
<div>
<label className="block text-sm font-medium text-stone-700 dark:text-stone-300 mb-2">
</label>
<input
type="text"
maxLength={140}
placeholder="用于拉群"
value={wechat}
onChange={(e) => setWechat(e.target.value)}
className="form-input"
/>
</div>
<div>
<label className="block text-sm font-medium text-stone-700 dark:text-stone-300 mb-2">
</label>
<input
type="tel"
maxLength={11}
pattern="^\d{11}$"
placeholder="请输入11位手机号"
value={phone}
onChange={(e) => setPhone(e.target.value.replace(/\D/g, "").slice(0, 11))}
className="form-input"
/>
</div>
</div>
<p className="text-xs text-stone-500 dark:text-stone-400 -mt-2">
</p>
<div>
<label className="block text-sm font-medium text-stone-700 dark:text-stone-300 mb-2">
<span className="text-red-500">*</span>
💬 <span className="text-red-500">*</span>
</label>
<textarea
maxLength={500}
rows={5}
placeholder="分享您的经历、兴趣或加入原因,越详细越好哦~"
value={intro}
onChange={(e) => setIntro(e.target.value)}
<input
type="text"
maxLength={140}
placeholder="用于拉群"
value={wechat}
onChange={(e) => setWechat(e.target.value)}
required
className="form-input min-h-[120px] resize-none"
className="form-input"
/>
<span className="text-xs text-stone-400 dark:text-stone-500">
{intro.length}/500
</span>
</div>
<div className="grid sm:grid-cols-2 gap-4">
<div>
<label className="block text-sm font-medium text-stone-700 dark:text-stone-300 mb-2">
<span className="text-red-500">*</span>
👤 <span className="text-red-500">*</span>
</label>
<select
value={education}
onChange={(e) => setEducation(e.target.value)}
value={gender}
onChange={(e) => setGender(e.target.value)}
required
className={`form-input appearance-none ${education ? "text-stone-800 dark:text-stone-100" : "text-stone-400 dark:text-stone-500"}`}
className={`form-input appearance-none ${gender ? "text-stone-800 dark:text-stone-100" : "text-stone-400 dark:text-stone-500"}`}
>
<option value=""></option>
{educationOptions.map((o) => (
<option value="女"></option>
<option value="男"></option>
</select>
</div>
<div>
<label className="block text-sm font-medium text-stone-700 dark:text-stone-300 mb-2">
📅 <span className="text-red-500">*</span>
</label>
<select
value={ageRange}
onChange={(e) => setAgeRange(e.target.value)}
required
className={`form-input appearance-none ${ageRange ? "text-stone-800 dark:text-stone-100" : "text-stone-400 dark:text-stone-500"}`}
>
<option value=""></option>
{ageRangeOptions.map((o) => (
<option key={o} value={o}>{o}</option>
))}
</select>
</div>
<div>
<label className="block text-sm font-medium text-stone-700 dark:text-stone-300 mb-2">
<span className="text-red-500">*</span>
</label>
<select
value={graduationYear}
onChange={(e) => setGraduationYear(e.target.value)}
required
className={`form-input appearance-none ${graduationYear ? "text-stone-800 dark:text-stone-100" : "text-stone-400 dark:text-stone-500"}`}
>
<option value=""></option>
{graduationYears.map((y) => (
<option key={y} value={y}>{y}</option>
))}
</select>
</div>
</div>
<p className="text-xs text-stone-500 dark:text-stone-400 -mt-2">
</p>
<div>
<label className="flex items-start gap-3 cursor-pointer">
@@ -468,31 +403,31 @@ export default function JoinPage() {
className="mt-1 rounded border-stone-300 text-amber-600 focus:ring-amber-500"
/>
<span className="text-xs sm:text-sm text-stone-600 dark:text-stone-400">
📋
</span>
</label>
</div>
{error && (
<p className="rounded-lg bg-red-50 dark:bg-red-900/30 px-4 py-3 text-sm text-red-600 dark:text-red-400">
{error}
<p className="rounded-lg bg-red-50 dark:bg-red-900/30 px-4 py-3 text-sm text-red-600 dark:text-red-400 flex items-center gap-2">
{error}
</p>
)}
<button
type="submit"
disabled={submitting || !!urlError || validating}
className="w-full rounded-xl bg-amber-600 py-3.5 text-base font-medium text-white transition-colors hover:bg-amber-700 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-50"
className="w-full rounded-xl bg-amber-600 py-3.5 text-base font-medium text-white transition-colors hover:bg-amber-700 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-50 flex items-center justify-center gap-2"
>
{submitting ? "提交中…" : "提交报名"}
{submitting ? "🔄 提交中…" : "📤 提交报名"}
</button>
</form>
</div>
</div>
<div className="mt-4 text-center">
<Link href="/" className="text-xs sm:text-sm text-stone-400 dark:text-stone-500 hover:text-amber-600">
<Link href="/" className="text-xs sm:text-sm text-stone-400 dark:text-stone-500 hover:text-amber-600 inline-flex items-center gap-1">
🏠
</Link>
</div>
</div>

83
app/lib/dates.ts Normal file
View File

@@ -0,0 +1,83 @@
/** 中国星期名称 */
const WEEKDAY_CN = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"] as const;
/** 中国时区 */
const TZ = "Asia/Shanghai";
/**
* 获取中国时区下的日期数字(月、日、星期)
*/
function getChinaDateParts(): { year: number; month: number; day: number; weekday: number } {
const now = new Date();
const formatter = new Intl.DateTimeFormat("en-CA", {
timeZone: TZ,
year: "numeric",
month: "numeric",
day: "numeric",
weekday: "short",
});
const parts = formatter.formatToParts(now);
const get = (type: string) => parseInt(parts.find((p) => p.type === type)?.value ?? "0", 10);
const weekdayStr = parts.find((p) => p.type === "weekday")?.value ?? "Sun";
const weekdayMap: Record<string, number> = { Sun: 0, Mon: 1, Tue: 2, Wed: 3, Thu: 4, Fri: 5, Sat: 6 };
return {
year: get("year"),
month: get("month"),
day: get("day"),
weekday: weekdayMap[weekdayStr] ?? 0,
};
}
/**
* 格式化为中文日期M月D日 周X
*/
function formatDateCN(month: number, day: number, weekday: number): string {
return `${month}${day}${WEEKDAY_CN[weekday]}`;
}
/**
* 获取下一个周六、周日的日期(中国日历)
* session-1 对应周六session-2 对应周日
*/
export function getNextWeekendDates(): { saturday: string; sunday: string } {
const { year, month, day, weekday } = getChinaDateParts();
let satM = month;
let satD = day;
let satW = 6;
let sunM = month;
let sunD = day;
let sunW = 0;
if (weekday === 0) {
// 今天周日:下周六 +6 天,下周日 +7 天
const d = new Date(year, month - 1, day);
d.setDate(d.getDate() + 6);
satM = d.getMonth() + 1;
satD = d.getDate();
d.setDate(d.getDate() + 1);
sunM = d.getMonth() + 1;
sunD = d.getDate();
} else if (weekday === 6) {
// 今天周六:明天周日
const d = new Date(year, month - 1, day);
d.setDate(d.getDate() + 1);
sunM = d.getMonth() + 1;
sunD = d.getDate();
} else {
// 周一至周五
const daysToSat = 6 - weekday;
const d = new Date(year, month - 1, day);
d.setDate(d.getDate() + daysToSat);
satM = d.getMonth() + 1;
satD = d.getDate();
d.setDate(d.getDate() + 1);
sunM = d.getMonth() + 1;
sunD = d.getDate();
}
return {
saturday: formatDateCN(satM, satD, 6),
sunday: formatDateCN(sunM, sunD, 0),
};
}

View File

@@ -1,14 +1,23 @@
"use client";
import { useEffect, useState } from "react";
import Link from "next/link";
import Image from "next/image";
import HeroSection from "./components/HeroSection";
import SessionCard from "./components/SessionCard";
import Footer from "./components/Footer";
import Header from "./components/Header";
import { SESSIONS, HOSTS } from "@/config/home.config";
import { getSessionsWithDates, HOSTS } from "@/config/home.config";
export default function Home() {
const [volunteers, setVolunteers] = useState<{ nickname: string; avatar?: string; xiaohongshu_url?: string }[]>([]);
useEffect(() => {
fetch("/api/join/volunteers")
.then((r) => r.json())
.then((d) => d?.volunteers && setVolunteers(d.volunteers))
.catch(() => {});
}, []);
return (
<div className="min-h-screen bg-[#faf8f5] dark:bg-stone-950 pb-20 sm:pb-12">
<Header />
@@ -25,7 +34,7 @@ export default function Home() {
</h3>
<ul className="space-y-1.5 text-sm text-stone-600 dark:text-stone-400">
<li>· loft民宿见</li>
<li>· 68 </li>
<li>· 48 </li>
<li>· OK</li>
</ul>
</div>
@@ -53,31 +62,25 @@ export default function Home() {
<div className="flex flex-col items-center text-center">
<div className="w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300 font-bold text-lg flex items-center justify-center mb-3">1</div>
<h4 className="font-semibold text-stone-800 dark:text-stone-100 text-sm sm:text-base"></h4>
<p className="mt-1 text-xs sm:text-sm text-stone-500 dark:text-stone-400"></p>
</div>
<div className="flex flex-col items-center text-center">
<div className="w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300 font-bold text-lg flex items-center justify-center mb-3">2</div>
<h4 className="font-semibold text-stone-800 dark:text-stone-100 text-sm sm:text-base"></h4>
<p className="mt-1 text-xs sm:text-sm text-stone-500 dark:text-stone-400"></p>
<h4 className="font-semibold text-stone-800 dark:text-stone-100 text-sm sm:text-base"></h4>
</div>
<div className="flex flex-col items-center text-center">
<div className="w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300 font-bold text-lg flex items-center justify-center mb-3">3</div>
<h4 className="font-semibold text-stone-800 dark:text-stone-100 text-sm sm:text-base"></h4>
<p className="mt-1 text-xs sm:text-sm text-stone-500 dark:text-stone-400">/</p>
<h4 className="font-semibold text-stone-800 dark:text-stone-100 text-sm sm:text-base"></h4>
</div>
</div>
<p className="mt-6 pt-6 border-t border-stone-100 dark:border-stone-700 text-xs sm:text-sm text-stone-500 dark:text-stone-400 text-center">
</p>
</div>
</section>
{/* 信任标签 */}
<div className="flex flex-wrap justify-center gap-x-6 gap-y-1.5 sm:gap-x-8 text-xs sm:text-sm text-stone-600 dark:text-stone-400">
<span>📍 </span>
<span>👥 68 </span>
<span> </span>
<span>🆓 </span>
<span>👥 48 </span>
<span> </span>
<span> </span>
</div>
{/* 本周场次 */}
@@ -86,7 +89,7 @@ export default function Home() {
<span>📅</span>
</h2>
<div className="grid gap-3 sm:gap-4 sm:grid-cols-2">
{SESSIONS.map((s, i) => (
{getSessionsWithDates().map((s, i) => (
<SessionCard key={s.id} session={s} index={i} />
))}
</div>
@@ -117,16 +120,18 @@ export default function Home() {
</div>
</section>
{/* 主理人 */}
{/* 发起人 + 志愿者 */}
<section>
<h2 className="text-lg sm:text-xl font-semibold text-stone-800 dark:text-stone-100 mb-4 sm:mb-5 flex items-center gap-2">
<span>👤</span>
<span>👤</span>
</h2>
<div className="grid sm:grid-cols-2 gap-3 sm:gap-4">
<div className="grid sm:grid-cols-2 gap-3 sm:gap-4 mb-4">
{HOSTS.map((host) => (
<Link
key={host.id}
href={`/host/${host.id}`}
href={"link" in host ? host.link : `/host/${host.id}`}
target={"link" in host && host.link.startsWith("http") ? "_blank" : undefined}
rel={"link" in host && host.link.startsWith("http") ? "noopener noreferrer" : undefined}
className="flex gap-3 sm:gap-4 p-4 sm:p-5 rounded-xl sm:rounded-2xl bg-white dark:bg-stone-900/80 border border-stone-200/80 dark:border-stone-700/80 hover:border-amber-200 dark:hover:border-amber-900/50 hover:shadow-lg transition-all"
>
<div className="relative w-14 h-14 sm:w-16 sm:h-16 shrink-0 rounded-full overflow-hidden border-2 border-amber-100 dark:border-amber-900/30">
@@ -146,6 +151,45 @@ export default function Home() {
</Link>
))}
</div>
{volunteers.length > 0 && (
<div className="rounded-xl sm:rounded-2xl bg-white dark:bg-stone-900/80 border border-stone-200/80 dark:border-stone-700/80 p-4 sm:p-5">
<h4 className="text-sm font-medium text-stone-700 dark:text-stone-300 mb-3">🙌 </h4>
<div className="flex flex-wrap items-center gap-3">
{volunteers.map((v, i) => {
const content = (
<>
<div className="relative w-10 h-10 rounded-full overflow-hidden border-2 border-amber-100 dark:border-amber-900/30 shrink-0">
{v.avatar ? (
<Image src={v.avatar} alt={v.nickname} fill sizes="40px" className="object-cover" unoptimized />
) : (
<div className="w-full h-full flex items-center justify-center bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300 text-sm font-medium">
{v.nickname.slice(0, 1) || "?"}
</div>
)}
</div>
<span className="text-xs text-stone-600 dark:text-stone-400">{v.nickname}</span>
</>
);
return v.xiaohongshu_url ? (
<a
key={i}
href={v.xiaohongshu_url}
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-2 hover:opacity-80"
title={v.nickname}
>
{content}
</a>
) : (
<span key={i} className="flex items-center gap-2" title={v.nickname}>
{content}
</span>
);
})}
</div>
</div>
)}
</section>
{/* FAQ */}
@@ -156,7 +200,7 @@ export default function Home() {
<div className="space-y-2 sm:space-y-3">
{[
{ q: "提交后多久会收到确认?", a: "活动前 12 天会联系,微信/短信确认。不匹配不会反复打扰~", icon: "⏱️" },
{ q: "第一次参加可以吗?", a: "可以呀!很多人都是第一次来。68 人小圈子、公开场地,聊得来就多聊~", icon: "✨" },
{ q: "第一次参加可以吗?", a: "可以呀!很多人都是第一次来。48 人小圈子、公开场地,聊得来就多聊~", icon: "✨" },
{ q: "临时有事怎么办?", a: "随时可以退出,提前说一声就行~", icon: "🔄" },
].map((faq) => (
<details
@@ -183,7 +227,7 @@ export default function Home() {
href="/join"
className="block w-full bg-amber-600 hover:bg-amber-700 text-white text-center py-3.5 sm:py-4 rounded-xl font-semibold text-sm sm:text-base shadow-lg shadow-amber-900/20 transition-all"
>
</Link>
<p className="mt-3 text-center text-xs sm:text-sm text-stone-500 dark:text-stone-400">

339
app/volunteer/page.tsx Normal file
View File

@@ -0,0 +1,339 @@
"use client";
import { useState, type FormEvent } from "react";
import Link from "next/link";
import ThemeToggle from "../components/ThemeToggle";
const ageRangeOptions = ["18-22", "23-27", "28-32", "33-37", "38+"];
function getDisplayCount(text?: string, value?: number | string, suffix = ""): string | null {
if (typeof text === "string" && text.trim()) return `${text}${suffix}`;
if (typeof value === "number" || typeof value === "string") return `${value}${suffix}`;
return null;
}
export default function VolunteerPage() {
const [xiaohongshuUrl, setXiaohongshuUrl] = useState("");
const [profession, setProfession] = useState("");
const [wechat, setWechat] = useState("");
const [gender, setGender] = useState("");
const [ageRange, setAgeRange] = useState("");
const [agreeRules, setAgreeRules] = useState(false);
const [urlError, setUrlError] = useState<string | null>(null);
const [profile, setProfile] = useState<{
nickname: string;
avatarUrl?: string;
resolvedUrl?: string;
postCountText?: string;
postCount?: number;
} | null>(null);
const [validating, setValidating] = useState(false);
const [submitted, setSubmitted] = useState(false);
const [submitting, setSubmitting] = useState(false);
const [error, setError] = useState<string | null>(null);
const handleUrlBlur = async () => {
const url = xiaohongshuUrl.trim();
if (!url) {
setUrlError(null);
setProfile(null);
return;
}
setValidating(true);
setUrlError(null);
setProfile(null);
try {
const validateRes = await fetch("/api/xiaohongshu/validate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ url }),
});
const validateData = await validateRes.json();
if (!validateData.valid) {
setUrlError(validateData.error || "小红书link异常");
return;
}
const profileRes = await fetch("/api/xiaohongshu/profile", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ url }),
});
const profileData = await profileRes.json();
if (profileData.ok) {
setProfile({
nickname: profileData.nickname,
avatarUrl: profileData.avatarUrl,
resolvedUrl: profileData.resolvedUrl,
postCountText: profileData.postCountText,
postCount: profileData.postCount ?? 0,
});
} else {
setUrlError(profileData.error || "获取资料失败");
}
} catch {
setUrlError("网络异常,请重试");
} finally {
setValidating(false);
}
};
const handleSubmit = async (e: FormEvent) => {
e.preventDefault();
setError(null);
if (xiaohongshuUrl.trim() && urlError) {
setError("请先修正小红书链接");
return;
}
if (!profession.trim()) {
setError("请填写职业");
return;
}
if (!wechat.trim()) {
setError("请填写微信号");
return;
}
if (!gender) {
setError("请选择性别");
return;
}
if (!ageRange) {
setError("请选择年龄区间");
return;
}
if (!agreeRules) {
setError("请同意志愿者须知");
return;
}
setSubmitting(true);
try {
const genderLabel = gender === "女" ? "女" : gender === "男" ? "男" : "无";
const postCountLabel = getDisplayCount(profile?.postCountText, profile?.postCount) ?? "0";
const submitXiaohongshuUrl = profile?.resolvedUrl || xiaohongshuUrl.trim() || "";
const submitReasonParts = [
`[志愿者]`,
`职业:${profession.trim()}`,
`性别:${genderLabel}`,
`年龄:${ageRange}`,
profile && `发帖:${postCountLabel}`,
].filter(Boolean);
const res = await fetch("/api/join", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
nickname: profile?.nickname || "匿名",
wechat: wechat.trim(),
phone: "",
profession: profession.trim(),
xiaohongshu_url: submitXiaohongshuUrl,
xiaohongshu_avatar_url: profile?.avatarUrl || "",
gender: genderLabel,
intro: submitReasonParts.join(" | "),
age_range: ageRange,
city: "深圳",
session: "volunteer",
education: "",
graduation_year: "",
agree_rules: true,
is_volunteer: true,
first_time: "",
status: "",
activity_type: "",
why_join: "",
region: "",
available_time: "",
}),
});
const data = await res.json();
if (!res.ok || !data?.ok) {
throw new Error(data?.error || "提交失败,请稍后重试");
}
setSubmitted(true);
} catch (err) {
setError(err instanceof Error ? err.message : "网络错误,请重试");
} finally {
setSubmitting(false);
}
};
if (submitted) {
return (
<div className="flex min-h-screen items-center justify-center bg-[#faf8f5] dark:bg-stone-950 px-4 py-8">
<div className="w-full max-w-md animate-fade-in rounded-2xl bg-white dark:bg-stone-900 p-6 sm:p-10 text-center shadow-lg border border-stone-200 dark:border-stone-800">
<div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-emerald-50 dark:bg-emerald-900/30 text-4xl">
🙌
</div>
<h2 className="text-xl sm:text-2xl font-bold text-stone-800 dark:text-stone-100">
</h2>
<p className="mt-2 text-sm text-stone-500 dark:text-stone-400">
</p>
<Link
href="/"
className="mt-6 sm:mt-8 inline-flex items-center gap-2 rounded-xl bg-amber-600 px-6 sm:px-8 py-2.5 sm:py-3 font-medium text-white text-sm sm:text-base transition-colors hover:bg-amber-700"
>
🏠
</Link>
</div>
</div>
);
}
return (
<div className="min-h-screen bg-[#faf8f5] dark:bg-stone-950">
<header className="sticky top-0 z-40 w-full border-b border-stone-200/80 dark:border-stone-800 bg-[#faf8f5]/95 dark:bg-stone-950/95 backdrop-blur">
<div className="max-w-2xl mx-auto px-4 h-12 sm:h-14 flex items-center justify-between">
<Link href="/" className="text-sm font-medium text-stone-600 dark:text-stone-400">
</Link>
<ThemeToggle />
</div>
</header>
<div className="mx-auto max-w-2xl px-4 sm:px-6 py-8 lg:py-10">
<div className="overflow-hidden bg-white dark:bg-stone-900 shadow-sm sm:rounded-2xl">
<div className="relative h-28 sm:h-36 overflow-hidden bg-gradient-to-br from-amber-500 via-amber-600 to-amber-700">
<div className="absolute inset-0 flex flex-col items-center justify-center text-white">
<div className="text-4xl sm:text-5xl" aria-hidden>🤝</div>
</div>
</div>
<div className="px-4 sm:px-6 py-5 sm:py-6">
<div className="mb-6 rounded-xl bg-amber-50 dark:bg-amber-900/20 p-4">
<h3 className="font-semibold text-stone-800 dark:text-stone-100 text-sm mb-2"></h3>
<ul className="text-xs sm:text-sm text-stone-600 dark:text-stone-400 space-y-1">
<li>· </li>
<li>· </li>
<li>· </li>
</ul>
</div>
<form onSubmit={handleSubmit} className="space-y-5">
<div>
<label className="block text-sm font-medium text-stone-700 dark:text-stone-300 mb-2">
📱 <span className="text-red-500">*</span>
</label>
<input
type="url"
value={xiaohongshuUrl}
onChange={(e) => { setXiaohongshuUrl(e.target.value); setUrlError(null); }}
onBlur={handleUrlBlur}
placeholder="https://www.xiaohongshu.com/user/profile/xxx"
required
className="form-input"
/>
{validating && <p className="mt-1.5 text-xs text-amber-600 dark:text-amber-400">🔄 </p>}
{urlError && !validating && <p className="mt-1.5 text-xs text-red-600 dark:text-red-400"> {urlError}</p>}
{profile && !urlError && (
<p className="mt-1.5 text-xs text-emerald-600 dark:text-emerald-400">
{profile.nickname}
</p>
)}
</div>
<div>
<label className="block text-sm font-medium text-stone-700 dark:text-stone-300 mb-2">
💼 <span className="text-red-500">*</span>
</label>
<input
type="text"
maxLength={140}
placeholder="您的职业或专业"
value={profession}
onChange={(e) => setProfession(e.target.value)}
required
className="form-input"
/>
</div>
<div>
<label className="block text-sm font-medium text-stone-700 dark:text-stone-300 mb-2">
💬 <span className="text-red-500">*</span>
</label>
<input
type="text"
maxLength={140}
placeholder="用于联系"
value={wechat}
onChange={(e) => setWechat(e.target.value)}
required
className="form-input"
/>
</div>
<div className="grid sm:grid-cols-2 gap-4">
<div>
<label className="block text-sm font-medium text-stone-700 dark:text-stone-300 mb-2">
👤 <span className="text-red-500">*</span>
</label>
<select
value={gender}
onChange={(e) => setGender(e.target.value)}
required
className={`form-input appearance-none ${gender ? "text-stone-800 dark:text-stone-100" : "text-stone-400 dark:text-stone-500"}`}
>
<option value=""></option>
<option value="女"></option>
<option value="男"></option>
</select>
</div>
<div>
<label className="block text-sm font-medium text-stone-700 dark:text-stone-300 mb-2">
📅 <span className="text-red-500">*</span>
</label>
<select
value={ageRange}
onChange={(e) => setAgeRange(e.target.value)}
required
className={`form-input appearance-none ${ageRange ? "text-stone-800 dark:text-stone-100" : "text-stone-400 dark:text-stone-500"}`}
>
<option value=""></option>
{ageRangeOptions.map((o) => (
<option key={o} value={o}>{o}</option>
))}
</select>
</div>
</div>
<div>
<label className="flex items-start gap-3 cursor-pointer">
<input
type="checkbox"
checked={agreeRules}
onChange={(e) => setAgreeRules(e.target.checked)}
required
className="mt-1 rounded border-stone-300 text-amber-600 focus:ring-amber-500"
/>
<span className="text-xs sm:text-sm text-stone-600 dark:text-stone-400">
📋
</span>
</label>
</div>
{error && (
<p className="rounded-lg bg-red-50 dark:bg-red-900/30 px-4 py-3 text-sm text-red-600 dark:text-red-400 flex items-center gap-2">
{error}
</p>
)}
<button
type="submit"
disabled={submitting || !!urlError || validating}
className="w-full rounded-xl bg-amber-600 py-3.5 text-base font-medium text-white transition-colors hover:bg-amber-700 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-50 flex items-center justify-center gap-2"
>
{submitting ? "🔄 提交中…" : "📤 提交志愿者申请"}
</button>
</form>
</div>
</div>
<div className="mt-4 text-center">
<Link href="/" className="text-xs sm:text-sm text-stone-400 dark:text-stone-500 hover:text-amber-600 inline-flex items-center gap-1">
🏠
</Link>
</div>
</div>
</div>
);
}

View File

@@ -1,3 +1,5 @@
import { getNextWeekendDates } from "@/app/lib/dates";
/** 开放城市 - 仅深圳 */
export const CITIES = ["深圳"] as const;
@@ -13,8 +15,8 @@ export const ACTIVITY_TYPES = {
export const SESSION_TAGS = {
"first-friendly": "首次友好",
"public-venue": "公开场地",
"small-group": "6-8 人",
"weekend-pm": "周末下午",
"min-4": "4人成行",
"weekend-pm": "周末",
"loft": "loft民宿",
"light-topic": "轻话题",
} as const;
@@ -23,29 +25,44 @@ export const SESSION_TAGS = {
const IMG_LOFT_1 = "https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=400&h=300&fit=crop";
const IMG_LOFT_2 = "https://images.unsplash.com/photo-1502672260266-1c1ef2d93688?w=400&h=300&fit=crop";
/** 本周活动场次 */
export const SESSIONS = [
{ id: "session-1", date: "3月16日 周六", time: "14:00", place: "南山区某loft民宿", city: "深圳", type: "skill-exchange" as const, title: "周末技能交换", coverImage: IMG_LOFT_1, tags: ["first-friendly", "public-venue", "small-group", "weekend-pm", "loft", "light-topic"] as const },
{ id: "session-2", date: "3月17日 周日", time: "15:00", place: "福田区某loft民宿", city: "深圳", type: "side-hustle" as const, title: "副业沙龙", coverImage: IMG_LOFT_2, tags: ["first-friendly", "public-venue", "small-group", "weekend-pm", "loft"] as const },
];
/** 龙华区红山地铁站 GPS */
export const HONGSHAN_COORDS = { lat: 22.6569, lng: 114.0297 };
/** 本周活动场次(日期占位,实际由 getSessionsWithDates 动态计算) */
const SESSIONS_BASE = [
{ id: "session-1", time: "15:00-18:00", place: "龙华区红山地铁站", city: "深圳", type: "skill-exchange" as const, title: "周末轻社交", coverImage: IMG_LOFT_1, tags: ["first-friendly", "public-venue", "min-4", "weekend-pm", "loft", "light-topic"] as const },
{ id: "session-2", time: "09:00-12:00", place: "龙华区红山地铁站", city: "深圳", type: "side-hustle" as const, title: "数字游民沙龙", coverImage: IMG_LOFT_2, tags: ["first-friendly", "public-venue", "min-4", "weekend-pm", "loft"] as const },
] as const;
/** 获取带动态日期的本周场次(周六/周日自动计算,中国时区) */
export function getSessionsWithDates() {
const { saturday, sunday } = getNextWeekendDates();
return [
{ ...SESSIONS_BASE[0], date: saturday },
{ ...SESSIONS_BASE[1], date: sunday },
];
}
/** 本周活动场次(静态引用,用于 API 等不需要日期的场景) */
export const SESSIONS = SESSIONS_BASE;
/** 历史活动(用于时间轴展示) */
export const PAST_SESSIONS = [
{ id: "past-1", date: "3月9日 周六", time: "14:00", place: "福田区某loft民宿", city: "深圳", type: "skill-exchange" as const, title: "周末技能交换", coverImage: IMG_LOFT_1, tags: ["loft", "light-topic"] as const },
{ id: "past-2", date: "3月10日 周日", time: "15:00", place: "南山区某loft民宿", city: "深圳", type: "side-hustle" as const, title: "副业沙龙", coverImage: IMG_LOFT_2, tags: ["loft"] as const },
{ id: "past-3", date: "3月2日 周六", time: "14:00", place: "南山区某loft民宿", city: "深圳", type: "skill-exchange" as const, title: "周末技能交换", coverImage: IMG_LOFT_1, tags: ["loft"] as const },
{ id: "past-4", date: "3月3日 周日", time: "15:00", place: "福田区某loft民宿", city: "深圳", type: "side-hustle" as const, title: "副业沙龙", coverImage: IMG_LOFT_2, tags: ["loft"] as const },
{ id: "past-5", date: "2月24日 周六", time: "14:00", place: "南山区某loft民宿", city: "深圳", type: "skill-exchange" as const, title: "周末技能交换", coverImage: IMG_LOFT_1, tags: ["loft"] as const },
{ id: "past-1", date: "3月9日 周六", time: "15:00-18:00", place: "龙华区红山地铁站", city: "深圳", type: "skill-exchange" as const, title: "周末轻社交", coverImage: IMG_LOFT_1, tags: ["loft", "light-topic"] as const },
{ id: "past-2", date: "3月10日 周日", time: "09:00-12:00", place: "龙华区红山地铁站", city: "深圳", type: "side-hustle" as const, title: "数字游民沙龙", coverImage: IMG_LOFT_2, tags: ["loft"] as const },
{ id: "past-3", date: "3月2日 周六", time: "15:00-18:00", place: "龙华区红山地铁站", city: "深圳", type: "skill-exchange" as const, title: "周末轻社交", coverImage: IMG_LOFT_1, tags: ["loft"] as const },
{ id: "past-4", date: "3月3日 周日", time: "09:00-12:00", place: "龙华区红山地铁站", city: "深圳", type: "side-hustle" as const, title: "数字游民沙龙", coverImage: IMG_LOFT_2, tags: ["loft"] as const },
{ id: "past-5", date: "2月24日 周六", time: "15:00-18:00", place: "龙华区红山地铁站", city: "深圳", type: "skill-exchange" as const, title: "周末轻社交", coverImage: IMG_LOFT_1, tags: ["loft"] as const },
];
/** 主理人 */
/** 发起人 - 点击跳转小红书 */
export const HOSTS = [
{ id: "host-1", name: "主理人1", avatar: "https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=120&h=120&fit=crop&crop=face", bio: "数字游民社区发起人,热爱连接同频的人。", intro: "主理人1的详细介绍... 负责周末沙龙的策划与运营,希望打造一个轻松、有温度的线下社交空间。" },
{ id: "host-2", name: "主理人2", avatar: "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=120&h=120&fit=crop&crop=face", bio: "副业探索者,相信小圈子有大能量。", intro: "主理人2的详细介绍... 专注副业沙龙与技能交换,帮助大家发现更多可能性。" },
{ id: "host-1", name: "发起人", avatar: "/images/11.webp", bio: "数字游民社区发起人,热爱连接同频的人。", link: "https://xhslink.com/m/9H50QYiVOVx" },
{ id: "host-2", name: "志愿者", avatar: "/images/volunteer-mystery.svg", bio: "签到、茶歇准备、拍照摄像。", link: "/volunteer" },
];
/** 数字游民社区 - 符合条件时显示的微信二维码(需替换为实际图片 URL */
export const DIGITAL_NOMAD_WECHAT_QR = "/images/wechat-qr-placeholder.svg";
/** 数字游民社区 - 符合条件时显示的微信二维码 */
export const DIGITAL_NOMAD_WECHAT_QR = "/images/QR.png";
/** 最近报名意向 - mock 数据,含小红书昵称与主页链接(悬浮显示昵称,点击不跳转) */
export const RECENT_JOINERS = [

BIN
public/images/11.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
public/images/QR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120" fill="none">
<circle cx="60" cy="60" r="55" fill="#f5f5f4" stroke="#d6d3d1" stroke-width="2"/>
<circle cx="60" cy="45" r="18" fill="#d6d3d1"/>
<path d="M30 95 Q60 75 90 95" stroke="#d6d3d1" stroke-width="4" fill="none" stroke-linecap="round"/>
<text x="60" y="115" text-anchor="middle" font-size="10" fill="#78716c">?</text>
</svg>

After

Width:  |  Height:  |  Size: 402 B