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>
517 lines
18 KiB
TypeScript
517 lines
18 KiB
TypeScript
/**
|
||
* Taro VIP landing — mirrors modules/vip LandingPage structure.
|
||
*/
|
||
import { useEffect, useMemo, useState } from 'react'
|
||
import { Text, Button, Image } from '@tarojs/components'
|
||
import Taro from '@tarojs/taro'
|
||
import { MiniModuleGate } from '@/components/MiniModuleGate'
|
||
import { H5Box, H5Txt } from '@/components/H5Box'
|
||
import { payVirtualProduct } from '@/utils/virtualPay'
|
||
import { getCachedRemoteConfig, loadRemoteConfig } from '@/services/remoteConfig'
|
||
import type { NomadroRemoteConfig } from '@/data/remoteConfig.defaults'
|
||
import { useNomadroTheme } from '@/utils/h5Theme'
|
||
import { goHome } from '@/utils/nav'
|
||
import { getSafeAreaMetrics } from '@/utils/safeArea'
|
||
import { usePageTrack } from '@/hooks/usePageTrack'
|
||
import './index.scss'
|
||
|
||
const isH5 = process.env.TARO_ENV === 'h5'
|
||
|
||
const LOGO_SVG = `<svg class="vip-logoMark" viewBox="0 0 40 40" fill="none" aria-hidden="true">
|
||
<circle cx="20" cy="20" r="18" stroke="#f59e0b" stroke-width="2.5"/>
|
||
<path d="M12 22c4-8 12-8 16 0" stroke="#f59e0b" stroke-width="2" stroke-linecap="round"/>
|
||
<circle cx="28" cy="14" r="3" fill="#f59e0b"/>
|
||
</svg>`
|
||
|
||
/** Offline seed from modules/vip/app/data/vip.mock.ts */
|
||
const ASSET_STATS = {
|
||
topics: 4,
|
||
ebooks: 2,
|
||
videos: '40+',
|
||
updateFrequency: '每周',
|
||
} as const
|
||
|
||
const STAT_ITEMS = [
|
||
{ key: 'topics', label: '模块' },
|
||
{ key: 'ebooks', label: '电子书' },
|
||
{ key: 'videos', label: '视频' },
|
||
{ key: 'updateFrequency', label: '更新' },
|
||
] as const
|
||
|
||
/** Offline seeds from modules/vip/app/data/vip.mock.ts */
|
||
const TOPICS_DISPLAY = [
|
||
{ id: 'ebook', icon: '📖', title: '电子书', desc: '知识沉淀·随时阅读', href: '#ebooks' },
|
||
{ id: 'cloudphone', icon: '🎬', title: '视频教程', desc: '实战演练·即学即用', href: '#video-courses' },
|
||
{
|
||
id: 'community',
|
||
icon: '👥',
|
||
title: '私密社群',
|
||
desc: '抱团出海',
|
||
href: 'https://qun.hackrobot.cn',
|
||
locked: true,
|
||
},
|
||
{
|
||
id: 'tools',
|
||
icon: '🛒',
|
||
title: '设备自助下单',
|
||
desc: '开箱即用',
|
||
href: 'https://store.hackrobot.cn/',
|
||
locked: true,
|
||
},
|
||
] as const
|
||
|
||
const VIDEO_COURSES_DISPLAY = [
|
||
// 过审展示文案;原文: 云手机 / 无人直播…
|
||
{
|
||
id: 'cloudphone',
|
||
icon: '☁️',
|
||
title: '云端安卓环境',
|
||
desc: '低成本自建云端安卓环境,TikTok/YouTube 直播效率实战指南',
|
||
href: '/vip/cloudphone',
|
||
},
|
||
{
|
||
id: 'livestream',
|
||
icon: '📺',
|
||
title: '直播效率',
|
||
desc: 'TikTok/YouTube 直播效率,24 小时自动化',
|
||
href: '/vip/topic/livestream',
|
||
},
|
||
{
|
||
id: 'indie',
|
||
icon: '🛠️',
|
||
title: '独立开发',
|
||
desc: '从想法到产品,独立开发者全流程指南',
|
||
href: '/vip/topic/indie',
|
||
},
|
||
{
|
||
id: 'aiagent',
|
||
icon: '🤖',
|
||
title: 'AI Agent',
|
||
desc: 'AIGC 与智能体,Vibe Coding 跨界创造',
|
||
href: '/vip/topic/aiagent',
|
||
},
|
||
] as const
|
||
|
||
const EBOOKS_DISPLAY = [
|
||
{
|
||
id: '1',
|
||
title: '数字游民',
|
||
desc: '地理优势运营与自动化杠杆',
|
||
href: '/vip/ebook',
|
||
free: true,
|
||
},
|
||
{
|
||
id: '2',
|
||
title: '云端安卓环境',
|
||
desc: '低成本工作室搭建指南',
|
||
href: '/vip/ebook/cloudphone',
|
||
locked: true,
|
||
},
|
||
] as const
|
||
|
||
const COMPARE_ITEMS = [
|
||
{ feature: '电子书', single: '按需开通', member: '全解锁' },
|
||
{ feature: '视频教程', single: '按需开通', member: '全解锁' },
|
||
{ feature: '私密社群', single: '—', member: '✓' },
|
||
{ feature: '即时问答', single: '—', member: '✓' },
|
||
{ feature: '持续更新', single: '—', member: '✓' },
|
||
] as const
|
||
|
||
const FAQ_ITEMS = [
|
||
{
|
||
q: '会员包含哪些内容?',
|
||
a: '电子书、视频教程、私密社群、即时问答、设备自助下单等全部解锁,并享受持续更新。',
|
||
},
|
||
{
|
||
q: '如何加入?',
|
||
a: '点击「立即加入」完成支付即可,支付成功后自动开通,无需人工审核。',
|
||
},
|
||
{
|
||
q: '为什么越早加入越划算?',
|
||
a: '会员采用阶梯定价:越早锁定席位,单价越低;在恢复原价前完成支付,可长期享受全部内容与后续更新,整体投入更省、权益不打折。',
|
||
},
|
||
] as const
|
||
|
||
const CTA_CHIPS = ['阶梯定价', '数字交付', '持续更新', '不支持退款'] as const
|
||
|
||
function formatRestoreDateShort(): string {
|
||
const d = new Date()
|
||
d.setDate(d.getDate() + 2)
|
||
return `${d.getMonth() + 1}月${d.getDate()}日`
|
||
}
|
||
|
||
export default function VipPage() {
|
||
return (
|
||
<MiniModuleGate moduleKey="vip">
|
||
<VipLanding />
|
||
</MiniModuleGate>
|
||
)
|
||
}
|
||
|
||
function VipLanding() {
|
||
usePageTrack('pages/vip/index', '会员中心')
|
||
const theme = useNomadroTheme()
|
||
const [busy, setBusy] = useState(false)
|
||
const [cfg, setCfg] = useState<NomadroRemoteConfig>(getCachedRemoteConfig())
|
||
const [offline, setOffline] = useState(false)
|
||
const [faqOpen, setFaqOpen] = useState<number | null>(0)
|
||
const [restoreDate] = useState(() => formatRestoreDateShort())
|
||
|
||
useEffect(() => {
|
||
loadRemoteConfig().then((r) => {
|
||
setCfg(r.config)
|
||
setOffline(r.fromOffline)
|
||
})
|
||
}, [])
|
||
|
||
// H5:锁定 16px 根字号,让 rem 与 Next 一致
|
||
useEffect(() => {
|
||
if (!isH5) return
|
||
const html = document.documentElement
|
||
const prev = html.style.fontSize
|
||
const lock = () => {
|
||
html.style.fontSize = '16px'
|
||
}
|
||
lock()
|
||
window.addEventListener('resize', lock)
|
||
return () => {
|
||
window.removeEventListener('resize', lock)
|
||
html.style.fontSize = prev
|
||
}
|
||
}, [])
|
||
|
||
/** 抖音无支付:全免费,不展示锁/不拉支付 */
|
||
const payOk = cfg.flags.payEnabled !== false
|
||
const freeMode = !payOk
|
||
const priceFen = freeMode ? 0 : cfg.copy.vipPriceFen || 8800
|
||
const productId = cfg.copy.vipProductId || 'vip_membership'
|
||
const cta = freeMode ? '本端免费开放' : cfg.copy.vipCta || '立即加入'
|
||
const brand = cfg.copy.homeBrand || 'nomadro'
|
||
const safe = useMemo(() => getSafeAreaMetrics(), [])
|
||
const safeStyle = useMemo(
|
||
() => ({
|
||
['--safe-status-bar' as string]: `${safe.statusBarHeight}px`,
|
||
['--safe-nav-bar' as string]: `${safe.navBarHeight}px`,
|
||
['--safe-menu-pad' as string]: `${safe.menuRightPad}px`,
|
||
['--safe-header' as string]: `${safe.headerHeight}px`,
|
||
}),
|
||
[safe],
|
||
)
|
||
|
||
function onLogin() {
|
||
Taro.showToast({ title: '请在门户登录', icon: 'none' })
|
||
}
|
||
|
||
function onLocked() {
|
||
if (freeMode) {
|
||
void Taro.navigateTo({ url: '/packageBook/pages/book/index' })
|
||
return
|
||
}
|
||
Taro.showToast({ title: '请开通会员', icon: 'none' })
|
||
}
|
||
|
||
function openHref(href: string) {
|
||
if (!href) return
|
||
if (href.startsWith('#')) {
|
||
if (isH5 && typeof document !== 'undefined') {
|
||
document.getElementById(href.slice(1))?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||
}
|
||
return
|
||
}
|
||
const url = href.startsWith('http') ? href : `https://nomadro.cn${href}`
|
||
if (isH5 && typeof window !== 'undefined') {
|
||
window.open(url, '_blank', 'noopener,noreferrer')
|
||
} else {
|
||
Taro.setClipboardData({ data: url }).then(() => {
|
||
Taro.showToast({ title: '链接已复制', icon: 'none' })
|
||
})
|
||
}
|
||
}
|
||
|
||
async function onJoin() {
|
||
if (busy) return
|
||
|
||
if (freeMode) {
|
||
void Taro.showToast({ title: '抖音端免费,直接阅读即可', icon: 'none' })
|
||
void Taro.navigateTo({ url: '/packageBook/pages/book/index' })
|
||
return
|
||
}
|
||
|
||
if (isH5) {
|
||
const portal = 'https://nomadro.cn/vip'
|
||
const { confirm } = await Taro.showModal({
|
||
title: '开通 VIP',
|
||
content: `将打开门户 ${portal} 完成支付`,
|
||
confirmText: '去支付',
|
||
cancelText: '取消',
|
||
})
|
||
if (confirm && typeof window !== 'undefined') {
|
||
window.open(portal, '_blank', 'noopener,noreferrer')
|
||
}
|
||
return
|
||
}
|
||
|
||
setBusy(true)
|
||
try {
|
||
const orderId = await payVirtualProduct(productId, priceFen)
|
||
Taro.showToast({ title: `支付成功 ${orderId.slice(-6)}`, icon: 'success' })
|
||
} catch (e) {
|
||
const msg = e instanceof Error ? e.message : String(e)
|
||
if (!/cancel|取消|-2/i.test(msg)) {
|
||
Taro.showModal({ title: '支付未完成', content: msg, showCancel: false })
|
||
}
|
||
} finally {
|
||
setBusy(false)
|
||
}
|
||
}
|
||
|
||
return (
|
||
<H5Box className="vip-root" data-theme={theme} style={safeStyle}>
|
||
<H5Box className="vip-header">
|
||
<H5Box className="vip-logo" onClick={goHome} aria-label="返回首页">
|
||
{isH5 ? (
|
||
<H5Box html={LOGO_SVG} />
|
||
) : (
|
||
<Image className="hub-logo-img" src="/icons/nomadro.webp" mode="aspectFit" />
|
||
)}
|
||
<H5Txt className="vip-logoBrand">{brand}</H5Txt>
|
||
<H5Txt className="vip-logoSep">·</H5Txt>
|
||
<H5Txt className="vip-logoVip">VIP</H5Txt>
|
||
</H5Box>
|
||
</H5Box>
|
||
|
||
<H5Box className="vip-landingScene">
|
||
<H5Box className="vip-landingSceneBg" aria-hidden>
|
||
<H5Box className="vip-landingOrb" />
|
||
<H5Box className="vip-landingOrb" />
|
||
<H5Box className="vip-landingOrb" />
|
||
<H5Box className="vip-landingMesh" />
|
||
<H5Box className="vip-landingNoise" />
|
||
</H5Box>
|
||
|
||
<H5Box className="vip-landingSceneInner">
|
||
{/* LandingHero */}
|
||
<H5Box className="vip-section vip-heroSection vip-heroSection3d">
|
||
<H5Txt className="vip-heroEyebrow">nomadro</H5Txt>
|
||
<H5Box className="vip-heroTitle">
|
||
<H5Txt className="vip-heroTitleAccent">全模块解锁</H5Txt>
|
||
<H5Txt className="vip-heroTitleRest">持续更新 · 抱团出海</H5Txt>
|
||
</H5Box>
|
||
<H5Txt className="vip-heroLead">
|
||
一次付费,解锁电子书、视频教程、私密社群、即时问答,每周更新
|
||
</H5Txt>
|
||
</H5Box>
|
||
|
||
{/* AssetStats */}
|
||
<H5Box className="vip-section vip-statsSection">
|
||
<H5Box className="vip-statsGrid">
|
||
{STAT_ITEMS.map(({ key, label }) => (
|
||
<H5Box key={key} className="vip-card vip-landingStatCard">
|
||
<H5Txt className="vip-bigNumber">{ASSET_STATS[key]}</H5Txt>
|
||
<H5Txt className="vip-bigNumberLabel">{label}</H5Txt>
|
||
</H5Box>
|
||
))}
|
||
</H5Box>
|
||
</H5Box>
|
||
|
||
{/* TopicEbookShowcase */}
|
||
<H5Box className="vip-section vip-topicsSection" id="topics">
|
||
<H5Txt className="vip-sectionTitle">模块</H5Txt>
|
||
<H5Box className="vip-topicGrid" style={{ marginBottom: '1.5rem' }}>
|
||
{TOPICS_DISPLAY.map((t) => {
|
||
const locked = !freeMode && 'locked' in t && t.locked
|
||
return (
|
||
<H5Box
|
||
key={t.id}
|
||
className="vip-topicCard"
|
||
onClick={() => (locked ? onLocked() : openHref(t.href))}
|
||
>
|
||
{locked ? <H5Txt className="vip-topicLock">🔒</H5Txt> : null}
|
||
<H5Txt className="vip-topicIcon">{t.icon}</H5Txt>
|
||
<H5Txt className="vip-topicTitle">{t.title}</H5Txt>
|
||
<H5Txt className="vip-topicDesc">{t.desc}</H5Txt>
|
||
</H5Box>
|
||
)
|
||
})}
|
||
</H5Box>
|
||
|
||
<H5Txt id="video-courses" className="vip-sectionTitle">
|
||
视频教程
|
||
</H5Txt>
|
||
<H5Box className="vip-topicGrid" style={{ marginBottom: '1.5rem' }}>
|
||
{VIDEO_COURSES_DISPLAY.map((v) => (
|
||
<H5Box
|
||
key={v.id}
|
||
className="vip-topicCard"
|
||
onClick={() => openHref(v.href)}
|
||
>
|
||
<H5Txt className="vip-topicIcon">{v.icon}</H5Txt>
|
||
<H5Txt className="vip-topicTitle">{v.title}</H5Txt>
|
||
<H5Txt className="vip-topicDesc">{v.desc}</H5Txt>
|
||
</H5Box>
|
||
))}
|
||
</H5Box>
|
||
|
||
<H5Txt id="ebooks" className="vip-sectionTitle">
|
||
电子书
|
||
</H5Txt>
|
||
<H5Box className="vip-ebookGrid">
|
||
{EBOOKS_DISPLAY.map((e) => {
|
||
const isFree = freeMode || ('free' in e && e.free)
|
||
const locked = !freeMode && 'locked' in e && e.locked
|
||
return (
|
||
<H5Box
|
||
key={e.id}
|
||
className="vip-card vip-ebookCard"
|
||
onClick={() =>
|
||
locked
|
||
? onLocked()
|
||
: freeMode
|
||
? void Taro.navigateTo({ url: '/packageBook/pages/book/index' })
|
||
: openHref(e.href)
|
||
}
|
||
>
|
||
<H5Txt className="vip-ebookEmoji">📖</H5Txt>
|
||
<H5Box className="vip-ebookTitleRow">
|
||
<H5Txt className="vip-ebookTitle">《{e.title}》</H5Txt>
|
||
{isFree ? <H5Txt className="vip-freeBadge">免费</H5Txt> : null}
|
||
{locked ? <H5Txt className="vip-ebookLock">🔒</H5Txt> : null}
|
||
</H5Box>
|
||
<H5Txt className="vip-ebookDesc">{e.desc}</H5Txt>
|
||
<H5Txt className="vip-ebookCta">
|
||
{locked ? '开通VIP解锁 →' : '阅读 →'}
|
||
</H5Txt>
|
||
</H5Box>
|
||
)
|
||
})}
|
||
</H5Box>
|
||
</H5Box>
|
||
|
||
{/* CompareSection */}
|
||
<H5Box className="vip-section">
|
||
<H5Txt className="vip-sectionTitle">单品 vs 会员</H5Txt>
|
||
<H5Txt className="vip-sectionDesc">一次付费,全部解锁</H5Txt>
|
||
<H5Box className="vip-compareWrap">
|
||
<H5Box className="vip-compareTable">
|
||
<H5Box className="vip-compareRow vip-compareRow--head">
|
||
<H5Txt className="vip-compareCell vip-compareCell--feature">权益</H5Txt>
|
||
<H5Txt className="vip-compareCell vip-compareCell--single">单品</H5Txt>
|
||
<H5Txt className="vip-compareCell vip-compareCell--member">会员</H5Txt>
|
||
</H5Box>
|
||
{COMPARE_ITEMS.map((row, i) => (
|
||
<H5Box
|
||
key={row.feature}
|
||
className={`vip-compareRow vip-compareRow--body${
|
||
i % 2 === 1 ? ' vip-compareRow--alt' : ''
|
||
}`}
|
||
>
|
||
<H5Txt className="vip-compareCell vip-compareCell--bodyFeature">
|
||
{row.feature}
|
||
</H5Txt>
|
||
<H5Txt className="vip-compareCell vip-compareCell--bodySingle">
|
||
{row.single}
|
||
</H5Txt>
|
||
<H5Txt className="vip-compareCell vip-compareCell--bodyMember">
|
||
{row.member}
|
||
</H5Txt>
|
||
</H5Box>
|
||
))}
|
||
</H5Box>
|
||
</H5Box>
|
||
</H5Box>
|
||
|
||
{/* FAQSection */}
|
||
<H5Box className="vip-section vip-faqSection">
|
||
<H5Box className="vip-faqInner">
|
||
<H5Box className="vip-faqEyebrow">
|
||
<H5Box className="vip-faqEyebrowDot" />
|
||
<H5Txt>FAQ</H5Txt>
|
||
</H5Box>
|
||
<H5Txt className="vip-faqHeadline">常见问题</H5Txt>
|
||
<H5Txt className="vip-faqSub">
|
||
购买前可快速了解会员权益与流程;点击问题展开详情。
|
||
</H5Txt>
|
||
<H5Box className="vip-faqList">
|
||
{FAQ_ITEMS.map((item, i) => {
|
||
const open = faqOpen === i
|
||
return (
|
||
<H5Box
|
||
key={item.q}
|
||
className={`vip-faqItem${open ? ' vip-faqItemOpen' : ''}`}
|
||
>
|
||
<Button
|
||
className="vip-faqTrigger"
|
||
onClick={() => setFaqOpen(open ? null : i)}
|
||
>
|
||
<Text className="vip-faqIndex">{i + 1}</Text>
|
||
<Text className="vip-faqQuestionText">{item.q}</Text>
|
||
<Text className="vip-faqChevron">▾</Text>
|
||
</Button>
|
||
<H5Box className={`vip-faqPanel${open ? ' vip-faqPanelOpen' : ''}`}>
|
||
<H5Txt className="vip-faqAnswer">{item.a}</H5Txt>
|
||
</H5Box>
|
||
</H5Box>
|
||
)
|
||
})}
|
||
</H5Box>
|
||
</H5Box>
|
||
</H5Box>
|
||
|
||
{/* LandingCTA */}
|
||
<H5Box className="vip-section vip-ctaSection">
|
||
<H5Box className="vip-ctaInner">
|
||
<H5Box className="vip-ctaGlow" aria-hidden />
|
||
<H5Box className="vip-ctaCard">
|
||
<H5Box className="vip-ctaPromoLine">
|
||
<H5Box className="vip-ctaPromoClickable">
|
||
<H5Box className="vip-ctaBadgePulse" />
|
||
<H5Txt>限时特惠</H5Txt>
|
||
</H5Box>
|
||
<H5Txt className="vip-ctaPromoDivider">·</H5Txt>
|
||
<H5Box className="vip-ctaPromoMain">
|
||
<H5Txt className="vip-ctaHighlight">{restoreDate}</H5Txt>
|
||
<H5Txt className="vip-ctaPromoSuffix">恢复原价</H5Txt>
|
||
</H5Box>
|
||
</H5Box>
|
||
|
||
<H5Box className="vip-ctaChips">
|
||
{CTA_CHIPS.map((c) => (
|
||
<H5Txt key={c} className="vip-ctaChip">
|
||
{c}
|
||
</H5Txt>
|
||
))}
|
||
</H5Box>
|
||
|
||
{offline ? (
|
||
<H5Txt className="vip-ctaOffline">📦 价格/文案来自离线配置</H5Txt>
|
||
) : null}
|
||
|
||
<H5Box className="vip-ctaActions">
|
||
<Button
|
||
className="vip-btnPrimary vip-btnLarge vip-ctaBtnPrimary"
|
||
loading={busy}
|
||
onClick={onJoin}
|
||
>
|
||
{busy ? '拉起支付…' : freeMode ? `✨ ${cta}` : `🔒 ${cta}`}
|
||
</Button>
|
||
{freeMode ? null : (
|
||
<Button className="vip-ctaBtnSecondary" onClick={onLogin}>
|
||
已有账号
|
||
</Button>
|
||
)}
|
||
</H5Box>
|
||
|
||
{isH5 ? (
|
||
<H5Txt className="vip-ctaHint">浏览器请走门户 /vip 支付</H5Txt>
|
||
) : (
|
||
<H5Txt className="vip-ctaHint">微信小程序虚拟支付</H5Txt>
|
||
)}
|
||
</H5Box>
|
||
</H5Box>
|
||
</H5Box>
|
||
</H5Box>
|
||
</H5Box>
|
||
</H5Box>
|
||
)
|
||
}
|