/**
* 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 = ``
/** 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 (
)
}
function VipLanding() {
usePageTrack('pages/vip/index', '会员中心')
const theme = useNomadroTheme()
const [busy, setBusy] = useState(false)
const [cfg, setCfg] = useState(getCachedRemoteConfig())
const [offline, setOffline] = useState(false)
const [faqOpen, setFaqOpen] = useState(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 (
{isH5 ? (
) : (
)}
{brand}
·
VIP
{/* LandingHero */}
nomadro
全模块解锁
持续更新 · 抱团出海
一次付费,解锁电子书、视频教程、私密社群、即时问答,每周更新
{/* AssetStats */}
{STAT_ITEMS.map(({ key, label }) => (
{ASSET_STATS[key]}
{label}
))}
{/* TopicEbookShowcase */}
模块
{TOPICS_DISPLAY.map((t) => {
const locked = !freeMode && 'locked' in t && t.locked
return (
(locked ? onLocked() : openHref(t.href))}
>
{locked ? 🔒 : null}
{t.icon}
{t.title}
{t.desc}
)
})}
视频教程
{VIDEO_COURSES_DISPLAY.map((v) => (
openHref(v.href)}
>
{v.icon}
{v.title}
{v.desc}
))}
电子书
{EBOOKS_DISPLAY.map((e) => {
const isFree = freeMode || ('free' in e && e.free)
const locked = !freeMode && 'locked' in e && e.locked
return (
locked
? onLocked()
: freeMode
? void Taro.navigateTo({ url: '/packageBook/pages/book/index' })
: openHref(e.href)
}
>
📖
《{e.title}》
{isFree ? 免费 : null}
{locked ? 🔒 : null}
{e.desc}
{locked ? '开通VIP解锁 →' : '阅读 →'}
)
})}
{/* CompareSection */}
单品 vs 会员
一次付费,全部解锁
权益
单品
会员
{COMPARE_ITEMS.map((row, i) => (
{row.feature}
{row.single}
{row.member}
))}
{/* FAQSection */}
FAQ
常见问题
购买前可快速了解会员权益与流程;点击问题展开详情。
{FAQ_ITEMS.map((item, i) => {
const open = faqOpen === i
return (
{item.a}
)
})}
{/* LandingCTA */}
限时特惠
·
{restoreDate}
恢复原价
{CTA_CHIPS.map((c) => (
{c}
))}
{offline ? (
📦 价格/文案来自离线配置
) : null}
{freeMode ? null : (
)}
{isH5 ? (
浏览器请走门户 /vip 支付
) : (
微信小程序虚拟支付
)}
)
}