Hide membership entry, brand ebook/video as 共创, harden H5 touch layout, and align copy with everyday nomad language. Co-authored-by: Cursor <cursoragent@cursor.com>
337 lines
11 KiB
TypeScript
337 lines
11 KiB
TypeScript
"use client";
|
||
|
||
import { useRef, useState, type FormEvent } from "react";
|
||
import Link from "next/link";
|
||
import {
|
||
ArrowUpRight,
|
||
Check,
|
||
Heart,
|
||
LockKeyhole,
|
||
MessageCircle,
|
||
Radio,
|
||
Send,
|
||
Users,
|
||
} from "lucide-react";
|
||
import { WechatOaModal } from "~/components/social-follow";
|
||
import SiteShell from "./SiteShell";
|
||
import JoinPayModal from "./JoinPayModal";
|
||
import { PageIntro } from "./SocialUI";
|
||
import { useSocialConfig } from "./SocialExperience";
|
||
import { socialApi } from "@social/lib/api";
|
||
import { useLocalState } from "@social/lib/useLocalState";
|
||
import { socialPath } from "@social/lib/socialPath";
|
||
import { resolveSocialLandingCopy } from "@social/lib/landing";
|
||
|
||
export function CommunityFeedback() {
|
||
const [draft, setDraft] = useLocalState<{
|
||
kind: "反馈" | "建议";
|
||
text: string;
|
||
contact: string;
|
||
}>("feedback-draft", { kind: "建议", text: "", contact: "" });
|
||
const [delivery, setDelivery] = useLocalState("feedback-delivery", "draft");
|
||
const [status, setStatus] = useState("");
|
||
const [busy, setBusy] = useState(false);
|
||
const lock = useRef(false);
|
||
const update = (key: keyof typeof draft, value: string) => {
|
||
setDraft((current) => ({ ...current, [key]: value }));
|
||
setDelivery("draft");
|
||
setStatus("");
|
||
};
|
||
const reset = () => {
|
||
setDraft({ kind: "建议", text: "", contact: "" });
|
||
setDelivery("draft");
|
||
setStatus("");
|
||
};
|
||
const submit = async (event: FormEvent) => {
|
||
event.preventDefault();
|
||
if (!draft.text.trim() || lock.current || delivery === "sent") return;
|
||
lock.current = true;
|
||
setBusy(true);
|
||
try {
|
||
await socialApi.postFeedback({
|
||
...draft,
|
||
text: draft.text.trim(),
|
||
contact: draft.contact.trim(),
|
||
});
|
||
setDelivery("sent");
|
||
setStatus("已提交,感谢反馈。");
|
||
} catch {
|
||
setDelivery("local");
|
||
setStatus("先留在你这边了,有网后再试一次");
|
||
} finally {
|
||
lock.current = false;
|
||
setBusy(false);
|
||
}
|
||
};
|
||
return (
|
||
<SiteShell title="说说想法">
|
||
<PageIntro title="意见反馈" accent="我们在听" />
|
||
<section className="social-panel social-feedback-panel reveal">
|
||
<div className="social-page-kicker">
|
||
<span />
|
||
说说你的想法
|
||
</div>
|
||
<h2 className="social-feedback-title">哪里用得不顺手?告诉我们</h2>
|
||
<p className="social-muted">
|
||
发不出去也没关系,会先留在你这边,有网后再试。我们会看,但不保证马上回复。
|
||
</p>
|
||
{delivery === "sent" ? (
|
||
<div className="social-join-success">
|
||
<p className="social-status" role="status">
|
||
{status || "已提交"}
|
||
</p>
|
||
<div className="social-actions">
|
||
<button
|
||
type="button"
|
||
className="social-btn primary"
|
||
onClick={reset}
|
||
>
|
||
再提一条
|
||
</button>
|
||
<Link className="social-btn" href={socialPath("/")}>
|
||
回社区首页
|
||
</Link>
|
||
</div>
|
||
</div>
|
||
) : (
|
||
<form className="social-form" onSubmit={(event) => void submit(event)}>
|
||
<fieldset disabled={busy} className="social-fieldset">
|
||
<div className="social-filters">
|
||
{(["建议", "反馈"] as const).map((kind) => (
|
||
<button
|
||
type="button"
|
||
key={kind}
|
||
className={draft.kind === kind ? "active" : ""}
|
||
aria-pressed={draft.kind === kind}
|
||
onClick={() => update("kind", kind)}
|
||
>
|
||
{kind}
|
||
</button>
|
||
))}
|
||
</div>
|
||
<label>
|
||
内容
|
||
<textarea
|
||
rows={6}
|
||
required
|
||
maxLength={3000}
|
||
value={draft.text}
|
||
onChange={(event) => update("text", event.target.value)}
|
||
placeholder="具体页面 / 操作 / 期望…"
|
||
/>
|
||
<small>{draft.text.length}/3000</small>
|
||
</label>
|
||
<label>
|
||
联系方式(选填)
|
||
<input
|
||
maxLength={120}
|
||
value={draft.contact}
|
||
onChange={(event) => update("contact", event.target.value)}
|
||
placeholder="邮箱 / 微信"
|
||
/>
|
||
</label>
|
||
</fieldset>
|
||
<button
|
||
type="submit"
|
||
className="social-btn primary"
|
||
disabled={busy || !draft.text.trim()}
|
||
>
|
||
<Send size={15} />
|
||
{busy ? "提交中…" : delivery === "local" ? "重试" : "提交"}
|
||
</button>
|
||
{status && (
|
||
<p
|
||
role="status"
|
||
className={`social-status${delivery === "local" ? " warn" : ""}`}
|
||
>
|
||
{status}
|
||
</p>
|
||
)}
|
||
</form>
|
||
)}
|
||
</section>
|
||
</SiteShell>
|
||
);
|
||
}
|
||
|
||
export function CommunityJoin() {
|
||
const config = useSocialConfig();
|
||
const copy = resolveSocialLandingCopy(config.copy);
|
||
const [payOpen, setPayOpen] = useState(false);
|
||
const [oaOpen, setOaOpen] = useState(false);
|
||
return (
|
||
<SiteShell title="加入社区">
|
||
<PageIntro title="加入社区" />
|
||
<div className="social-join-paths">
|
||
<article className="social-panel social-join-path reveal">
|
||
<span className="social-page-kicker">
|
||
<span />
|
||
方式一
|
||
</span>
|
||
<span className="social-join-path-ico" aria-hidden>
|
||
<LockKeyhole size={24} strokeWidth={1.4} />
|
||
</span>
|
||
<h2>{copy.socialPayJoinLabel}</h2>
|
||
<p>
|
||
填一下邮箱,按提示完成支付就能加入。电脑、手机浏览器和微信里都会带你走合适的支付方式。
|
||
</p>
|
||
{config.flags.payEnabled ? (
|
||
<button
|
||
type="button"
|
||
className="social-btn coral"
|
||
onClick={() => setPayOpen(true)}
|
||
>
|
||
{copy.socialPayJoinLabel}
|
||
<ArrowUpRight size={15} />
|
||
</button>
|
||
) : (
|
||
<span className="social-status">暂时还不能购买</span>
|
||
)}
|
||
</article>
|
||
<article className="social-panel social-join-path reveal">
|
||
<span className="social-page-kicker">
|
||
<span />
|
||
方式二
|
||
</span>
|
||
<span className="social-join-path-ico" aria-hidden>
|
||
<MessageCircle size={24} strokeWidth={1.4} />
|
||
</span>
|
||
<h2>{copy.socialOaJoinLabel}</h2>
|
||
<p>
|
||
关注
|
||
{config.copy.wechatOaName
|
||
? `「${config.copy.wechatOaName}」`
|
||
: "公众号"}
|
||
,先看看社区动态和活动,再决定要不要正式加入。
|
||
</p>
|
||
<button
|
||
type="button"
|
||
className="social-btn primary"
|
||
onClick={() => setOaOpen(true)}
|
||
>
|
||
{copy.socialOaJoinLabel}
|
||
<ArrowUpRight size={15} />
|
||
</button>
|
||
</article>
|
||
</div>
|
||
<h3 className="social-onboarding-heading">加入后可以先去这些地方</h3>
|
||
<div className="social-grid social-onboarding-grid">
|
||
{[
|
||
{
|
||
icon: MessageCircle,
|
||
title: "大家聊天",
|
||
desc: "跟大家打个招呼",
|
||
href: socialPath("/chat"),
|
||
cta: "去聊聊",
|
||
},
|
||
{
|
||
icon: Heart,
|
||
title: "认识一下",
|
||
desc: "左右滑,慢慢认识新朋友",
|
||
href: socialPath("/date"),
|
||
cta: "去看看",
|
||
},
|
||
{
|
||
icon: Users,
|
||
title: "我的介绍",
|
||
desc: "写几句,让别人认识你",
|
||
href: socialPath("/roster"),
|
||
cta: "去写写",
|
||
},
|
||
{
|
||
icon: Radio,
|
||
title: "开视频聊聊",
|
||
desc: "开摄像头,面对面认识",
|
||
href: socialPath("/meetup"),
|
||
cta: "去开视频",
|
||
},
|
||
].map((item) => (
|
||
<article className="social-card social-onboarding-card" key={item.title}>
|
||
<div className="social-card-top">
|
||
<item.icon size={24} strokeWidth={1.3} />
|
||
</div>
|
||
<h2>{item.title}</h2>
|
||
<p className="social-muted">{item.desc}</p>
|
||
<Link className="social-btn primary" href={item.href}>
|
||
{item.cta}
|
||
<ArrowUpRight size={14} />
|
||
</Link>
|
||
</article>
|
||
))}
|
||
</div>
|
||
<JoinPayModal open={payOpen} onClose={() => setPayOpen(false)} />
|
||
<WechatOaModal open={oaOpen} onClose={() => setOaOpen(false)} />
|
||
</SiteShell>
|
||
);
|
||
}
|
||
|
||
export function CommunityMembership() {
|
||
const config = useSocialConfig();
|
||
const price = ((config.copy.vipPriceFen ?? 29800) / 100).toLocaleString(
|
||
"zh-CN",
|
||
{ maximumFractionDigits: 2 },
|
||
);
|
||
const benefits = [
|
||
"更好地展示自己的介绍",
|
||
"更方便认识想见的人",
|
||
"视频见面与同城活动更新提醒",
|
||
"找搭子做事时优先沟通",
|
||
];
|
||
return (
|
||
<SiteShell title="会员">
|
||
<PageIntro title="会员" accent={`¥${price}`} />
|
||
<section className="social-membership-banner reveal">
|
||
<div className="social-page-kicker">
|
||
<span />
|
||
会员通行证
|
||
</div>
|
||
<h2 className="social-feedback-title">游民会员</h2>
|
||
<p className="social-muted">
|
||
开通后能更方便参与社区。具体权益以支付页说明为准。
|
||
</p>
|
||
<ul className="social-benefit-list">
|
||
{benefits.map((item) => (
|
||
<li key={item}>
|
||
<Check size={15} />
|
||
{item}
|
||
</li>
|
||
))}
|
||
</ul>
|
||
<div className="social-actions">
|
||
{config.flags.payEnabled ? (
|
||
<Link className="social-btn coral" href="/vip">
|
||
{config.copy.vipCta || "开通会员"}
|
||
<ArrowUpRight size={15} />
|
||
</Link>
|
||
) : (
|
||
<span className="social-status">暂时还不能购买</span>
|
||
)}
|
||
<Link className="social-btn" href={socialPath("/join")}>
|
||
去加入社区
|
||
</Link>
|
||
</div>
|
||
</section>
|
||
<div className="social-grid">
|
||
{[
|
||
{ title: "我的介绍", href: socialPath("/roster") },
|
||
{ title: "认识一下", href: socialPath("/date") },
|
||
{ title: "找咖啡馆", href: socialPath("/coffeechat") },
|
||
{ title: "大家聊天", href: socialPath("/chat") },
|
||
].map((item) => (
|
||
<Link
|
||
className="social-card social-membership-card"
|
||
href={item.href}
|
||
key={item.href}
|
||
>
|
||
<Check size={18} />
|
||
<h2>{item.title}</h2>
|
||
<span>
|
||
打开 <ArrowUpRight size={14} />
|
||
</span>
|
||
</Link>
|
||
))}
|
||
</div>
|
||
</SiteShell>
|
||
);
|
||
}
|