Pay-then-profile join desk with live card, S3 upload fallback, hydration-safe drafts; document on test9 README. Co-authored-by: Cursor <cursoragent@cursor.com>
948 lines
31 KiB
TypeScript
948 lines
31 KiB
TypeScript
import { Link } from 'react-router-dom'
|
||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||
import { api } from '../api'
|
||
import './BookEdit.css'
|
||
import './Vip.css'
|
||
|
||
type JoinAction = 'popup' | 'vip'
|
||
type TabKey = 'pay' | 'switches' | 'landing' | 'content'
|
||
|
||
type VipTopic = {
|
||
id: string
|
||
icon: string
|
||
title: string
|
||
desc: string
|
||
href: string
|
||
enabled: boolean
|
||
locked?: boolean
|
||
sort?: number
|
||
}
|
||
|
||
type VipVideo = {
|
||
id: string
|
||
icon: string
|
||
title: string
|
||
desc: string
|
||
href: string
|
||
enabled: boolean
|
||
sort?: number
|
||
}
|
||
|
||
type VipEbook = {
|
||
id: string
|
||
title: string
|
||
desc: string
|
||
ebookId: string
|
||
href?: string
|
||
free: boolean
|
||
enabled: boolean
|
||
sort?: number
|
||
}
|
||
|
||
type VipContent = {
|
||
heroEyebrow: string
|
||
heroTitleAccent: string
|
||
heroTitleRest: string
|
||
heroLead: string
|
||
showStats: boolean
|
||
showTopics: boolean
|
||
showVideos: boolean
|
||
showEbooks: boolean
|
||
showCompare: boolean
|
||
showFaq: boolean
|
||
showCta: boolean
|
||
reviewMode: boolean
|
||
topics: VipTopic[]
|
||
videos: VipVideo[]
|
||
ebooks: VipEbook[]
|
||
compareTitle: string
|
||
compareDesc: string
|
||
faqTitle: string
|
||
faqSub: string
|
||
ctaChips: string[]
|
||
ctaSecondary: string
|
||
/** 空则课时页不展示「课程资料下载」 */
|
||
courseMaterialsUrl: string
|
||
courseMaterialsDesc: string
|
||
}
|
||
|
||
type VipCfg = {
|
||
ok?: boolean
|
||
vipEnabled: boolean
|
||
gameEnabled: boolean
|
||
joinGroupAction: JoinAction
|
||
vipWebBridgeEnabled?: boolean
|
||
vipPriceFen: number
|
||
vipProductId: string
|
||
vipCta: string
|
||
vipOfferKey?: string
|
||
is_free?: boolean
|
||
vipContent?: VipContent
|
||
updatedAt?: string
|
||
version?: number
|
||
}
|
||
|
||
type ProductOffer = {
|
||
key: string
|
||
label: string
|
||
name: string
|
||
product_id: string
|
||
price_fen: number
|
||
price_yuan: string
|
||
free: boolean
|
||
image: string
|
||
remark?: string
|
||
}
|
||
|
||
const emptyContent: VipContent = {
|
||
heroEyebrow: 'nomadro',
|
||
heroTitleAccent: '全模块解锁',
|
||
heroTitleRest: '持续更新 · 抱团出海',
|
||
heroLead: '一次付费,解锁电子书、视频教程、知识社群、即时问答,每周更新',
|
||
showStats: true,
|
||
showTopics: true,
|
||
showVideos: true,
|
||
showEbooks: true,
|
||
showCompare: true,
|
||
showFaq: true,
|
||
showCta: true,
|
||
reviewMode: false,
|
||
topics: [],
|
||
videos: [],
|
||
ebooks: [],
|
||
compareTitle: '单品 vs 会员',
|
||
compareDesc: '一次付费,全部解锁',
|
||
faqTitle: '常见问题',
|
||
faqSub: '购买前可快速了解会员权益与流程',
|
||
ctaChips: ['阶梯定价', '数字交付', '持续更新', '不支持退款'],
|
||
ctaSecondary: '已有账号',
|
||
courseMaterialsUrl: '',
|
||
courseMaterialsDesc: '课程配套资料已上传至网盘,报名后可复制链接打开夸克获取',
|
||
}
|
||
|
||
const empty: VipCfg = {
|
||
vipEnabled: false,
|
||
gameEnabled: false,
|
||
joinGroupAction: 'popup',
|
||
vipWebBridgeEnabled: false,
|
||
vipPriceFen: 8800,
|
||
vipProductId: 'tiktok',
|
||
vipCta: '立即加入',
|
||
vipOfferKey: 'tiktok',
|
||
is_free: false,
|
||
vipContent: emptyContent,
|
||
}
|
||
|
||
const SECTION_TOGGLES = [
|
||
['showStats', '数据条'],
|
||
['showTopics', '模块入口'],
|
||
['showVideos', '视频教程'],
|
||
['showEbooks', '电子书'],
|
||
['showCompare', '单品对比'],
|
||
['showFaq', 'FAQ'],
|
||
['showCta', '底部 CTA'],
|
||
] as const
|
||
|
||
const TABS: { key: TabKey; label: string }[] = [
|
||
{ key: 'pay', label: '付费方案' },
|
||
{ key: 'switches', label: '入口开关' },
|
||
{ key: 'landing', label: '落地页' },
|
||
{ key: 'content', label: '正式内容' },
|
||
]
|
||
|
||
const CONTENT_HUB = [
|
||
{
|
||
to: '/wechat/vip/ebooks/nomad',
|
||
ico: '🌍',
|
||
title: '数字游民',
|
||
desc: 'VIP 电子书 · 章节 Markdown',
|
||
primary: true,
|
||
},
|
||
{
|
||
to: '/wechat/vip/ebooks/cloudphone',
|
||
ico: '📱',
|
||
title: '云手机',
|
||
desc: 'VIP 电子书 · 章节 Markdown',
|
||
},
|
||
{
|
||
to: '/wechat/books/default',
|
||
ico: '▶️',
|
||
title: 'youtube运营笔记',
|
||
desc: '专属小册 · 试读% 与道具',
|
||
},
|
||
{
|
||
to: '/wechat/vip/course',
|
||
ico: '🎬',
|
||
title: '视频课程',
|
||
desc: '课时视频 URL 与配套文档',
|
||
},
|
||
{
|
||
to: '/wechat/memo',
|
||
ico: '👥',
|
||
title: '知识社群',
|
||
desc: '动态帖子、置顶与星球设置',
|
||
},
|
||
{
|
||
to: '/wechat/shop',
|
||
ico: '🛒',
|
||
title: '设备商城',
|
||
desc: '商品、卡密、订单发货',
|
||
},
|
||
{
|
||
to: '/wechat/books/default',
|
||
ico: '📕',
|
||
title: '微信小册',
|
||
desc: '试读 % 与章节(非 VIP 电子书)',
|
||
},
|
||
] as const
|
||
|
||
function fromContent(raw: Partial<VipContent> | undefined): VipContent {
|
||
const c = { ...emptyContent, ...(raw || {}) }
|
||
return {
|
||
...c,
|
||
showStats: c.showStats !== false,
|
||
showTopics: c.showTopics !== false,
|
||
showVideos: c.showVideos !== false,
|
||
showEbooks: c.showEbooks !== false,
|
||
showCompare: c.showCompare !== false,
|
||
showFaq: c.showFaq !== false,
|
||
showCta: c.showCta !== false,
|
||
reviewMode: !!c.reviewMode,
|
||
topics: Array.isArray(c.topics) ? c.topics : [],
|
||
videos: Array.isArray(c.videos) ? c.videos : [],
|
||
ebooks: Array.isArray(c.ebooks) ? c.ebooks : [],
|
||
ctaChips: Array.isArray(c.ctaChips) ? c.ctaChips : emptyContent.ctaChips,
|
||
courseMaterialsUrl: String(c.courseMaterialsUrl || '').trim(),
|
||
courseMaterialsDesc: String(
|
||
c.courseMaterialsDesc || emptyContent.courseMaterialsDesc,
|
||
),
|
||
}
|
||
}
|
||
|
||
function fromApi(data: VipCfg): VipCfg {
|
||
return {
|
||
vipEnabled: !!data.vipEnabled,
|
||
gameEnabled: !!data.gameEnabled,
|
||
joinGroupAction: data.joinGroupAction === 'vip' ? 'vip' : 'popup',
|
||
vipWebBridgeEnabled: !!data.vipWebBridgeEnabled,
|
||
vipPriceFen: Number(data.vipPriceFen) || 0,
|
||
vipProductId: String(data.vipProductId || ''),
|
||
vipCta: String(data.vipCta || '立即加入'),
|
||
vipOfferKey: String(data.vipOfferKey || ''),
|
||
is_free: !!data.is_free,
|
||
vipContent: fromContent(data.vipContent),
|
||
updatedAt: data.updatedAt,
|
||
version: data.version,
|
||
}
|
||
}
|
||
|
||
function Switch({
|
||
checked,
|
||
onChange,
|
||
label,
|
||
disabled,
|
||
}: {
|
||
checked: boolean
|
||
onChange: (v: boolean) => void
|
||
label: string
|
||
disabled?: boolean
|
||
}) {
|
||
return (
|
||
<label className="vip-switch" title={label}>
|
||
<input
|
||
type="checkbox"
|
||
checked={checked}
|
||
disabled={disabled}
|
||
onChange={(e) => onChange(e.target.checked)}
|
||
aria-label={label}
|
||
/>
|
||
<span className="vip-switch-track">
|
||
<span className="vip-switch-thumb" />
|
||
</span>
|
||
</label>
|
||
)
|
||
}
|
||
|
||
/** 微信小程序 · VIP / 加群 / 落地页运营(只写微信 · 不改抖音 · 不改订单) */
|
||
export default function Vip() {
|
||
const [cfg, setCfg] = useState<VipCfg | null>(null)
|
||
const [draft, setDraft] = useState<VipCfg>(empty)
|
||
const [offers, setOffers] = useState<ProductOffer[]>([])
|
||
const [err, setErr] = useState('')
|
||
const [msg, setMsg] = useState('')
|
||
const [busy, setBusy] = useState(false)
|
||
const [tab, setTab] = useState<TabKey>('pay')
|
||
|
||
const load = useCallback(async () => {
|
||
setErr('')
|
||
const [data, offerRes] = await Promise.all([
|
||
api<VipCfg>('/api/admin/vip'),
|
||
api<{ items: ProductOffer[] }>('/api/admin/product-offers'),
|
||
])
|
||
const next = fromApi(data)
|
||
setCfg(next)
|
||
setDraft(next)
|
||
setOffers(offerRes.items || [])
|
||
}, [])
|
||
|
||
useEffect(() => {
|
||
load().catch((e) => setErr(e.message || '加载失败'))
|
||
}, [load])
|
||
|
||
const isFree = !!draft.is_free || (draft.vipPriceFen <= 0 && !draft.vipProductId)
|
||
const content = draft.vipContent || emptyContent
|
||
const savedContent = cfg?.vipContent || emptyContent
|
||
|
||
const copyDirty = useMemo(() => {
|
||
return (
|
||
content.heroTitleAccent !== savedContent.heroTitleAccent ||
|
||
content.heroTitleRest !== savedContent.heroTitleRest ||
|
||
content.heroLead !== savedContent.heroLead ||
|
||
content.heroEyebrow !== savedContent.heroEyebrow
|
||
)
|
||
}, [content, savedContent])
|
||
|
||
const activeOfferKey = useMemo(() => {
|
||
if (draft.vipOfferKey) return draft.vipOfferKey
|
||
const hit = offers.find(
|
||
(o) =>
|
||
(!o.free && o.product_id === draft.vipProductId) ||
|
||
(o.free && isFree),
|
||
)
|
||
return hit?.key || ''
|
||
}, [draft.vipOfferKey, draft.vipProductId, offers, isFree])
|
||
|
||
async function save(patch: Partial<VipCfg>, okHint: string) {
|
||
setBusy(true)
|
||
setMsg('')
|
||
setErr('')
|
||
const next = { ...draft, ...patch }
|
||
if (patch.vipContent) {
|
||
next.vipContent = fromContent({ ...content, ...patch.vipContent })
|
||
}
|
||
setDraft(next)
|
||
try {
|
||
const body: Record<string, unknown> = {
|
||
vipEnabled: next.vipEnabled,
|
||
gameEnabled: next.gameEnabled,
|
||
joinGroupAction: next.joinGroupAction,
|
||
vipWebBridgeEnabled: !!next.vipWebBridgeEnabled,
|
||
vipPriceFen: next.vipPriceFen,
|
||
vipProductId: next.vipProductId,
|
||
vipCta: next.vipCta,
|
||
vipOfferKey: next.vipOfferKey,
|
||
}
|
||
if (patch.vipContent) {
|
||
body.vipContent = next.vipContent
|
||
}
|
||
const data = await api<VipCfg>('/api/admin/vip', {
|
||
method: 'PUT',
|
||
body: JSON.stringify(body),
|
||
})
|
||
const saved = fromApi(data)
|
||
setCfg(saved)
|
||
setDraft(saved)
|
||
setMsg(okHint)
|
||
} catch (e: any) {
|
||
setErr(e.message || '保存失败')
|
||
await load().catch(() => undefined)
|
||
} finally {
|
||
setBusy(false)
|
||
}
|
||
}
|
||
|
||
function patchContent(partial: Partial<VipContent>, okHint: string) {
|
||
void save({ vipContent: { ...content, ...partial } }, okHint)
|
||
}
|
||
|
||
function updateContentLocal(partial: Partial<VipContent>) {
|
||
setDraft({
|
||
...draft,
|
||
vipContent: { ...content, ...partial },
|
||
})
|
||
}
|
||
|
||
function toggleTopic(id: string, enabled: boolean) {
|
||
const topics = content.topics.map((t) => (t.id === id ? { ...t, enabled } : t))
|
||
patchContent({ topics }, enabled ? `模块「${id}」已显示` : `模块「${id}」已隐藏`)
|
||
}
|
||
|
||
function toggleVideo(id: string, enabled: boolean) {
|
||
const videos = content.videos.map((t) => (t.id === id ? { ...t, enabled } : t))
|
||
patchContent({ videos }, enabled ? `视频「${id}」已显示` : `视频「${id}」已隐藏`)
|
||
}
|
||
|
||
function toggleEbook(id: string, enabled: boolean) {
|
||
const ebooks = content.ebooks.map((t) => (t.id === id ? { ...t, enabled } : t))
|
||
patchContent({ ebooks }, enabled ? `电子书「${id}」已显示` : `电子书「${id}」已隐藏`)
|
||
}
|
||
|
||
async function applyOffer(offerKey: string) {
|
||
setBusy(true)
|
||
setMsg('')
|
||
setErr('')
|
||
try {
|
||
const data = await api<VipCfg>('/api/admin/vip/offer', {
|
||
method: 'POST',
|
||
body: JSON.stringify({ offer_key: offerKey }),
|
||
})
|
||
const saved = fromApi(data)
|
||
setCfg(saved)
|
||
setDraft(saved)
|
||
setMsg(
|
||
saved.is_free
|
||
? '已切换免费 · 小程序「立即加入」→ 免费加入'
|
||
: `已切换 ${saved.vipProductId} · CTA「${saved.vipCta}」约 3s 热更新`,
|
||
)
|
||
} catch (e: any) {
|
||
setErr(e.message || '切换方案失败')
|
||
await load().catch(() => undefined)
|
||
} finally {
|
||
setBusy(false)
|
||
}
|
||
}
|
||
|
||
if (!cfg && !err) {
|
||
return <div className="page vip-page vip-skeleton">加载 VIP 配置…</div>
|
||
}
|
||
|
||
const vipJumpOn = draft.joinGroupAction === 'vip'
|
||
const visibleSections = SECTION_TOGGLES.filter(([k]) => content[k]).length
|
||
|
||
return (
|
||
<div className="wx-page page vip-page">
|
||
<header className="page-head">
|
||
<div>
|
||
<div className="vip-eyebrow">WeChat · VIP · Remote</div>
|
||
<h1>VIP 运营</h1>
|
||
<p>
|
||
只影响微信小程序 · 不改抖音 · 不改订单。付费与落地页写远程配置,小程序约 3 秒热更新。
|
||
</p>
|
||
<div className="vip-chips">
|
||
<span className={`vip-chip ${draft.vipEnabled ? 'on' : ''}`}>
|
||
{draft.vipEnabled ? '会员入口开' : '会员入口关'}
|
||
</span>
|
||
<span className={`vip-chip ${isFree ? 'ok' : 'on'}`}>
|
||
{isFree ? '免费模式' : `¥${(draft.vipPriceFen / 100).toFixed(0)}`}
|
||
</span>
|
||
<span className={`vip-chip ${content.reviewMode ? 'warn' : ''}`}>
|
||
{content.reviewMode ? '审核模式' : '正式模式'}
|
||
</span>
|
||
<span className="vip-chip">
|
||
区块 {visibleSections}/{SECTION_TOGGLES.length}
|
||
</span>
|
||
{cfg?.version != null ? <span className="vip-chip">v{cfg.version}</span> : null}
|
||
</div>
|
||
</div>
|
||
</header>
|
||
|
||
{err ? (
|
||
<div className="vip-toast err">
|
||
<span>{err}</span>
|
||
<button type="button" onClick={() => setErr('')} aria-label="关闭">
|
||
×
|
||
</button>
|
||
</div>
|
||
) : null}
|
||
{msg ? (
|
||
<div className="vip-toast ok">
|
||
<span>{msg}</span>
|
||
<button type="button" onClick={() => setMsg('')} aria-label="关闭">
|
||
×
|
||
</button>
|
||
</div>
|
||
) : null}
|
||
|
||
<div className="vip-tabs" role="tablist">
|
||
{TABS.map((t) => (
|
||
<button
|
||
key={t.key}
|
||
type="button"
|
||
role="tab"
|
||
aria-selected={tab === t.key}
|
||
className={`vip-tab${tab === t.key ? ' active' : ''}`}
|
||
onClick={() => setTab(t.key)}
|
||
>
|
||
{t.label}
|
||
</button>
|
||
))}
|
||
</div>
|
||
|
||
{tab === 'pay' ? (
|
||
<section className="vip-card">
|
||
<div className="vip-card-head">
|
||
<div>
|
||
<h2>立即加入 · 付费控制</h2>
|
||
<p>
|
||
一键切换免费 / 已发布道具。切换后小程序按钮文案与价格立即跟随(已打开会员页约 3s
|
||
热更新)。
|
||
</p>
|
||
</div>
|
||
<div className="vip-preview-btn">
|
||
<span>小程序按钮预览</span>
|
||
<strong className={isFree ? 'free' : ''}>{draft.vipCta || '立即加入'}</strong>
|
||
<em>
|
||
{isFree
|
||
? '免费模式 · 不拉起虚拟支付'
|
||
: `道具 ${draft.vipProductId || '-'} · ¥${(draft.vipPriceFen / 100).toFixed(0)}`}
|
||
</em>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="offer-grid offer-grid-6">
|
||
{offers.map((o) => {
|
||
const active = o.key === activeOfferKey
|
||
const img = o.image ? `/${o.image.replace(/^\/+/, '')}` : ''
|
||
return (
|
||
<button
|
||
key={o.key}
|
||
type="button"
|
||
className={`offer-card ${active ? 'active' : ''} ${o.free ? 'is-free' : ''}`}
|
||
disabled={busy}
|
||
onClick={() => void applyOffer(o.key)}
|
||
>
|
||
{o.free ? (
|
||
<div className="offer-free-badge">FREE</div>
|
||
) : img ? (
|
||
<img className="offer-img" src={img} alt={o.label} />
|
||
) : (
|
||
<div className="offer-free-badge">{o.product_id.slice(0, 6)}</div>
|
||
)}
|
||
<strong>{o.label}</strong>
|
||
<span className="offer-id">{o.free ? '免费加入' : o.product_id}</span>
|
||
<em>{o.price_yuan}</em>
|
||
{o.remark && !o.remark.includes('unlock_percent') ? (
|
||
<i className="offer-remark">{o.remark}</i>
|
||
) : o.free ? (
|
||
<i className="offer-remark">不拉起支付 · 内容全开</i>
|
||
) : null}
|
||
{active ? <b className="offer-on">使用中</b> : null}
|
||
</button>
|
||
)
|
||
})}
|
||
</div>
|
||
|
||
{!isFree ? (
|
||
<div className="unlock-hero monetize-unlock">
|
||
<div className="price-box mono-box" style={{ width: '100%' }}>
|
||
<div>
|
||
<label>道具 ID</label>
|
||
<code>{draft.vipProductId || '—'}</code>
|
||
</div>
|
||
<div>
|
||
<label>价格</label>
|
||
<code>
|
||
¥{(draft.vipPriceFen / 100).toFixed(0)}({draft.vipPriceFen} 分)
|
||
</code>
|
||
</div>
|
||
<div>
|
||
<label>CTA</label>
|
||
<code>{draft.vipCta}</code>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
) : (
|
||
<div className="vip-free-banner">
|
||
当前为临时免费:前端权限临时放行,不写用户 VIP;切回收费后未开通用户仍须付费。
|
||
</div>
|
||
)}
|
||
</section>
|
||
) : null}
|
||
|
||
{tab === 'switches' ? (
|
||
<section className="vip-card">
|
||
<div className="vip-card-head">
|
||
<div>
|
||
<h2>入口与行为开关</h2>
|
||
<p>默认关闭项保持安全;游戏入口已冻结,请勿开启。</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="vip-row">
|
||
<div>
|
||
<strong>VIP 会员入口</strong>
|
||
<p className="vip-hint">关闭后会员页闸门拦截</p>
|
||
</div>
|
||
<Switch
|
||
checked={draft.vipEnabled}
|
||
disabled={busy}
|
||
label="VIP 会员入口"
|
||
onChange={(v) => void save({ vipEnabled: v }, v ? 'VIP 已开启' : 'VIP 已关闭')}
|
||
/>
|
||
</div>
|
||
|
||
<div className="vip-row">
|
||
<div>
|
||
<strong>加群 → 跳转 VIP</strong>
|
||
<p className="vip-hint">关闭=社群「加群」弹窗引导;开启=跳转会员页</p>
|
||
</div>
|
||
<Switch
|
||
checked={vipJumpOn}
|
||
disabled={busy}
|
||
label="加群跳转 VIP"
|
||
onChange={(v) =>
|
||
void save(
|
||
{ joinGroupAction: v ? 'vip' : 'popup' },
|
||
v ? '加群跳 VIP 已开启' : '加群跳 VIP 已关闭(弹窗)',
|
||
)
|
||
}
|
||
/>
|
||
</div>
|
||
|
||
<div className="vip-row">
|
||
<div>
|
||
<strong>Web 账号打通</strong>
|
||
<p className="vip-hint">
|
||
开启后:小程序显示「已有账号」弹窗(对齐 Web 登录),付费后引导绑邮箱以便回 Web
|
||
登录。默认关;只增量写当前 openid,不改既有订单与他人会员
|
||
</p>
|
||
</div>
|
||
<Switch
|
||
checked={!!draft.vipWebBridgeEnabled}
|
||
disabled={busy}
|
||
label="Web 账号打通"
|
||
onChange={(v) =>
|
||
void save(
|
||
{ vipWebBridgeEnabled: v },
|
||
v ? 'Web 账号打通已开启' : 'Web 账号打通已关闭',
|
||
)
|
||
}
|
||
/>
|
||
</div>
|
||
|
||
<div className="vip-row">
|
||
<div>
|
||
<strong>数字游民 · 游戏入口</strong>
|
||
<p className="vip-hint">已冻结隐藏,首页不展示</p>
|
||
</div>
|
||
<button type="button" className="vip-btn-ghost" disabled>
|
||
已冻结
|
||
</button>
|
||
</div>
|
||
|
||
<div className="vip-row">
|
||
<div>
|
||
<strong>审核模式 reviewMode</strong>
|
||
<p className="vip-hint">开启后隐藏限时特惠等付费敏感强调(默认关)</p>
|
||
</div>
|
||
<Switch
|
||
checked={content.reviewMode}
|
||
disabled={busy}
|
||
label="审核模式"
|
||
onChange={(v) =>
|
||
patchContent({ reviewMode: v }, v ? '审核模式已开' : '审核模式已关')
|
||
}
|
||
/>
|
||
</div>
|
||
</section>
|
||
) : null}
|
||
|
||
{tab === 'content' ? (
|
||
<section className="vip-card">
|
||
<div className="vip-card-head">
|
||
<div>
|
||
<h2>正式内容枢纽</h2>
|
||
<p>
|
||
落地页只是入口卡片;正文在内容库。电子书章节与视频课在「VIP 内容」编辑,社群 /
|
||
商城走既有后台。
|
||
</p>
|
||
</div>
|
||
</div>
|
||
<div className="vip-item-list">
|
||
{CONTENT_HUB.map((item) => (
|
||
<Link
|
||
key={item.to}
|
||
to={item.to}
|
||
className={`vip-item${'primary' in item && item.primary ? ' on' : ''}`}
|
||
style={{ textDecoration: 'none' }}
|
||
>
|
||
<div className="vip-item-ico">{item.ico}</div>
|
||
<div className="vip-item-body">
|
||
<strong>{item.title}</strong>
|
||
<span>{item.desc}</span>
|
||
</div>
|
||
<span className="vip-item-tag">打开 →</span>
|
||
</Link>
|
||
))}
|
||
</div>
|
||
</section>
|
||
) : null}
|
||
|
||
{tab === 'landing' ? (
|
||
<>
|
||
<section className="vip-card">
|
||
<div className="vip-card-head">
|
||
<div>
|
||
<h2>落地页 · platforms.weapp</h2>
|
||
<p>
|
||
区块与文案只写微信;未保存过时小程序用包内默认(与现网一致)。左侧编辑,右侧即时预览。
|
||
</p>
|
||
</div>
|
||
</div>
|
||
|
||
<h3 style={{ margin: '0 0 10px', fontSize: 14, color: 'var(--muted)' }}>区块显隐</h3>
|
||
<div className="vip-section-grid">
|
||
{SECTION_TOGGLES.map(([key, label]) => (
|
||
<div
|
||
key={key}
|
||
className={`vip-section-tile${content[key] ? ' on' : ''}`}
|
||
>
|
||
<span>{label}</span>
|
||
<Switch
|
||
checked={content[key]}
|
||
disabled={busy}
|
||
label={label}
|
||
onChange={(v) =>
|
||
patchContent({ [key]: v }, `${label}已${v ? '显示' : '隐藏'}`)
|
||
}
|
||
/>
|
||
</div>
|
||
))}
|
||
</div>
|
||
</section>
|
||
|
||
<section className="vip-card">
|
||
<div className="vip-layout">
|
||
<div>
|
||
<h3 style={{ margin: '0 0 14px', fontSize: 16 }}>主视觉文案</h3>
|
||
<div className="vip-fields">
|
||
<div className="vip-field">
|
||
<label>眉标 eyebrow</label>
|
||
<input
|
||
value={content.heroEyebrow}
|
||
disabled={busy}
|
||
onChange={(e) => updateContentLocal({ heroEyebrow: e.target.value })}
|
||
/>
|
||
</div>
|
||
<div className="vip-field">
|
||
<label>主标题(强调色)</label>
|
||
<input
|
||
value={content.heroTitleAccent}
|
||
disabled={busy}
|
||
onChange={(e) => updateContentLocal({ heroTitleAccent: e.target.value })}
|
||
/>
|
||
</div>
|
||
<div className="vip-field">
|
||
<label>主标题(其余)</label>
|
||
<input
|
||
value={content.heroTitleRest}
|
||
disabled={busy}
|
||
onChange={(e) => updateContentLocal({ heroTitleRest: e.target.value })}
|
||
/>
|
||
</div>
|
||
<div className="vip-field">
|
||
<label>副文案</label>
|
||
<textarea
|
||
value={content.heroLead}
|
||
disabled={busy}
|
||
onChange={(e) => updateContentLocal({ heroLead: e.target.value })}
|
||
/>
|
||
</div>
|
||
</div>
|
||
<div className="vip-actions">
|
||
<button
|
||
type="button"
|
||
className="vip-btn"
|
||
disabled={busy || !copyDirty}
|
||
onClick={() =>
|
||
patchContent(
|
||
{
|
||
heroEyebrow: content.heroEyebrow,
|
||
heroTitleAccent: content.heroTitleAccent,
|
||
heroTitleRest: content.heroTitleRest,
|
||
heroLead: content.heroLead,
|
||
},
|
||
'落地页文案已保存',
|
||
)
|
||
}
|
||
>
|
||
{busy ? '保存中…' : '保存文案'}
|
||
</button>
|
||
{copyDirty ? (
|
||
<span className="vip-dirty">有未保存修改</span>
|
||
) : (
|
||
<button
|
||
type="button"
|
||
className="vip-btn-ghost"
|
||
disabled={busy}
|
||
onClick={() =>
|
||
setDraft({
|
||
...draft,
|
||
vipContent: fromContent(cfg?.vipContent),
|
||
})
|
||
}
|
||
>
|
||
重置
|
||
</button>
|
||
)}
|
||
</div>
|
||
</div>
|
||
|
||
<aside className="vip-phone" aria-label="落地页预览">
|
||
<div className="vip-phone-bar" />
|
||
<div className="vip-phone-eyebrow">{content.heroEyebrow || 'nomadro'}</div>
|
||
<p className="vip-phone-title">
|
||
<b>{content.heroTitleAccent || '全模块解锁'}</b>
|
||
<br />
|
||
{content.heroTitleRest || '持续更新 · 抱团出海'}
|
||
</p>
|
||
<p className="vip-phone-lead">{content.heroLead}</p>
|
||
<div className="vip-phone-blocks">
|
||
{SECTION_TOGGLES.map(([key, label]) => (
|
||
<i key={key} className={content[key] ? '' : 'off'}>
|
||
{label}
|
||
</i>
|
||
))}
|
||
</div>
|
||
{content.showCta ? (
|
||
<>
|
||
<div className={`vip-phone-cta${isFree ? ' free' : ''}`}>
|
||
🔒 {draft.vipCta || '立即加入'}
|
||
</div>
|
||
<p className="vip-phone-hint">
|
||
{content.reviewMode ? '审核模式 · 已藏促销强调' : '微信小程序虚拟支付'}
|
||
</p>
|
||
</>
|
||
) : (
|
||
<p className="vip-phone-hint">底部 CTA 已隐藏</p>
|
||
)}
|
||
</aside>
|
||
</div>
|
||
</section>
|
||
|
||
<section className="vip-card">
|
||
<h3 style={{ margin: '0 0 12px', fontSize: 16 }}>模块入口</h3>
|
||
<div className="vip-item-list">
|
||
{content.topics.map((t) => {
|
||
const on = t.enabled !== false
|
||
return (
|
||
<div key={t.id} className={`vip-item${on ? ' on' : ' off'}`}>
|
||
<div className="vip-item-ico">{t.icon || '◆'}</div>
|
||
<div className="vip-item-body">
|
||
<strong>{t.title}</strong>
|
||
<span>{t.desc}</span>
|
||
</div>
|
||
{t.locked ? <span className="vip-item-tag">需 VIP</span> : null}
|
||
<Switch
|
||
checked={on}
|
||
disabled={busy}
|
||
label={t.title}
|
||
onChange={(v) => toggleTopic(t.id, v)}
|
||
/>
|
||
</div>
|
||
)
|
||
})}
|
||
</div>
|
||
|
||
<h3 style={{ margin: '22px 0 12px', fontSize: 16 }}>单课时资料(可选)</h3>
|
||
<p className="vip-meta" style={{ marginTop: 0 }}>
|
||
每个视频页默认不展示资料。仅当在 lessonMaterials 为该课时 key(如
|
||
0-0)单独配了 url 才显示。下方全局链接不会套到所有课时;落地页「网盘下载」仍走
|
||
netdisk 列表。
|
||
</p>
|
||
<div className="vip-fields" style={{ marginBottom: 8 }}>
|
||
<div className="vip-field">
|
||
<label>网盘链接(空=隐藏)</label>
|
||
<input
|
||
value={content.courseMaterialsUrl || ''}
|
||
disabled={busy}
|
||
placeholder="https://pan.baidu.com/s/..."
|
||
onChange={(e) =>
|
||
updateContentLocal({ courseMaterialsUrl: e.target.value })
|
||
}
|
||
onBlur={() =>
|
||
patchContent(
|
||
{
|
||
courseMaterialsUrl: String(
|
||
content.courseMaterialsUrl || '',
|
||
).trim(),
|
||
},
|
||
content.courseMaterialsUrl?.trim()
|
||
? '课程资料链接已保存'
|
||
: '已隐藏课程资料下载',
|
||
)
|
||
}
|
||
/>
|
||
</div>
|
||
<div className="vip-field">
|
||
<label>说明文案</label>
|
||
<input
|
||
value={content.courseMaterialsDesc || ''}
|
||
disabled={busy}
|
||
onChange={(e) =>
|
||
updateContentLocal({ courseMaterialsDesc: e.target.value })
|
||
}
|
||
onBlur={() =>
|
||
patchContent(
|
||
{
|
||
courseMaterialsDesc: String(
|
||
content.courseMaterialsDesc || '',
|
||
),
|
||
},
|
||
'资料说明已保存',
|
||
)
|
||
}
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<h3 style={{ margin: '22px 0 12px', fontSize: 16 }}>视频教程</h3>
|
||
<div className="vip-item-list">
|
||
{content.videos.map((t) => {
|
||
const on = t.enabled !== false
|
||
return (
|
||
<div key={t.id} className={`vip-item${on ? ' on' : ' off'}`}>
|
||
<div className="vip-item-ico">{t.icon || '▶'}</div>
|
||
<div className="vip-item-body">
|
||
<strong>{t.title}</strong>
|
||
<span>{t.desc}</span>
|
||
</div>
|
||
<Switch
|
||
checked={on}
|
||
disabled={busy}
|
||
label={t.title}
|
||
onChange={(v) => toggleVideo(t.id, v)}
|
||
/>
|
||
</div>
|
||
)
|
||
})}
|
||
</div>
|
||
|
||
<h3 style={{ margin: '22px 0 12px', fontSize: 16 }}>电子书</h3>
|
||
<div className="vip-item-list">
|
||
{content.ebooks.map((t) => {
|
||
const on = t.enabled !== false
|
||
return (
|
||
<div key={t.id} className={`vip-item${on ? ' on' : ' off'}`}>
|
||
<div className="vip-item-ico">📖</div>
|
||
<div className="vip-item-body">
|
||
<strong>《{t.title}》</strong>
|
||
<span>
|
||
{t.desc}
|
||
{t.free ? ' · 免费' : ''}
|
||
</span>
|
||
</div>
|
||
{t.free ? <span className="vip-item-tag">免费</span> : null}
|
||
<Switch
|
||
checked={on}
|
||
disabled={busy}
|
||
label={t.title}
|
||
onChange={(v) => toggleEbook(t.id, v)}
|
||
/>
|
||
</div>
|
||
)
|
||
})}
|
||
</div>
|
||
|
||
{cfg?.updatedAt ? (
|
||
<p className="vip-meta">
|
||
最近更新 · v{cfg.version ?? '—'} · {cfg.updatedAt}
|
||
</p>
|
||
) : null}
|
||
</section>
|
||
</>
|
||
) : null}
|
||
</div>
|
||
)
|
||
}
|