Port nomadvip VIP into native WeChat pages and document the flow.
Add vip-course/lesson/ebook with source markdown seeds, VIP order API + admin offers, ban web-view for content, and update READMEs for weapp rebuild/extract scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b2851c210c
commit
98a54730ff
25
.cursor/rules/no-webview-content.mdc
Normal file
25
.cursor/rules/no-webview-content.mdc
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
description: 全端小程序禁止 web-view(微信/抖音/小红书/H5 SoT)
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# 全端小程序禁止 web-view
|
||||
|
||||
适用范围:`apps/miniprogram/{h5,weapp,tt,xhs}` 及一切 Taro/小程序业务页。
|
||||
|
||||
## 强制
|
||||
|
||||
- **禁止**使用 `WebView`、`web-view`、`pages/*-web`、内嵌 H5 壳承载任何业务内容。
|
||||
- **禁止**用 web-view「偷懒」打开:VIP、电子书、视频课、社群、导航详情、目的地、活动、会员落地。
|
||||
- 内容必须是**原生页面**:Taro 组件 + 包内/离线数据(markdown、catalog、Video、现有 reader)。
|
||||
- 真外链(社群二维码页、商城):只允许复制链接 / 提示外部打开;**不得**当内容页塞进 web-view。
|
||||
|
||||
## 反模式
|
||||
|
||||
- `import { WebView } from '@tarojs/components'`
|
||||
- `goPage('/pages/vip-web/...')` 或任何 `*-web` 内容页
|
||||
- 导航栏标题出现 `%E4%...` 编码串却打开空白黑页(典型 web-view 失败)
|
||||
|
||||
## 发现即改
|
||||
|
||||
搜到业务页 WebView → 立刻改成原生页再继续其它需求;不得留下「先 web-view 以后再说」。
|
||||
@ -16,4 +16,6 @@ Follow `.cursor/rules/*.mdc`.
|
||||
|
||||
Remote config: `/api/config` + offline defaults. Do not reintroduce deleted vertical trees (`payjsapi` / `community-api` / `ebook` / `navmini` / `nomadweb` / `nomadvip` / `wemini`).
|
||||
|
||||
**全端小程序禁止 web-view**(微信 / 抖音 / 小红书 / H5 SoT):业务内容必须原生页;见 `.cursor/rules/no-webview-content.mdc`。
|
||||
|
||||
H5 游戏(Nomad Day 3D)冷冻:勿改 `apps/miniprogram/h5/src/modules/game` / `pages/game`,除非用户明确要求。
|
||||
|
||||
16
README.md
16
README.md
@ -19,12 +19,26 @@ scripts/ 本地开发 / 清理(dev-api · clean-artifacts)
|
||||
| 导航 | `/nav` | `src/modules/nav` |
|
||||
| 小册 | `/book` | `src/modules/ebook` + `src/modules/ebook-content` |
|
||||
| 社群 | `/community` | `src/modules/community` |
|
||||
| VIP | `/vip` | `src/modules/vip` |
|
||||
| VIP | `/vip` | `src/modules/vip`(微信小程序原生页,见下) |
|
||||
| 后台 | admin.nomadro.cn | `apps/admin` |
|
||||
| API | api.nomadro.cn | `apps/api` |
|
||||
|
||||
后台平台:`/wechat/*` 微信 · `/douyin/*` 抖音。抖音加群弹窗(公众号 / 抖音群)集成在 **`/douyin/modules`**(非独立页)。
|
||||
|
||||
### 微信小程序 VIP(原生,禁止 web-view)
|
||||
|
||||
对照 `src/modules/vip` / nomadvip H5,微信端业务内容必须原生页(见 `.cursor/rules/no-webview-content.mdc`):
|
||||
|
||||
| 能力 | 小程序页 | 说明 |
|
||||
|------|----------|------|
|
||||
| VIP 落地 | `pages/vip/index` | 模块锚点真滚动、虚拟支付 / 免费方案 |
|
||||
| 专题课 | `pages/vip-course/index?id=` | `cloudphone` / `livestream` / `indie` / `aiagent` |
|
||||
| 课时 | `pages/vip-lesson/index` | 原生 Video + 配套 markdown |
|
||||
| 电子书 | `pages/vip-ebook/index?id=` | `nomad`(免费)/ `cloudphone`(VIP),目录抽屉 |
|
||||
|
||||
内容种子:`h5/src/data/vipEbooks.ts` · `vipLessonContent.ts`(可由 `h5/scripts/extract-vip-*.py` 从 `src/modules/vip/app/data` 重生)。
|
||||
后台 VIP 方案:`apps/admin` → VIP;下单 `POST /api/ebook/pay/vip-order`。
|
||||
|
||||
## 本地
|
||||
|
||||
根目录一次安装(pnpm workspace):
|
||||
|
||||
@ -9,6 +9,7 @@ import Orders from './pages/Orders'
|
||||
import Users from './pages/Users'
|
||||
import Events from './pages/Events'
|
||||
import Checklist from './pages/Checklist'
|
||||
import Vip from './pages/Vip'
|
||||
import Layout from './components/Layout'
|
||||
import DouyinLayout from './pages/douyin/DouyinLayout'
|
||||
import DouyinOverview from './pages/douyin/DouyinOverview'
|
||||
@ -62,6 +63,7 @@ export default function App() {
|
||||
>
|
||||
<Route index element={<Dashboard />} />
|
||||
<Route path="books/:id" element={<BookEdit />} />
|
||||
<Route path="vip" element={<Vip />} />
|
||||
<Route path="orders" element={<Orders />} />
|
||||
<Route path="users" element={<Users />} />
|
||||
<Route path="events" element={<Events />} />
|
||||
@ -89,6 +91,7 @@ export default function App() {
|
||||
<Route path="/users" element={<WechatRedirect to="/wechat/users" />} />
|
||||
<Route path="/events" element={<WechatRedirect to="/wechat/events" />} />
|
||||
<Route path="/checklist" element={<WechatRedirect to="/wechat/checklist" />} />
|
||||
<Route path="/vip" element={<WechatRedirect to="/wechat/vip" />} />
|
||||
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
</Routes>
|
||||
|
||||
@ -19,6 +19,7 @@ export default function Layout() {
|
||||
概览
|
||||
</NavLink>
|
||||
<NavLink to="/wechat/books/default">书籍与试读%</NavLink>
|
||||
<NavLink to="/wechat/vip">VIP</NavLink>
|
||||
<NavLink to="/wechat/users">读者</NavLink>
|
||||
<NavLink to="/wechat/orders">订单</NavLink>
|
||||
<NavLink to="/wechat/events">埋点</NavLink>
|
||||
|
||||
@ -57,6 +57,7 @@ export default function Dashboard() {
|
||||
<h2>快捷操作</h2>
|
||||
<div className="quick">
|
||||
<Link to="/wechat/books/default">📚 书籍 / 解锁阈值</Link>
|
||||
<Link to="/wechat/vip">👑 VIP / 加群行为</Link>
|
||||
<Link to="/wechat/users">👥 读者运营</Link>
|
||||
<Link to="/wechat/orders">🧾 订单列表</Link>
|
||||
<Link to="/wechat/events">📊 埋点事件</Link>
|
||||
|
||||
321
apps/admin/src/pages/Vip.tsx
Normal file
321
apps/admin/src/pages/Vip.tsx
Normal file
@ -0,0 +1,321 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { api } from '../api'
|
||||
import './BookEdit.css'
|
||||
|
||||
type JoinAction = 'popup' | 'vip'
|
||||
|
||||
type VipCfg = {
|
||||
ok?: boolean
|
||||
vipEnabled: boolean
|
||||
gameEnabled: boolean
|
||||
joinGroupAction: JoinAction
|
||||
vipPriceFen: number
|
||||
vipProductId: string
|
||||
vipCta: string
|
||||
vipOfferKey?: string
|
||||
is_free?: boolean
|
||||
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 empty: VipCfg = {
|
||||
vipEnabled: false,
|
||||
gameEnabled: false,
|
||||
joinGroupAction: 'popup',
|
||||
vipPriceFen: 29800,
|
||||
vipProductId: 'tiktok',
|
||||
vipCta: '立即加入 · ¥298',
|
||||
vipOfferKey: 'tiktok',
|
||||
is_free: false,
|
||||
}
|
||||
|
||||
function fromApi(data: VipCfg): VipCfg {
|
||||
return {
|
||||
vipEnabled: !!data.vipEnabled,
|
||||
gameEnabled: !!data.gameEnabled,
|
||||
joinGroupAction: data.joinGroupAction === 'vip' ? 'vip' : 'popup',
|
||||
vipPriceFen: Number(data.vipPriceFen) || 0,
|
||||
vipProductId: String(data.vipProductId || ''),
|
||||
vipCta: String(data.vipCta || '立即加入'),
|
||||
vipOfferKey: String(data.vipOfferKey || ''),
|
||||
is_free: !!data.is_free,
|
||||
updatedAt: data.updatedAt,
|
||||
version: data.version,
|
||||
}
|
||||
}
|
||||
|
||||
/** 微信小程序 · VIP / 加群行为 / 3D 入口 + 动态付费方案(对齐小册「阅读与付费控制」) */
|
||||
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 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 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 }
|
||||
setDraft(next)
|
||||
try {
|
||||
const data = await api<VipCfg>('/api/admin/vip', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
vipEnabled: next.vipEnabled,
|
||||
gameEnabled: next.gameEnabled,
|
||||
joinGroupAction: next.joinGroupAction,
|
||||
vipPriceFen: next.vipPriceFen,
|
||||
vipProductId: next.vipProductId,
|
||||
vipCta: next.vipCta,
|
||||
vipOfferKey: next.vipOfferKey,
|
||||
}),
|
||||
})
|
||||
const saved = fromApi(data)
|
||||
setCfg(saved)
|
||||
setDraft(saved)
|
||||
setMsg(okHint)
|
||||
} catch (e: any) {
|
||||
setErr(e.message || '保存失败')
|
||||
await load().catch(() => undefined)
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
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 配置…</div>
|
||||
}
|
||||
|
||||
const vipJumpOn = draft.joinGroupAction === 'vip'
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<header className="page-head">
|
||||
<div>
|
||||
<h1>VIP</h1>
|
||||
<p>
|
||||
默认全关。付费方案与小册相同(免费 / 已发布道具);改完写远程配置并升 version,小程序约 3
|
||||
秒热更新。
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{err ? (
|
||||
<p className="badge bad" style={{ display: 'inline-block', marginBottom: 12 }}>
|
||||
{err}
|
||||
</p>
|
||||
) : null}
|
||||
{msg ? (
|
||||
<p className="badge ok" style={{ display: 'inline-block', marginBottom: 12 }}>
|
||||
{msg}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
<section className="panel monetize-panel" style={{ marginBottom: 16 }}>
|
||||
<div className="monetize-head">
|
||||
<div>
|
||||
<h2 className="monetize-title">立即加入 · 付费控制</h2>
|
||||
<p className="hint">
|
||||
一键切换免费 / 已发布道具。切换后小程序「立即加入」按钮文案与价格立即跟随(已打开会员页约
|
||||
3s 热更新;否则重新进入即可)。
|
||||
</p>
|
||||
</div>
|
||||
<div className="live-preview">
|
||||
<span className="live-preview-label">小程序按钮预览</span>
|
||||
<div className={`live-btn ${isFree ? 'free' : ''}`}>{draft.vipCta || '立即加入'}</div>
|
||||
<span className="live-preview-sub">
|
||||
{isFree
|
||||
? '免费模式 · 不拉起虚拟支付'
|
||||
: `道具 ${draft.vipProductId || '-'} · ¥${(draft.vipPriceFen / 100).toFixed(0)}`}
|
||||
</span>
|
||||
</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="free-banner">当前为免费会员:小程序不拉起支付,「立即加入」显示「免费加入」。</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="panel" style={{ marginBottom: 16 }}>
|
||||
<h2>开关(默认关闭)</h2>
|
||||
<div className="vip-row">
|
||||
<div>
|
||||
<strong>VIP 会员入口</strong>
|
||||
<p className="vip-hint">关闭后会员页闸门拦截</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className={draft.vipEnabled ? 'primary-link' : 'ghost-btn'}
|
||||
disabled={busy}
|
||||
onClick={() =>
|
||||
void save({ vipEnabled: !draft.vipEnabled }, draft.vipEnabled ? 'VIP 已关闭' : 'VIP 已开启')
|
||||
}
|
||||
>
|
||||
{draft.vipEnabled ? '已开启' : '已关闭'}
|
||||
</button>
|
||||
</div>
|
||||
<div className="vip-row">
|
||||
<div>
|
||||
<strong>加群 → 跳转 VIP</strong>
|
||||
<p className="vip-hint">关闭=社群「加群」弹窗引导;开启=跳转会员页</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className={vipJumpOn ? 'primary-link' : 'ghost-btn'}
|
||||
disabled={busy}
|
||||
onClick={() =>
|
||||
void save(
|
||||
{ joinGroupAction: vipJumpOn ? 'popup' : 'vip' },
|
||||
vipJumpOn ? '加群跳 VIP 已关闭(弹窗)' : '加群跳 VIP 已开启',
|
||||
)
|
||||
}
|
||||
>
|
||||
{vipJumpOn ? '已开启' : '已关闭'}
|
||||
</button>
|
||||
</div>
|
||||
<div className="vip-row">
|
||||
<div>
|
||||
<strong>Nomad Day 3D 入口</strong>
|
||||
<p className="vip-hint">关闭后首页不展示 3D 卡片</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className={draft.gameEnabled ? 'primary-link' : 'ghost-btn'}
|
||||
disabled={busy}
|
||||
onClick={() =>
|
||||
void save(
|
||||
{ gameEnabled: !draft.gameEnabled },
|
||||
draft.gameEnabled ? '3D 入口已关闭' : '3D 入口已开启',
|
||||
)
|
||||
}
|
||||
>
|
||||
{draft.gameEnabled ? '已开启' : '已关闭'}
|
||||
</button>
|
||||
</div>
|
||||
{cfg?.updatedAt ? (
|
||||
<p className="vip-hint" style={{ marginTop: 16 }}>
|
||||
最近更新 · v{cfg.version ?? '—'} · {cfg.updatedAt}
|
||||
</p>
|
||||
) : null}
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -382,6 +382,44 @@ th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--lin
|
||||
color: #ff7a93;
|
||||
}
|
||||
|
||||
/* VIP 配置页 */
|
||||
.vip-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.vip-row:last-of-type { border-bottom: none; }
|
||||
.vip-hint {
|
||||
margin: 4px 0 0;
|
||||
color: var(--muted);
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.vip-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin-top: 12px;
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.vip-field input {
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
color: var(--text);
|
||||
padding: 10px 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.vip-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.shell { grid-template-columns: 1fr; }
|
||||
.side { border-right: none; border-bottom: 1px solid var(--line); }
|
||||
|
||||
@ -19,7 +19,7 @@ PRODUCT_OFFERS: list[dict[str, Any]] = [
|
||||
"unlock_percent": 100,
|
||||
"free": True,
|
||||
"image": "",
|
||||
"remark": "unlock_percent=100,全书可读,不拉起支付",
|
||||
"remark": "免费加入,不拉起支付",
|
||||
},
|
||||
{
|
||||
"key": "tiktok",
|
||||
|
||||
@ -11,7 +11,7 @@ from fastapi.staticfiles import StaticFiles
|
||||
|
||||
from ebook_svc.config import settings
|
||||
from ebook_svc.jobs import reconcile_pending_orders
|
||||
from ebook_svc.routers import admin, auth, books, douyin_admin, join_group_admin, pay, public_config, track
|
||||
from ebook_svc.routers import admin, auth, books, douyin_admin, join_group_admin, pay, public_config, track, vip_admin
|
||||
|
||||
scheduler = AsyncIOScheduler()
|
||||
|
||||
@ -49,6 +49,8 @@ app.include_router(admin.router)
|
||||
app.include_router(douyin_admin.router)
|
||||
# 加群引导开关(微信公众号 / 抖音群)
|
||||
app.include_router(join_group_admin.router)
|
||||
# 微信 VIP / 加群行为 / 3D 入口
|
||||
app.include_router(vip_admin.router)
|
||||
# 公开远程配置(抖音真机:dyapi/api 合法域名 + 有效证书)
|
||||
app.include_router(public_config.router)
|
||||
|
||||
|
||||
@ -9,17 +9,132 @@ from fastapi import APIRouter, Depends, HTTPException, Request, Response
|
||||
from ebook_svc.config import settings
|
||||
from ebook_svc.core.deps import get_current_openid
|
||||
from ebook_svc.domains.books import is_book_free
|
||||
from ebook_svc.domains.books.products import PRODUCT_OFFERS
|
||||
from ebook_svc.schemas.pay import DevConfirmBody, OrderBody, StatusBody
|
||||
from ebook_svc.services.store import store
|
||||
from ebook_svc.services.vip_config import read_vip_config
|
||||
from ebook_svc.services.wxpay import build_sign_data, calc_pay_sig, calc_signature, query_order
|
||||
|
||||
router = APIRouter(prefix="/pay", tags=["pay"])
|
||||
|
||||
# VIP 订单在 unlocks / orders 里用的哨兵 book_id(不是真实小册)
|
||||
VIP_BOOK_ID = "__vip__"
|
||||
|
||||
|
||||
def _vip_product_ids() -> set[str]:
|
||||
return {
|
||||
str(o["product_id"])
|
||||
for o in PRODUCT_OFFERS
|
||||
if not o.get("free") and str(o.get("product_id") or "").strip()
|
||||
}
|
||||
|
||||
|
||||
def _build_vip_order_payload(openid: str) -> dict[str, Any]:
|
||||
"""按远程 VIP 方案下单(与小册无关)。"""
|
||||
cfg = read_vip_config()
|
||||
if cfg.get("is_free") or int(cfg.get("vipPriceFen") or 0) <= 0 or not str(
|
||||
cfg.get("vipProductId") or ""
|
||||
).strip():
|
||||
raise HTTPException(400, "当前为免费会员,无需购买")
|
||||
|
||||
product_id = str(cfg["vipProductId"]).strip()
|
||||
price_fen = int(cfg["vipPriceFen"])
|
||||
|
||||
if store.is_unlocked(openid, VIP_BOOK_ID):
|
||||
raise HTTPException(400, "已是会员,无需重复购买")
|
||||
|
||||
user = store.get_user(openid)
|
||||
if not user or not user.get("session_key"):
|
||||
raise HTTPException(401, "session_key 缺失,请重新登录")
|
||||
|
||||
attach = json.dumps(
|
||||
{"type": "vip", "book_id": VIP_BOOK_ID, "openid": openid},
|
||||
ensure_ascii=False,
|
||||
separators=(",", ":"),
|
||||
)
|
||||
out_trade_no = store.create_order(
|
||||
openid=openid,
|
||||
book_id=VIP_BOOK_ID,
|
||||
product_id=product_id,
|
||||
amount_fen=price_fen,
|
||||
attach=attach,
|
||||
)
|
||||
sign_data = build_sign_data(
|
||||
offer_id=settings.wx_offer_id,
|
||||
product_id=product_id,
|
||||
goods_price=price_fen,
|
||||
out_trade_no=out_trade_no,
|
||||
attach=attach,
|
||||
)
|
||||
pay_sig = calc_pay_sig("requestVirtualPayment", sign_data, settings.wx_app_key)
|
||||
signature = calc_signature(sign_data, user["session_key"])
|
||||
return {
|
||||
"signData": sign_data,
|
||||
"mode": "short_series_goods",
|
||||
"paySig": pay_sig,
|
||||
"signature": signature,
|
||||
"outTradeNo": out_trade_no,
|
||||
"productId": product_id,
|
||||
"goodsPrice": price_fen,
|
||||
"kind": "vip",
|
||||
}
|
||||
|
||||
|
||||
async def _track_vip_order(openid: str, payload: dict[str, Any]) -> None:
|
||||
try:
|
||||
from ebook_svc.services.track import ingest_events
|
||||
|
||||
await ingest_events(
|
||||
[
|
||||
{
|
||||
"name": "pay_order_created",
|
||||
"page": "api",
|
||||
"label": payload.get("productId"),
|
||||
"props": {
|
||||
"kind": "vip",
|
||||
"book_id": VIP_BOOK_ID,
|
||||
"out_trade_no": payload.get("outTradeNo"),
|
||||
"price_fen": payload.get("goodsPrice"),
|
||||
},
|
||||
"ts": None,
|
||||
}
|
||||
],
|
||||
openid=openid,
|
||||
client="api",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@router.post("/vip-order")
|
||||
async def create_vip_pay_order(openid: str = Depends(get_current_openid)):
|
||||
"""VIP 会员虚拟支付下单 — 读 remote-config 道具,不查 books。"""
|
||||
payload = _build_vip_order_payload(openid)
|
||||
await _track_vip_order(openid, payload)
|
||||
return payload
|
||||
|
||||
|
||||
@router.get("/vip-status")
|
||||
async def vip_status(openid: str = Depends(get_current_openid)):
|
||||
return {
|
||||
"ok": True,
|
||||
"isVip": store.is_unlocked(openid, VIP_BOOK_ID),
|
||||
"vipBookId": VIP_BOOK_ID,
|
||||
}
|
||||
|
||||
|
||||
@router.post("/order")
|
||||
async def create_pay_order(body: OrderBody, openid: str = Depends(get_current_openid)):
|
||||
book = store.get_book(body.book_id)
|
||||
if not book:
|
||||
# 兼容旧 VIP 客户端:把 product_id 误当成 book_id 传来 → 走会员单
|
||||
hint = str(body.book_id or "").strip()
|
||||
cfg = read_vip_config()
|
||||
vip_pid = str(cfg.get("vipProductId") or "").strip()
|
||||
if hint and (hint in _vip_product_ids() or hint == vip_pid or hint == "vip_membership"):
|
||||
payload = _build_vip_order_payload(openid)
|
||||
await _track_vip_order(openid, payload)
|
||||
return payload
|
||||
raise HTTPException(404, "书籍不存在")
|
||||
if is_book_free(book):
|
||||
raise HTTPException(400, "当前为免费模式,无需购买")
|
||||
@ -79,6 +194,7 @@ async def create_pay_order(body: OrderBody, openid: str = Depends(get_current_op
|
||||
"outTradeNo": out_trade_no,
|
||||
"productId": book["product_id"],
|
||||
"goodsPrice": book["price_fen"],
|
||||
"kind": "book",
|
||||
}
|
||||
|
||||
|
||||
|
||||
49
apps/api/services/ebook_svc/routers/vip_admin.py
Normal file
49
apps/api/services/ebook_svc/routers/vip_admin.py
Normal file
@ -0,0 +1,49 @@
|
||||
"""微信 VIP 运营配置 API — admin.nomadro.cn/wechat/vip。"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Literal
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from ebook_svc.core.security import require_admin
|
||||
from ebook_svc.services.vip_config import apply_vip_offer_key, read_vip_config, write_vip_config
|
||||
|
||||
router = APIRouter(prefix="/api/admin/vip", tags=["vip-admin"])
|
||||
|
||||
|
||||
class VipBody(BaseModel):
|
||||
vipEnabled: bool | None = None
|
||||
gameEnabled: bool | None = None
|
||||
joinGroupAction: Literal["popup", "vip"] | None = None
|
||||
vipPriceFen: int | None = Field(default=None, ge=0)
|
||||
vipProductId: str | None = None
|
||||
vipCta: str | None = None
|
||||
vipOfferKey: str | None = None
|
||||
|
||||
|
||||
class VipOfferBody(BaseModel):
|
||||
offer_key: str = Field(..., min_length=1)
|
||||
|
||||
|
||||
@router.get("")
|
||||
async def get_vip(_: str = Depends(require_admin)) -> dict[str, Any]:
|
||||
return {"ok": True, **read_vip_config()}
|
||||
|
||||
|
||||
@router.put("")
|
||||
async def put_vip(body: VipBody, _: str = Depends(require_admin)) -> dict[str, Any]:
|
||||
patch = body.model_dump(exclude_none=True)
|
||||
saved = write_vip_config(patch)
|
||||
return {"ok": True, **saved}
|
||||
|
||||
|
||||
@router.post("/offer")
|
||||
async def apply_vip_offer(body: VipOfferBody, _: str = Depends(require_admin)) -> dict[str, Any]:
|
||||
"""一键切换免费 / 已发布道具(对齐小册 POST /books/{id}/offer)。"""
|
||||
try:
|
||||
apply_vip_offer_key(body.offer_key)
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e)) from e
|
||||
saved = write_vip_config({"vipOfferKey": body.offer_key})
|
||||
return {"ok": True, **saved}
|
||||
227
apps/api/services/ebook_svc/services/vip_config.py
Normal file
227
apps/api/services/ebook_svc/services/vip_config.py
Normal file
@ -0,0 +1,227 @@
|
||||
"""微信 VIP / 加群行为 / 3D 入口 — 读写 remote-config,不碰订单与抖音 platforms.tt。
|
||||
|
||||
VIP「立即加入」付费方案复用小册 PRODUCT_OFFERS(免费 / 已发布道具)。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any, Literal
|
||||
|
||||
from ebook_svc.domains.books.products import PRODUCT_OFFERS, _LEGACY_PRODUCT_IDS
|
||||
from ebook_svc.services.tt_platform_config import resolve_config_file
|
||||
|
||||
JoinAction = Literal["popup", "vip"]
|
||||
|
||||
DEFAULT_VIP = {
|
||||
"vipEnabled": False,
|
||||
"gameEnabled": False,
|
||||
# VIP 跳转默认关 → 加群仍弹窗(现网);后台可开 vip
|
||||
"joinGroupAction": "popup",
|
||||
"vipPriceFen": 29800,
|
||||
"vipProductId": "tiktok",
|
||||
"vipCta": "立即加入 · ¥298",
|
||||
"vipOfferKey": "tiktok",
|
||||
}
|
||||
|
||||
|
||||
def _read_raw() -> dict[str, Any]:
|
||||
path = resolve_config_file()
|
||||
if not path.is_file():
|
||||
return {}
|
||||
try:
|
||||
raw = json.loads(path.read_text(encoding="utf-8"))
|
||||
return raw if isinstance(raw, dict) else {}
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
|
||||
def _as_action(v: Any, fallback: JoinAction = "popup") -> JoinAction:
|
||||
return "popup" if v == "popup" else "vip" if v == "vip" else fallback
|
||||
|
||||
|
||||
def vip_cta_text(*, free: bool, price_fen: int) -> str:
|
||||
"""小程序「立即加入」按钮文案(方案驱动,对齐小册 unlock_button_text)。"""
|
||||
if free or price_fen <= 0:
|
||||
return "免费加入"
|
||||
yuan = price_fen / 100
|
||||
if yuan == int(yuan):
|
||||
return f"立即加入 · ¥{int(yuan)}"
|
||||
return f"立即加入 · ¥{yuan:.2f}"
|
||||
|
||||
|
||||
def match_vip_offer(
|
||||
*,
|
||||
offer_key: str = "",
|
||||
product_id: str = "",
|
||||
price_fen: int = 0,
|
||||
) -> dict[str, Any]:
|
||||
key = (offer_key or "").strip()
|
||||
if key:
|
||||
key = _LEGACY_PRODUCT_IDS.get(key, key)
|
||||
for o in PRODUCT_OFFERS:
|
||||
if o["key"] == key or o["product_id"] == key:
|
||||
return o
|
||||
|
||||
pid = (product_id or "").strip()
|
||||
mapped = _LEGACY_PRODUCT_IDS.get(pid, pid)
|
||||
if not pid and price_fen <= 0:
|
||||
return PRODUCT_OFFERS[0] # free
|
||||
|
||||
for o in PRODUCT_OFFERS:
|
||||
if o["free"]:
|
||||
continue
|
||||
if o["product_id"] == pid or o["key"] == mapped or o["product_id"] == mapped:
|
||||
return o
|
||||
|
||||
# 旧默认 vip_membership → 视为自定义
|
||||
return {
|
||||
"key": "custom",
|
||||
"label": pid or "自定义",
|
||||
"name": pid or "自定义",
|
||||
"product_id": pid,
|
||||
"price_fen": int(price_fen),
|
||||
"free": price_fen <= 0 and not pid,
|
||||
"image": "",
|
||||
"remark": "未在目录中的自定义道具",
|
||||
}
|
||||
|
||||
|
||||
def apply_vip_offer_key(key: str) -> dict[str, Any]:
|
||||
"""一键应用免费 / 已发布道具 → vipPriceFen / vipProductId / vipCta / vipOfferKey。"""
|
||||
key = _LEGACY_PRODUCT_IDS.get((key or "").strip(), (key or "").strip())
|
||||
offer = next(
|
||||
(
|
||||
o
|
||||
for o in PRODUCT_OFFERS
|
||||
if o["key"] == key or o["product_id"] == key or o["name"] == key
|
||||
),
|
||||
None,
|
||||
)
|
||||
if not offer:
|
||||
raise ValueError(f"未知方案: {key}")
|
||||
|
||||
free = bool(offer["free"])
|
||||
price = 0 if free else int(offer["price_fen"])
|
||||
pid = "" if free else str(offer["product_id"])
|
||||
return {
|
||||
"vipOfferKey": str(offer["key"]),
|
||||
"vipPriceFen": price,
|
||||
"vipProductId": pid,
|
||||
"vipCta": vip_cta_text(free=free, price_fen=price),
|
||||
"is_free": free,
|
||||
}
|
||||
|
||||
|
||||
def read_vip_config() -> dict[str, Any]:
|
||||
raw = _read_raw()
|
||||
modules = raw.get("modules") if isinstance(raw.get("modules"), dict) else {}
|
||||
flags = raw.get("flags") if isinstance(raw.get("flags"), dict) else {}
|
||||
copy = raw.get("copy") if isinstance(raw.get("copy"), dict) else {}
|
||||
|
||||
vip_mod = modules.get("vip") if isinstance(modules.get("vip"), dict) else {}
|
||||
game_mod = modules.get("game") if isinstance(modules.get("game"), dict) else {}
|
||||
|
||||
vip_enabled = vip_mod.get("enabled")
|
||||
if not isinstance(vip_enabled, bool):
|
||||
vip_enabled = DEFAULT_VIP["vipEnabled"]
|
||||
|
||||
game_enabled = game_mod.get("enabled")
|
||||
if not isinstance(game_enabled, bool):
|
||||
game_enabled = DEFAULT_VIP["gameEnabled"]
|
||||
|
||||
try:
|
||||
price = int(copy.get("vipPriceFen", DEFAULT_VIP["vipPriceFen"]))
|
||||
except Exception:
|
||||
price = int(DEFAULT_VIP["vipPriceFen"])
|
||||
|
||||
product_id = str(copy.get("vipProductId") if "vipProductId" in copy else DEFAULT_VIP["vipProductId"])
|
||||
offer_key = str(copy.get("vipOfferKey") or "")
|
||||
offer = match_vip_offer(offer_key=offer_key, product_id=product_id, price_fen=price)
|
||||
is_free = bool(offer.get("free")) or (price <= 0 and not product_id.strip())
|
||||
|
||||
cta = str(copy.get("vipCta") or "").strip()
|
||||
if not cta:
|
||||
cta = vip_cta_text(free=is_free, price_fen=price)
|
||||
|
||||
return {
|
||||
"vipEnabled": bool(vip_enabled),
|
||||
"gameEnabled": bool(game_enabled),
|
||||
"joinGroupAction": _as_action(flags.get("joinGroupAction"), "popup"),
|
||||
"vipPriceFen": price,
|
||||
"vipProductId": product_id,
|
||||
"vipCta": cta,
|
||||
"vipOfferKey": str(offer.get("key") or offer_key or ""),
|
||||
"is_free": is_free,
|
||||
"updatedAt": raw.get("updatedAt"),
|
||||
"version": raw.get("version"),
|
||||
"configPath": str(resolve_config_file()),
|
||||
}
|
||||
|
||||
|
||||
def write_vip_config(patch: dict[str, Any]) -> dict[str, Any]:
|
||||
path = resolve_config_file()
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
existing = _read_raw()
|
||||
out: dict[str, Any] = (
|
||||
dict(existing) if existing else {"version": 2, "modules": {}, "flags": {}, "copy": {}}
|
||||
)
|
||||
|
||||
modules = dict(out.get("modules") or {})
|
||||
flags = dict(out.get("flags") or {})
|
||||
copy = dict(out.get("copy") or {})
|
||||
|
||||
# 一键方案优先:写出价格 / 道具 / CTA / offerKey
|
||||
if "vipOfferKey" in patch and patch["vipOfferKey"] is not None:
|
||||
applied = apply_vip_offer_key(str(patch["vipOfferKey"]))
|
||||
copy["vipOfferKey"] = applied["vipOfferKey"]
|
||||
copy["vipPriceFen"] = applied["vipPriceFen"]
|
||||
copy["vipProductId"] = applied["vipProductId"]
|
||||
copy["vipCta"] = applied["vipCta"]
|
||||
else:
|
||||
if "vipPriceFen" in patch and patch["vipPriceFen"] is not None:
|
||||
try:
|
||||
copy["vipPriceFen"] = max(0, int(patch["vipPriceFen"]))
|
||||
except Exception:
|
||||
pass
|
||||
if "vipProductId" in patch and patch["vipProductId"] is not None:
|
||||
# 允许空串 = 免费方案
|
||||
copy["vipProductId"] = str(patch["vipProductId"]).strip()
|
||||
if "vipCta" in patch and patch["vipCta"] is not None:
|
||||
copy["vipCta"] = str(patch["vipCta"]).strip() or DEFAULT_VIP["vipCta"]
|
||||
if "vipOfferKey" in patch and patch["vipOfferKey"] is not None:
|
||||
copy["vipOfferKey"] = str(patch["vipOfferKey"]).strip()
|
||||
|
||||
if "vipEnabled" in patch and isinstance(patch["vipEnabled"], bool):
|
||||
vip = dict(modules.get("vip") or {"title": "会员中心", "note": "deep link only"})
|
||||
vip["enabled"] = patch["vipEnabled"]
|
||||
vip.setdefault("title", "会员中心")
|
||||
modules["vip"] = vip
|
||||
|
||||
if "gameEnabled" in patch and isinstance(patch["gameEnabled"], bool):
|
||||
game = dict(modules.get("game") or {"title": "Nomad Day 3D", "note": "WebGL 数字游民一日"})
|
||||
game["enabled"] = patch["gameEnabled"]
|
||||
game.setdefault("title", "Nomad Day 3D")
|
||||
modules["game"] = game
|
||||
|
||||
if "joinGroupAction" in patch:
|
||||
flags["joinGroupAction"] = _as_action(patch["joinGroupAction"], "popup")
|
||||
|
||||
out["modules"] = modules
|
||||
out["flags"] = flags
|
||||
out["copy"] = copy
|
||||
out["updatedAt"] = datetime.now(timezone.utc).isoformat()
|
||||
try:
|
||||
out["version"] = int(out.get("version") or 1) + 1
|
||||
except Exception:
|
||||
out["version"] = 2
|
||||
|
||||
if path.is_file():
|
||||
bak = path.with_suffix(path.suffix + f".bak-{out['updatedAt'].replace(':', '-')}")
|
||||
try:
|
||||
bak.write_text(path.read_text(encoding="utf-8"), encoding="utf-8")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
path.write_text(json.dumps(out, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
||||
return read_vip_config()
|
||||
@ -9,4 +9,6 @@
|
||||
|
||||
业务 API:`apps/api`。管理后台:`apps/admin`。
|
||||
|
||||
**全端禁止 web-view 承载业务内容**(VIP / 电子书 / 视频课等须原生页)。微信 VIP 说明见 `weapp/README.md`。
|
||||
|
||||
H5 游戏模块冷冻,默认勿改。
|
||||
|
||||
112
apps/miniprogram/h5/scripts/extract-vip-ebooks.py
Normal file
112
apps/miniprogram/h5/scripts/extract-vip-ebooks.py
Normal file
@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Pack nomadvip ebook.md + cloudphone.md into weapp vipEbooks.ts"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[4]
|
||||
SRC = ROOT / "src/modules/vip/app/data"
|
||||
OUT = ROOT / "apps/miniprogram/h5/src/data/vipEbooks.ts"
|
||||
|
||||
|
||||
def parse_headers(md: str) -> list[str]:
|
||||
h1 = re.findall(r"(?m)^#\s+(.+)$", md)
|
||||
if h1:
|
||||
return [re.sub(r"#+\s*", "", x).strip() for x in h1]
|
||||
return [x.strip() for x in re.findall(r"(?m)^##\s+(.+)$", md)]
|
||||
|
||||
|
||||
def split_sections(md: str) -> list[str]:
|
||||
h1s = list(re.finditer(r"(?m)^#\s+.+$", md))
|
||||
if len(h1s) > 1:
|
||||
parts: list[str] = []
|
||||
for i, m in enumerate(h1s):
|
||||
end = h1s[i + 1].start() if i + 1 < len(h1s) else len(md)
|
||||
chunk = md[m.start() : end].strip()
|
||||
if chunk:
|
||||
parts.append(chunk)
|
||||
return parts
|
||||
|
||||
h2s = list(re.finditer(r"(?m)^##\s+.+$", md))
|
||||
if len(h2s) > 1:
|
||||
parts = []
|
||||
if h2s[0].start() > 0:
|
||||
pre = md[: h2s[0].start()].strip()
|
||||
if pre:
|
||||
parts.append(pre)
|
||||
for i, m in enumerate(h2s):
|
||||
end = h2s[i + 1].start() if i + 1 < len(h2s) else len(md)
|
||||
chunk = md[m.start() : end].strip()
|
||||
if chunk:
|
||||
parts.append(chunk)
|
||||
return parts
|
||||
return [md]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
books = {
|
||||
"nomad": {
|
||||
"id": "nomad",
|
||||
"title": "数字游民",
|
||||
"free": True,
|
||||
"estimatedMinutes": 45,
|
||||
"file": "ebook.md",
|
||||
},
|
||||
"cloudphone": {
|
||||
"id": "cloudphone",
|
||||
"title": "云手机",
|
||||
"free": False,
|
||||
"estimatedMinutes": 25,
|
||||
"file": "cloudphone.md",
|
||||
},
|
||||
}
|
||||
payload = {}
|
||||
for key, meta in books.items():
|
||||
md = (SRC / meta["file"]).read_text(encoding="utf-8")
|
||||
payload[key] = {
|
||||
"id": meta["id"],
|
||||
"title": meta["title"],
|
||||
"free": meta["free"],
|
||||
"estimatedMinutes": meta["estimatedMinutes"],
|
||||
"headers": parse_headers(md),
|
||||
"sections": split_sections(md),
|
||||
"markdown": md,
|
||||
}
|
||||
print(
|
||||
key,
|
||||
"chars",
|
||||
len(md),
|
||||
"headers",
|
||||
len(payload[key]["headers"]),
|
||||
"sections",
|
||||
len(payload[key]["sections"]),
|
||||
)
|
||||
|
||||
body = json.dumps(payload, ensure_ascii=False, indent=2)
|
||||
OUT.write_text(
|
||||
"/** Auto from src/modules/vip/app/data — nomadvip EbookViewer SoT */\n"
|
||||
"export type VipEbookId = 'nomad' | 'cloudphone'\n"
|
||||
"export type VipEbookPack = {\n"
|
||||
" id: VipEbookId\n"
|
||||
" title: string\n"
|
||||
" free: boolean\n"
|
||||
" estimatedMinutes: number\n"
|
||||
" headers: string[]\n"
|
||||
" sections: string[]\n"
|
||||
" markdown: string\n"
|
||||
"}\n"
|
||||
f"export const VIP_EBOOKS: Record<VipEbookId, VipEbookPack> = {body}\n"
|
||||
"export function resolveVipEbookId(raw?: string): VipEbookId {\n"
|
||||
" const id = String(raw || 'nomad').trim()\n"
|
||||
" if (id === 'cloudphone' || id === '2') return 'cloudphone'\n"
|
||||
" return 'nomad'\n"
|
||||
"}\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
print("wrote", OUT, "bytes", OUT.stat().st_size)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
99
apps/miniprogram/h5/scripts/extract-vip-lessons.py
Normal file
99
apps/miniprogram/h5/scripts/extract-vip-lessons.py
Normal file
@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Extract cloudphone lesson markdown + videoUrl into weapp data."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[4]
|
||||
SRC = ROOT / "src/modules/vip/app/cloudphone/config/lessons.ts"
|
||||
OUT = ROOT / "apps/miniprogram/h5/src/data/vipLessonContent.ts"
|
||||
|
||||
SAMPLE = "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
|
||||
|
||||
|
||||
def extract_template_literals(text: str) -> dict[str, str]:
|
||||
"""Parse key -> template-literal blocks; allow escaped backticks inside."""
|
||||
out: dict[str, str] = {}
|
||||
# Only scan LESSON_MARKDOWNS block to avoid LESSONS_MAP noise
|
||||
block_m = re.search(
|
||||
r"const LESSON_MARKDOWNS[^=]*=\s*\{(.*?)\n\};",
|
||||
text,
|
||||
re.S,
|
||||
)
|
||||
body = block_m.group(1) if block_m else text
|
||||
i = 0
|
||||
while True:
|
||||
m = re.search(r'"(\d+-\d+)":\s*`', body[i:])
|
||||
if not m:
|
||||
break
|
||||
key = m.group(1)
|
||||
start = i + m.end()
|
||||
j = start
|
||||
chunks: list[str] = []
|
||||
while j < len(body):
|
||||
ch = body[j]
|
||||
if ch == "\\" and j + 1 < len(body):
|
||||
nxt = body[j + 1]
|
||||
if nxt == "`":
|
||||
chunks.append("`")
|
||||
elif nxt == "\\":
|
||||
chunks.append("\\")
|
||||
elif nxt == "n":
|
||||
chunks.append("\n")
|
||||
elif nxt == "t":
|
||||
chunks.append("\t")
|
||||
else:
|
||||
chunks.append(nxt)
|
||||
j += 2
|
||||
continue
|
||||
if ch == "`":
|
||||
break
|
||||
chunks.append(ch)
|
||||
j += 1
|
||||
out[key] = "".join(chunks).strip("\n")
|
||||
i = j + 1
|
||||
return out
|
||||
|
||||
|
||||
def extract_videos(text: str) -> dict[str, str]:
|
||||
vids: dict[str, str] = {}
|
||||
map_m = re.search(r"export const LESSONS_MAP[^=]*=\s*\{(.*?)\n\};", text, re.S)
|
||||
body = map_m.group(1) if map_m else text
|
||||
for m in re.finditer(
|
||||
r'"(\d+-\d+)":\s*\{[^}]*?videoUrl:\s*(?:"([^"]+)"|SAMPLE_VIDEO)',
|
||||
body,
|
||||
re.S,
|
||||
):
|
||||
vids[m.group(1)] = m.group(2) or SAMPLE
|
||||
return vids
|
||||
|
||||
|
||||
def main() -> None:
|
||||
text = SRC.read_text(encoding="utf-8")
|
||||
mds = extract_template_literals(text)
|
||||
vids = extract_videos(text)
|
||||
keys = sorted(
|
||||
set(mds) | set(vids),
|
||||
key=lambda x: (int(x.split("-")[0]), int(x.split("-")[1])),
|
||||
)
|
||||
payload = {
|
||||
k: {"markdown": mds.get(k, ""), "videoUrl": vids.get(k, SAMPLE)} for k in keys
|
||||
}
|
||||
OUT.write_text(
|
||||
"/** Auto from src/modules/vip/app/cloudphone/config/lessons.ts */\n"
|
||||
"export const VIP_LESSON_CONTENT: Record<\n"
|
||||
" string,\n"
|
||||
" { markdown: string; videoUrl: string }\n"
|
||||
f"> = {json.dumps(payload, ensure_ascii=False, indent=2)}\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
print("keys", len(payload), "bytes", OUT.stat().st_size)
|
||||
empty = [k for k, v in payload.items() if len(v["markdown"]) < 80]
|
||||
if empty:
|
||||
print("WARN short markdown:", empty)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@ -57,6 +57,9 @@ export default defineAppConfig({
|
||||
'pages/destination/index',
|
||||
'pages/meetups/index',
|
||||
'pages/vip/index',
|
||||
'pages/vip-course/index',
|
||||
'pages/vip-lesson/index',
|
||||
'pages/vip-ebook/index',
|
||||
'pages/game/index',
|
||||
],
|
||||
window: {
|
||||
|
||||
@ -28,24 +28,29 @@ function flagOn(v: unknown): boolean {
|
||||
|
||||
/**
|
||||
* 仅在「联网拿到后台配置」时用:严格跟 flags。
|
||||
* 双开时:抖音端优先抖音,其它端优先微信。
|
||||
* 双开时:抖音端优先抖音,微信/H5 优先公众号。
|
||||
* 微信小程序永远走公众号(不被抖音后台频道抢走)。
|
||||
*/
|
||||
function resolveChannelOnline(flags: {
|
||||
joinGroupWechat?: unknown
|
||||
joinGroupDouyin?: unknown
|
||||
}): Channel {
|
||||
if (isWeapp) return 'wechat'
|
||||
const wx = flagOn(flags.joinGroupWechat)
|
||||
const dy = flagOn(flags.joinGroupDouyin)
|
||||
if (wx && !dy) return 'wechat'
|
||||
if (dy && !wx) return 'douyin'
|
||||
if (wx && dy) return isTt ? 'douyin' : 'wechat'
|
||||
return 'none'
|
||||
// 两端都关:微信端仍给公众号兜底,抖音才 none
|
||||
if (isTt) return 'none'
|
||||
return 'wechat'
|
||||
}
|
||||
|
||||
/**
|
||||
* 加群弹窗:
|
||||
* - 拉取失败 / 离线 → 默认抖音群
|
||||
* - 联网成功 → 永远跟后台 flags 实时显示
|
||||
* - 微信小程序:永远公众号(含离线)
|
||||
* - 抖音:联网跟 flags;离线默认抖音群
|
||||
* - H5:联网跟 flags;离线默认公众号
|
||||
*/
|
||||
export function WechatOaModal({
|
||||
open,
|
||||
@ -74,6 +79,7 @@ export function WechatOaModal({
|
||||
setChannel(null)
|
||||
trackJoinGroup('open')
|
||||
void (async () => {
|
||||
const offlineFallback: Channel = isWeapp ? 'wechat' : isTt ? 'douyin' : 'wechat'
|
||||
try {
|
||||
const result = await loadRemoteConfig(true)
|
||||
if (cancelled) return
|
||||
@ -87,7 +93,11 @@ export function WechatOaModal({
|
||||
),
|
||||
douyinQr: String(cfg.copy?.joinGroupDouyinQr || ''),
|
||||
})
|
||||
const ch = offline ? 'douyin' : resolveChannelOnline(cfg.flags || {})
|
||||
const ch = isWeapp
|
||||
? 'wechat'
|
||||
: offline
|
||||
? offlineFallback
|
||||
: resolveChannelOnline(cfg.flags || {})
|
||||
if (ch === 'none') {
|
||||
Taro.showToast({ title: '加群暂未开放', icon: 'none' })
|
||||
onCloseRef.current()
|
||||
@ -97,8 +107,8 @@ export function WechatOaModal({
|
||||
setChannel(ch)
|
||||
} catch {
|
||||
if (cancelled) return
|
||||
trackJoinGroup('show', { popup: 'douyin', offline: true })
|
||||
setChannel('douyin')
|
||||
trackJoinGroup('show', { popup: offlineFallback, offline: true })
|
||||
setChannel(offlineFallback)
|
||||
}
|
||||
})()
|
||||
return () => {
|
||||
|
||||
@ -25,6 +25,8 @@ export type NomadroRemoteConfig = {
|
||||
socialFollowAuto?: boolean
|
||||
joinGroupWechat?: boolean
|
||||
joinGroupDouyin?: boolean
|
||||
/** 加群点击:popup=弹窗(默认关跳转);vip=跳会员页 */
|
||||
joinGroupAction?: 'popup' | 'vip'
|
||||
offlineBadge: boolean
|
||||
}
|
||||
copy: {
|
||||
@ -50,8 +52,8 @@ export const DEFAULT_REMOTE_CONFIG: NomadroRemoteConfig = {
|
||||
community: { enabled: true, title: '旅居社群', tabLabel: '社群' },
|
||||
destinations: { enabled: true, title: '目的地' },
|
||||
meetups: { enabled: true, title: '活动' },
|
||||
vip: { enabled: true, title: '会员中心' },
|
||||
game: { enabled: true, title: 'Nomad Day 3D', note: 'WebGL 数字游民一日' },
|
||||
vip: { enabled: false, title: '会员中心' },
|
||||
game: { enabled: false, title: 'Nomad Day 3D', note: '默认隐藏入口' },
|
||||
},
|
||||
flags: {
|
||||
payEnabled: true,
|
||||
@ -59,6 +61,7 @@ export const DEFAULT_REMOTE_CONFIG: NomadroRemoteConfig = {
|
||||
socialFollowAuto: false,
|
||||
joinGroupWechat: true,
|
||||
joinGroupDouyin: false,
|
||||
joinGroupAction: 'popup',
|
||||
offlineBadge: false,
|
||||
},
|
||||
copy: {
|
||||
@ -66,8 +69,8 @@ export const DEFAULT_REMOTE_CONFIG: NomadroRemoteConfig = {
|
||||
homeTagline: '',
|
||||
homeLead: '',
|
||||
vipPriceFen: 29800,
|
||||
vipProductId: 'vip_membership',
|
||||
vipCta: '立即加入',
|
||||
vipProductId: 'tiktok',
|
||||
vipCta: '立即加入 · ¥298',
|
||||
wechatOaName: '异度世界',
|
||||
joinGroupDouyinHint: '打开抖音搜群「数字游民」或扫码进群',
|
||||
joinGroupDouyinQr: '',
|
||||
|
||||
50
apps/miniprogram/h5/src/data/vipCloudphoneLanding.ts
Normal file
50
apps/miniprogram/h5/src/data/vipCloudphoneLanding.ts
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 云手机落地配置 — 对照 nomadvip app/cloudphone/config/course.ts
|
||||
*/
|
||||
export const CLOUDPHONE_HERO = {
|
||||
title: '云手机实战课',
|
||||
subtitle: '低成本工作室搭建指南 · TikTok/Youtube 无人直播,开启 24 小时赚美金',
|
||||
stats: [
|
||||
{ value: '13', label: '节实战课程' },
|
||||
{ value: '170+', label: '分钟视频' },
|
||||
{ value: '1', label: '位资深导师' },
|
||||
],
|
||||
} as const
|
||||
|
||||
export const CLOUDPHONE_AUDIENCE = {
|
||||
title: '这门课适合谁?',
|
||||
subtitle: '向往低成本自建,想用开源硬件实现无人直播的人',
|
||||
items: [
|
||||
{ emoji: '💻', title: '无人直播创业者', desc: '想用低成本硬件搭建 TikTok/Youtube 直播矩阵' },
|
||||
{ emoji: '⚙️', title: '技术极客', desc: '想自建云手机、Redroid、ARM 开发板玩转自动化' },
|
||||
{ emoji: '📱', title: '出海副业者', desc: '想摆脱云手机平台高额月费,自建开箱即用' },
|
||||
{ emoji: '🌴', title: '工作室搭建者', desc: '想低成本打造无人值守 24 小时赚美金' },
|
||||
],
|
||||
} as const
|
||||
|
||||
export const CLOUDPHONE_BENEFITS = {
|
||||
title: '学完你将获得',
|
||||
subtitle: '5大核心能力,助你自建云手机工作室',
|
||||
items: [
|
||||
{ num: '1', title: '云手机自建方案', desc: 'Redroid、AOSP 安卓、ARM 开发板,从零搭建云手机' },
|
||||
{ num: '2', title: '无人直播技术栈', desc: 'ffmpeg、SRS、油猴脚本,实现 24 小时自动化推流' },
|
||||
{ num: '3', title: '软路由与网络', desc: '科学上网、静态住宅 IP,出海必备基础设施' },
|
||||
{ num: '4', title: '硬件选型与成本', desc: '开发板、采集卡、配件,一套成本不过千' },
|
||||
{ num: '5', title: 'VIP 社群支持', desc: '加入异度星球,获取部署教程与即时答疑' },
|
||||
],
|
||||
} as const
|
||||
|
||||
export const CLOUDPHONE_CURRICULUM_META = {
|
||||
title: '实战课程',
|
||||
subtitle: '从入门到进阶,完整搭建云手机工作室',
|
||||
} as const
|
||||
|
||||
export const CLOUDPHONE_FAQ = {
|
||||
title: '常见问题',
|
||||
items: [
|
||||
{ q: '课程可以永久回看吗?', a: '可以,VIP 会员永久有效,随时回看。' },
|
||||
{ q: '适合零基础吗?', a: '适合。课程从入门到进阶,前 2 节可免费试看。' },
|
||||
{ q: '有社群答疑吗?', a: '有,VIP 加入异度星球专属社群,即时答疑。' },
|
||||
{ q: '支持退款吗?', a: '虚拟数字交付,不支持退款。' },
|
||||
],
|
||||
} as const
|
||||
111
apps/miniprogram/h5/src/data/vipCourse.ts
Normal file
111
apps/miniprogram/h5/src/data/vipCourse.ts
Normal file
@ -0,0 +1,111 @@
|
||||
/** VIP 云手机课程目录(对照 nomadvip / modules/vip cloudphone) */
|
||||
export type VipLesson = {
|
||||
key: string
|
||||
moduleIndex: number
|
||||
lessonIndex: number
|
||||
name: string
|
||||
duration: string
|
||||
videoUrl: string
|
||||
}
|
||||
|
||||
export type VipModule = {
|
||||
emoji: string
|
||||
title: string
|
||||
lessons: VipLesson[]
|
||||
}
|
||||
|
||||
const V: Record<string, string> = {
|
||||
'0-0': 'https://minioweb.hackrobot.cn/hackrobot/1. 安装安卓img_20260326_095335_848.mp4',
|
||||
'0-1': 'https://minioweb.hackrobot.cn/hackrobot/2. 安卓扩容_20260326_095426_1002.mp4',
|
||||
'1-0': 'https://minioweb.hackrobot.cn/hackrobot/3. 设置竖屏_20260326_095414_979.mp4',
|
||||
'1-1': 'https://minioweb.hackrobot.cn/hackrobot/4. 安装magisk以及模块_20260326_095427_1018.mp4',
|
||||
'1-2': 'https://minioweb.hackrobot.cn/hackrobot/5. 修改机型参数_20260326_095438_1051.mp4',
|
||||
'2-0': 'https://minioweb.hackrobot.cn/hackrobot/6. gps定位_20260326_095430_1031.mp4',
|
||||
'2-1': 'https://minioweb.hackrobot.cn/hackrobot/7无人直播-录播_20260326_100335_2814.mp4',
|
||||
'2-2': 'https://minioweb.hackrobot.cn/hackrobot/8. tiktok直播_20260326_095441_1064.mp4',
|
||||
'2-3': 'https://minioweb.hackrobot.cn/hackrobot/9. tiktok直播-2_20260326_095403_943.mp4',
|
||||
}
|
||||
const FALLBACK =
|
||||
'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4'
|
||||
|
||||
const RAW = [
|
||||
{
|
||||
emoji: '🚀',
|
||||
title: '基础篇 · 云手机入门',
|
||||
lessons: [
|
||||
{ name: '01 从0到1:安卓镜像安装与首次开机', duration: '08:32', key: '0-0' },
|
||||
{ name: '02 性能翻倍:安卓存储扩容实操', duration: '12:15', key: '0-1' },
|
||||
],
|
||||
},
|
||||
{
|
||||
emoji: '⚙️',
|
||||
title: '技术篇 · Redroid 与 AOSP',
|
||||
lessons: [
|
||||
{ name: '03 竖屏直播必备:系统显示方向设置', duration: '15:20', key: '1-0' },
|
||||
{ name: '04 一次搞定 Root:Magisk + 模块安装', duration: '18:00', key: '1-1' },
|
||||
{ name: '05 防风控第一步:机型参数改造', duration: '14:30', key: '1-2' },
|
||||
],
|
||||
},
|
||||
{
|
||||
emoji: '📺',
|
||||
title: '直播篇 · 无人推流',
|
||||
lessons: [
|
||||
{ name: '06 降低风控命中:GPS 精准定位', duration: '16:00', key: '2-0' },
|
||||
{ name: '07 无人直播入门:录播素材循环推流', duration: '12:45', key: '2-1' },
|
||||
{ name: '08 TikTok 实战开播:完整流程演示', duration: '11:20', key: '2-2' },
|
||||
{ name: '09 TikTok 进阶优化:稳定推流与细节调优', duration: '20:00', key: '2-3' },
|
||||
],
|
||||
},
|
||||
{
|
||||
emoji: '🌐',
|
||||
title: '网络篇 · 出海基础',
|
||||
lessons: [
|
||||
{ name: '10 软路由与科学上网', duration: '13:00', key: '3-0' },
|
||||
{ name: '11 静态住宅 IP 配置', duration: '10:30', key: '3-1' },
|
||||
],
|
||||
},
|
||||
{
|
||||
emoji: '🏆',
|
||||
title: '进阶篇 · 产品化',
|
||||
lessons: [
|
||||
{ name: '12 HDMI 辅助板方案', duration: '15:00', key: '4-0' },
|
||||
{ name: '13 多设备群控与远控', duration: '12:00', key: '4-1' },
|
||||
],
|
||||
},
|
||||
] as const
|
||||
|
||||
export const VIP_COURSE_MODULES: VipModule[] = RAW.map((m, mi) => ({
|
||||
emoji: m.emoji,
|
||||
title: m.title,
|
||||
lessons: m.lessons.map((l, li) => ({
|
||||
key: l.key,
|
||||
moduleIndex: mi,
|
||||
lessonIndex: li,
|
||||
name: l.name,
|
||||
duration: l.duration,
|
||||
videoUrl: V[l.key] || FALLBACK,
|
||||
})),
|
||||
}))
|
||||
|
||||
export function getVipLesson(moduleIndex: number, lessonIndex: number): VipLesson | null {
|
||||
const mod = VIP_COURSE_MODULES[moduleIndex]
|
||||
if (!mod) return null
|
||||
return mod.lessons[lessonIndex] || null
|
||||
}
|
||||
|
||||
export const VIP_EBOOKS = [
|
||||
{
|
||||
id: 'nomad',
|
||||
title: '数字游民',
|
||||
desc: '地理套利与自动化杠杆',
|
||||
free: true,
|
||||
readerId: 'default',
|
||||
},
|
||||
{
|
||||
id: 'cloudphone',
|
||||
title: '云手机',
|
||||
desc: '低成本工作室搭建指南',
|
||||
free: false,
|
||||
readerId: 'cloudphone',
|
||||
},
|
||||
] as const
|
||||
144
apps/miniprogram/h5/src/data/vipEbooks.ts
Normal file
144
apps/miniprogram/h5/src/data/vipEbooks.ts
Normal file
File diff suppressed because one or more lines are too long
58
apps/miniprogram/h5/src/data/vipLessonContent.ts
Normal file
58
apps/miniprogram/h5/src/data/vipLessonContent.ts
Normal file
@ -0,0 +1,58 @@
|
||||
/** Auto from src/modules/vip/app/cloudphone/config/lessons.ts */
|
||||
export const VIP_LESSON_CONTENT: Record<
|
||||
string,
|
||||
{ markdown: string; videoUrl: string }
|
||||
> = {
|
||||
"0-0": {
|
||||
"markdown": "# 01 从0到1:安卓镜像安装与首次开机\n\n对应电子书章节:`硬件选择` -> `刷入安卓系统`。\n\n## 你会完成什么\n\n- 准备 TF 卡、读卡器、开发板电源与网线\n- 下载开发板安卓镜像(AOSP)\n- 用 Balena Etcher 刷写 img 并首次开机\n\n## 实操步骤\n\n1. 将 img 镜像写入 TF 卡\n2. TF 卡插回开发板,接通电源和网线\n3. 首次启动后确认系统已进入桌面并可调试\n\n## 避坑提醒\n\n- 刷机前优先确认镜像版本与板型匹配\n- 首次开机时间可能较长,不要中途断电",
|
||||
"videoUrl": "https://minioweb.hackrobot.cn/hackrobot/1. 安装安卓img_20260326_095335_848.mp4"
|
||||
},
|
||||
"0-1": {
|
||||
"markdown": "# 02 性能翻倍:安卓存储扩容实操\n\n对应电子书章节:`硬件选择` 与存储相关说明(TF/SSD 组合)。\n\n## 核心目标\n\n- 解决默认系统空间不足导致的安装失败\n- 保证后续安装模块、素材、脚本有足够空间\n\n## 推荐方案\n\n- TF 卡至少 64GB\n- 优先使用 USB3.0 读卡器提升刷写效率\n- 有条件时搭配 SSD 作为素材盘\n\n## 执行清单\n\n- [ ] 检查系统可用容量\n- [ ] 清理无用预装与缓存\n- [ ] 预留直播素材和日志空间",
|
||||
"videoUrl": "https://minioweb.hackrobot.cn/hackrobot/2. 安卓扩容_20260326_095426_1002.mp4"
|
||||
},
|
||||
"1-0": {
|
||||
"markdown": "# 03 竖屏直播必备:系统显示方向设置\n\n对应电子书章节:`业务场景:无人直播` 中摄像头与画面链路实践。\n\n## 为什么先做竖屏\n\n- TikTok 直播以竖屏为主\n- 先固定方向,后续采集与推流才稳定\n\n## 操作要点\n\n1. 在系统中关闭自动旋转\n2. 固定竖屏分辨率\n3. 使用测试素材验证采集画面方向\n\n## 验证标准\n\n- 开播预览无横竖屏抖动\n- 推流端与手机端画面方向一致",
|
||||
"videoUrl": "https://minioweb.hackrobot.cn/hackrobot/3. 设置竖屏_20260326_095414_979.mp4"
|
||||
},
|
||||
"1-1": {
|
||||
"markdown": "# 04 一次搞定 Root:Magisk + 模块安装\n\n对应电子书章节:`获取root权限` 与 `安装lsposed环境`。\n\n## 实操流程\n\n1. 从镜像提取 `boot.img`\n2. 在安卓端用 Magisk 修补镜像\n3. 通过刷写工具或 adb dd 回刷补丁镜像\n4. 重启验证 Root 生效\n\n## 关键命令(电子书同源)\n\n```bash\nadb shell\nsu\ndd if=/sdcard/magisk_patched.img of=/dev/block/mmcblk0p9 bs=4M\nsync\nreboot\n```\n\n## 后续动作\n\n- 安装 LSPosed,准备模块化能力\n- 记录可回滚镜像,避免系统损坏",
|
||||
"videoUrl": "https://minioweb.hackrobot.cn/hackrobot/4. 安装magisk以及模块_20260326_095427_1018.mp4"
|
||||
},
|
||||
"1-2": {
|
||||
"markdown": "# 05 防风控第一步:机型参数改造\n\n对应电子书章节:`修改机型`。\n\n## 目标\n\n- 降低平台对异常设备指纹的识别概率\n- 让账号环境更贴近真实移动设备\n\n## 建议流程\n\n1. 安装改机工具并授予 Root 权限\n2. 进入设备信息伪装,选择目标机型\n3. 重启系统并重新检查参数是否生效\n\n## 风险提示\n\n- 机型参数、IP、GPS 需要协同一致\n- 不建议频繁切换机型,避免触发异常行为",
|
||||
"videoUrl": "https://minioweb.hackrobot.cn/hackrobot/5. 修改机型参数_20260326_095438_1051.mp4"
|
||||
},
|
||||
"2-0": {
|
||||
"markdown": "# 06 降低风控命中:GPS 精准定位\n\n对应电子书章节:`GPS定位`。\n\n## 为什么必须做\n\n- GPS 与 IP 国家/城市不一致,容易触发风控\n- 直播账号稳定性与定位一致性强相关\n\n## 操作步骤\n\n1. 安装定位工具并配置 Mock Location\n2. 通过地图搜索目标区域并手动校准\n3. 启动模拟定位后再打开直播 App\n\n## 检查清单\n\n- [ ] GPS 城市与代理 IP 所在地区一致\n- [ ] 时间时区与账号地区一致\n- [ ] 开播前再次确认定位未漂移",
|
||||
"videoUrl": "https://minioweb.hackrobot.cn/hackrobot/6. gps定位_20260326_095430_1031.mp4"
|
||||
},
|
||||
"2-1": {
|
||||
"markdown": "# 07 无人直播入门:录播素材循环推流\n\n对应电子书章节:`业务场景:无人直播` 与 `录播mp4素材`。\n\n## 核心链路\n\n1. Linux 辅助板播放素材\n2. HDMI 输出到采集卡\n3. 采集卡通过 USB 输入安卓板,识别为摄像头\n\n## 示例命令\n\n```bash\nffplay -loop 0 -vf \"transpose=2,scale=640:-1,format=yuv420p\" -fs -threads 6 xxx.mp4\n```\n\n## 实战建议\n\n- 先用短素材跑通链路,再换长素材\n- 分辨率和码率不要一步拉满,先求稳定",
|
||||
"videoUrl": "https://minioweb.hackrobot.cn/hackrobot/7无人直播-录播_20260326_100335_2814.mp4"
|
||||
},
|
||||
"2-2": {
|
||||
"markdown": "# 08 TikTok 实战开播:完整流程演示\n\n对应电子书章节:`业务场景:无人直播` 与 `辅助板linux配置`。\n\n## 开播前准备\n\n- 辅助板已安装视频/音频驱动与 ffmpeg\n- 安卓端已完成 Root、改机、定位\n- 直播账号完成基础养号与资料设置\n\n## 标准流程\n\n1. 启动素材源或直播流\n2. 在 TikTok 端预览并确认摄像头输入\n3. 开播后观察前 10 分钟数据与风控提示\n\n## 观察重点\n\n- 是否弹验证窗口\n- 是否出现明显限流\n- 进房、停留、互动是否正常",
|
||||
"videoUrl": "https://minioweb.hackrobot.cn/hackrobot/8. tiktok直播_20260326_095441_1064.mp4"
|
||||
},
|
||||
"2-3": {
|
||||
"markdown": "# 09 TikTok 进阶优化:稳定推流与细节调优\n\n对应电子书章节:`obs推流/srs拉流`。\n\n## 进阶目标\n\n- 降低延迟与卡顿\n- 提升长时段推流稳定性\n\n## SRS 部署思路\n\n- 在辅助板部署 SRS\n- OBS 走 SRT 推流,辅助板本地拉流喂给安卓摄像头\n\n## 拉流脚本示例\n\n```bash\nffplay -fflags nobuffer -flags low_delay -framedrop \n-probesize 32 -analyzeduration 0 -sync ext -infbuf \n-vf \"setpts=PTS-STARTPTS\" \n'srt://127.0.0.1:10080?streamid=#!::r=live/livestream,m=request&latency=10'\n```",
|
||||
"videoUrl": "https://minioweb.hackrobot.cn/hackrobot/9. tiktok直播-2_20260326_095403_943.mp4"
|
||||
},
|
||||
"3-0": {
|
||||
"markdown": "# 10 软路由与科学上网\n\n对应电子书章节:`魔法上网`。\n\n## 为什么是软路由优先\n\n- 电子书实测:代理 APK 在部分场景难过风控\n- 软路由链路更稳定,适合长期业务运行\n\n## 推荐组合\n\n- 海外 VPS(中转)\n- 静态住宅 IP(落地)\n- Clash Meta(链式代理)\n\n## 操作顺序\n\n1. 购买 VPS 与域名\n2. 购买静态住宅 IP\n3. 配置链式代理与策略路由",
|
||||
"videoUrl": "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
|
||||
},
|
||||
"3-1": {
|
||||
"markdown": "# 11 静态住宅 IP 配置\n\n对应电子书章节:`静态住宅ip` 与 `链式代理`。\n\n## 核心原则\n\n- 便宜节点通常不能国内直连,必须走中转\n- IP、GPS、机型要形成一致的“环境画像”\n\n## 配置要点\n\n- 落地节点使用静态住宅 IP\n- 中转与落地分层,避免单点故障\n- 业务账号固定绑定线路,不频繁切换\n\n## 验证指标\n\n- DNS、出口国家、时区一致\n- 连续开播无大规模验证弹窗",
|
||||
"videoUrl": "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
|
||||
},
|
||||
"4-0": {
|
||||
"markdown": "# 12 HDMI 辅助板方案\n\n对应电子书章节:`如果需要直播` 与 `业务场景:无人直播`。\n\n## 方案价值\n\n- 把外部视频信号稳定送进安卓端“摄像头”\n- 满足 TikTok 对移动端直播形态的偏好\n\n## 硬件清单\n\n- Linux 辅助板(如 R3S)\n- 视频采集卡\n- HDMI 线\n- 安卓开发板(主控)\n\n## 连接示意\n\n`素材源 -> HDMI -> 采集卡 -> 安卓板 USB`\n\n确认安卓相机可预览即代表链路打通。",
|
||||
"videoUrl": "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
|
||||
},
|
||||
"4-1": {
|
||||
"markdown": "# 13 多设备群控与远控\n\n对应电子书章节:`远程控制`、`内网穿透 frp`、`应用多开/系统多开`。\n\n## 目标\n\n- 一台电脑管理多台安卓设备\n- 降低人工重复操作成本\n\n## 常见工具链\n\n- qtscrcpy / escrcpy:图形远控与群控\n- frp-panel:外网访问与设备穿透\n- 安卓虚拟机:低成本扩展多开能力\n\n## 交付标准\n\n- 可以批量连接设备并执行统一操作\n- 关键节点支持日志与异常回溯",
|
||||
"videoUrl": "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
|
||||
}
|
||||
}
|
||||
155
apps/miniprogram/h5/src/data/vipTopics.ts
Normal file
155
apps/miniprogram/h5/src/data/vipTopics.ts
Normal file
@ -0,0 +1,155 @@
|
||||
/**
|
||||
* VIP 专题配置 — 对照 src/modules/vip/app/topic/config.ts
|
||||
*/
|
||||
import { VIP_COURSE_MODULES } from './vipCourse'
|
||||
|
||||
export type VipTopicId = 'cloudphone' | 'livestream' | 'indie' | 'aiagent'
|
||||
|
||||
export type VipTopicConfig = {
|
||||
id: VipTopicId
|
||||
icon: string
|
||||
title: string
|
||||
subtitle: string
|
||||
desc: string
|
||||
stats: { value: string; label: string }[]
|
||||
/** 空数组 = 筹备中;undefined = 用云手机全课纲 */
|
||||
moduleIndices?: number[]
|
||||
}
|
||||
|
||||
export type VipTopicLesson = {
|
||||
name: string
|
||||
duration: string
|
||||
/** 对应云手机课索引,用于原生课时页 */
|
||||
moduleIndex: number
|
||||
lessonIndex: number
|
||||
}
|
||||
|
||||
export type VipTopicModule = {
|
||||
emoji: string
|
||||
title: string
|
||||
lessons: VipTopicLesson[]
|
||||
}
|
||||
|
||||
export const VIP_TOPIC_CONFIGS: Record<VipTopicId, VipTopicConfig> = {
|
||||
cloudphone: {
|
||||
id: 'cloudphone',
|
||||
icon: '☁️',
|
||||
title: '云手机',
|
||||
subtitle: '低成本自建云手机,TikTok/YouTube 运营搭建指南',
|
||||
desc: '用开源硬件打造云手机,Redroid、AOSP、ffmpeg、SRS,从零搭建无人直播工作室',
|
||||
stats: [
|
||||
{ value: '13', label: '节实战课程' },
|
||||
{ value: '170+', label: '分钟视频' },
|
||||
{ value: '5', label: '大模块' },
|
||||
],
|
||||
},
|
||||
livestream: {
|
||||
id: 'livestream',
|
||||
icon: '📺',
|
||||
title: '无人直播',
|
||||
subtitle: 'TikTok/YouTube 无人直播,24 小时自动化',
|
||||
desc: 'ffmpeg 拉流转推、SRS 直播服务器、油猴脚本自动化,实现 24 小时无人值守推流',
|
||||
stats: [
|
||||
{ value: '7', label: '节核心课程' },
|
||||
{ value: '100+', label: '分钟视频' },
|
||||
{ value: '2', label: '大模块' },
|
||||
],
|
||||
},
|
||||
indie: {
|
||||
id: 'indie',
|
||||
icon: '🛠️',
|
||||
title: '独立开发',
|
||||
subtitle: '从想法到产品,独立开发者全流程指南',
|
||||
desc: '',
|
||||
stats: [
|
||||
{ value: '—', label: '课程筹备中' },
|
||||
{ value: '—', label: '内容策划中' },
|
||||
],
|
||||
moduleIndices: [],
|
||||
},
|
||||
aiagent: {
|
||||
id: 'aiagent',
|
||||
icon: '🤖',
|
||||
title: 'AI Agent',
|
||||
subtitle: 'AIGC 与智能体,Vibe Coding 跨界创造',
|
||||
desc: '',
|
||||
stats: [
|
||||
{ value: '—', label: '课程筹备中' },
|
||||
{ value: '—', label: '内容策划中' },
|
||||
],
|
||||
moduleIndices: [],
|
||||
},
|
||||
}
|
||||
|
||||
/** 无人直播课纲 — 对照 topic/config LIVESTREAM_CURRICULUM */
|
||||
const LIVESTREAM_MODULES: VipTopicModule[] = [
|
||||
{
|
||||
emoji: '🎯',
|
||||
title: '策略篇 · 账号定位',
|
||||
lessons: [
|
||||
{ name: '01 赛道选择与账号人设设计', duration: '09:30', moduleIndex: 1, lessonIndex: 0 },
|
||||
{ name: '02 起号期内容与直播节奏', duration: '11:20', moduleIndex: 1, lessonIndex: 1 },
|
||||
],
|
||||
},
|
||||
{
|
||||
emoji: '🧩',
|
||||
title: '执行篇 · 素材与脚本',
|
||||
lessons: [
|
||||
{ name: '03 直播素材筛选与版权避坑', duration: '12:10', moduleIndex: 2, lessonIndex: 0 },
|
||||
{ name: '04 开播话术与互动脚本模板', duration: '10:45', moduleIndex: 2, lessonIndex: 1 },
|
||||
],
|
||||
},
|
||||
{
|
||||
emoji: '📈',
|
||||
title: '增长篇 · 复盘优化',
|
||||
lessons: [
|
||||
{ name: '05 流量数据复盘与调优闭环', duration: '13:15', moduleIndex: 3, lessonIndex: 0 },
|
||||
{ name: '06 多账号矩阵扩展方法', duration: '14:00', moduleIndex: 3, lessonIndex: 1 },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
export function getVipTopicConfig(topicId: string): VipTopicConfig | null {
|
||||
return VIP_TOPIC_CONFIGS[topicId as VipTopicId] ?? null
|
||||
}
|
||||
|
||||
export function getVipTopicCurriculum(topicId: string): {
|
||||
modules: VipTopicModule[]
|
||||
hasContent: boolean
|
||||
} {
|
||||
const config = getVipTopicConfig(topicId)
|
||||
if (!config) return { modules: [], hasContent: false }
|
||||
|
||||
if (topicId === 'livestream') {
|
||||
return { modules: LIVESTREAM_MODULES, hasContent: true }
|
||||
}
|
||||
|
||||
if (config.moduleIndices !== undefined && config.moduleIndices.length === 0) {
|
||||
return { modules: [], hasContent: false }
|
||||
}
|
||||
|
||||
const indices =
|
||||
config.moduleIndices ?? VIP_COURSE_MODULES.map((_, i) => i)
|
||||
|
||||
const modules: VipTopicModule[] = indices
|
||||
.map((i) => VIP_COURSE_MODULES[i])
|
||||
.filter(Boolean)
|
||||
.map((m) => ({
|
||||
emoji: m.emoji,
|
||||
title: m.title,
|
||||
lessons: m.lessons.map((l) => ({
|
||||
name: l.name,
|
||||
duration: l.duration,
|
||||
moduleIndex: l.moduleIndex,
|
||||
lessonIndex: l.lessonIndex,
|
||||
})),
|
||||
}))
|
||||
|
||||
return { modules, hasContent: modules.length > 0 }
|
||||
}
|
||||
|
||||
export function resolveTopicId(raw?: string): VipTopicId {
|
||||
const id = String(raw || 'cloudphone').trim()
|
||||
if (id in VIP_TOPIC_CONFIGS) return id as VipTopicId
|
||||
return 'cloudphone'
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* 社区首页收敛:仅顶栏 + Hero;「加群」→ 公众号二维码。
|
||||
* 社区首页收敛:仅顶栏 + Hero;「加群」按 flags.joinGroupAction 弹窗或跳 VIP。
|
||||
* Hero 视觉:社交星座网(区别于门户首页地球)。对齐 Next `/community`。
|
||||
*/
|
||||
import { View, Button } from '@tarojs/components'
|
||||
@ -13,6 +13,7 @@ import { MiniModuleGate } from '@/components/MiniModuleGate'
|
||||
import { useNomadroTheme } from '@/utils/h5Theme'
|
||||
import { usePageShare, markPageShare } from '@/utils/pageShare'
|
||||
import { getSafeAreaMetrics } from '@/utils/safeArea'
|
||||
import { getCachedRemoteConfig, loadRemoteConfig } from '@/services/remoteConfig'
|
||||
import { usePageTrack } from '@/hooks/usePageTrack'
|
||||
import { trackTap } from '@/utils/track'
|
||||
import './index.scss'
|
||||
@ -92,6 +93,25 @@ function HomePageInner() {
|
||||
[safe],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
void loadRemoteConfig(true)
|
||||
}, [])
|
||||
|
||||
async function onJoinClick() {
|
||||
// 点击前强制拉最新远程配置(后台 VIP「加群→跳转」实时生效)
|
||||
try {
|
||||
await loadRemoteConfig(true)
|
||||
} catch {
|
||||
/* 用缓存 */
|
||||
}
|
||||
const action = getCachedRemoteConfig().flags.joinGroupAction
|
||||
if (action === 'vip') {
|
||||
void Taro.navigateTo({ url: '/pages/vip/index' })
|
||||
return
|
||||
}
|
||||
setJoinOpen(true)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let locale: 'zh' | 'en' = 'zh'
|
||||
try {
|
||||
@ -212,7 +232,7 @@ function HomePageInner() {
|
||||
|
||||
<H5Box className="hero-bottom">
|
||||
<H5Box className="hero-actions">
|
||||
<Button className="btn btn-primary" onClick={trackTap('加群', () => setJoinOpen(true))}>
|
||||
<Button className="btn btn-primary" onClick={trackTap('加群', onJoinClick)}>
|
||||
👥 加群
|
||||
</Button>
|
||||
</H5Box>
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
/**
|
||||
* 对齐门户 components/sections/hero.tsx(结构 / PORTALS / 开发快捷入口)
|
||||
* H5 关键布局用原生 div(Taro View 自定义元素会弄塌 grid/绝对定位)。
|
||||
* H5 真布局用原生 div(Taro View 自定义元素会弄塌 grid/绝对定位)。
|
||||
*/
|
||||
import { useEffect, useMemo, useState, type CSSProperties, type ReactNode } from 'react'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import Taro, { usePageScroll } from '@tarojs/taro'
|
||||
import Taro, { useDidShow, usePageScroll } from '@tarojs/taro'
|
||||
import {
|
||||
isModuleEnabled,
|
||||
loadRemoteConfig,
|
||||
subscribeRemoteConfig,
|
||||
} from '@/services/remoteConfig'
|
||||
import type { NomadroRemoteConfig } from '@/data/remoteConfig.defaults'
|
||||
import { applyH5Theme, useNomadroTheme } from '@/utils/h5Theme'
|
||||
@ -16,7 +17,6 @@ import { usePageShare, markPageShare } from '@/utils/pageShare'
|
||||
import { getSafeAreaMetrics } from '@/utils/safeArea'
|
||||
import { usePageTrack } from '@/hooks/usePageTrack'
|
||||
import './index.scss'
|
||||
|
||||
type PortalId = 'nav' | 'book' | 'community' | 'vip' | 'game'
|
||||
|
||||
type Portal = {
|
||||
@ -167,10 +167,16 @@ function IndexPage() {
|
||||
const [navScrolled, setNavScrolled] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
loadRemoteConfig().then((r) => setConfig(r.config))
|
||||
const unsub = subscribeRemoteConfig((r) => setConfig(r.config))
|
||||
void loadRemoteConfig(true).then((r) => setConfig(r.config))
|
||||
applyH5Theme(theme)
|
||||
return unsub
|
||||
}, [])
|
||||
|
||||
useDidShow(() => {
|
||||
void loadRemoteConfig(true).then((r) => setConfig(r.config))
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
applyH5Theme(theme)
|
||||
}, [theme])
|
||||
|
||||
7
apps/miniprogram/h5/src/pages/vip-course/index.config.ts
Normal file
7
apps/miniprogram/h5/src/pages/vip-course/index.config.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export default definePageConfig({
|
||||
navigationStyle: 'custom',
|
||||
navigationBarTitleText: '视频课程',
|
||||
navigationBarBackgroundColor: '#0c0c0f',
|
||||
navigationBarTextStyle: 'white',
|
||||
backgroundColor: '#0c0c0f',
|
||||
})
|
||||
617
apps/miniprogram/h5/src/pages/vip-course/index.scss
Normal file
617
apps/miniprogram/h5/src/pages/vip-course/index.scss
Normal file
@ -0,0 +1,617 @@
|
||||
/* 小程序真 px(已加入 weapp pxExclude)— 适配胶囊 + 可读字号 + 44px 热区 */
|
||||
.vip-topic {
|
||||
--vt-bg: #0c0c0f;
|
||||
--vt-fg: #f5f5f7;
|
||||
--vt-muted: #9ca3af;
|
||||
--vt-card: rgba(255, 255, 255, 0.045);
|
||||
--vt-border: rgba(255, 255, 255, 0.1);
|
||||
--vt-accent: #f59e0b;
|
||||
--vt-accent-fg: #111;
|
||||
min-height: 100vh;
|
||||
background: var(--vt-bg);
|
||||
color: var(--vt-fg);
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue',
|
||||
'Noto Sans SC', 'Microsoft YaHei', sans-serif;
|
||||
font-size: 15px;
|
||||
line-height: 1.5;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
.vip-topic[data-theme='light'] {
|
||||
--vt-bg: #f7f7f8;
|
||||
--vt-fg: #111827;
|
||||
--vt-muted: #6b7280;
|
||||
--vt-card: #fff;
|
||||
--vt-border: rgba(0, 0, 0, 0.08);
|
||||
--vt-accent: #d97706;
|
||||
--vt-accent-fg: #fff;
|
||||
}
|
||||
|
||||
/* —— 顶栏:品牌 + 主题;CTA 收短,避开胶囊 —— */
|
||||
.vip-topic-header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 50;
|
||||
border-bottom: 1px solid var(--vt-border);
|
||||
background: rgba(12, 12, 15, 0.96);
|
||||
}
|
||||
.vip-topic[data-theme='light'] .vip-topic-header {
|
||||
background: rgba(247, 247, 248, 0.96);
|
||||
}
|
||||
.vip-topic-header-inner {
|
||||
min-height: 44px;
|
||||
height: 44px;
|
||||
padding: 0 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.vip-topic-brand {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 44px;
|
||||
color: var(--vt-fg);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.vip-topic-header-nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.vip-topic-theme {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
}
|
||||
.vip-topic-home {
|
||||
display: none; /* 小程序用面包屑/返回,不再挤顶栏 */
|
||||
}
|
||||
.vip-topic-header-cta {
|
||||
min-height: 32px;
|
||||
padding: 0 12px;
|
||||
border-radius: 999px;
|
||||
background: var(--vt-accent);
|
||||
color: var(--vt-accent-fg);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 32px;
|
||||
max-width: 88px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.vip-topic-scroll {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.vip-topic-crumb {
|
||||
padding: 12px 16px 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
color: var(--vt-muted);
|
||||
}
|
||||
.vip-topic-crumb-link {
|
||||
color: var(--vt-muted);
|
||||
}
|
||||
.vip-topic-crumb-sep {
|
||||
color: var(--vt-muted);
|
||||
}
|
||||
.vip-topic-crumb-cur {
|
||||
color: var(--vt-fg);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* —— Hero:手机可读层级 —— */
|
||||
.vip-topic-hero {
|
||||
position: relative;
|
||||
padding: 20px 20px 28px;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
.vip-topic-hero-glow {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: -30%;
|
||||
width: 140%;
|
||||
height: 70%;
|
||||
transform: translateX(-50%);
|
||||
background: radial-gradient(
|
||||
ellipse 80% 50% at 50% 20%,
|
||||
rgba(245, 158, 11, 0.16),
|
||||
transparent 70%
|
||||
);
|
||||
pointer-events: none;
|
||||
}
|
||||
.vip-topic-hero-title {
|
||||
position: relative;
|
||||
display: block;
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0;
|
||||
margin-bottom: 10px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
.vip-topic-hero-sub {
|
||||
position: relative;
|
||||
display: block;
|
||||
font-size: 15px;
|
||||
color: var(--vt-muted);
|
||||
line-height: 1.5;
|
||||
margin-bottom: 10px;
|
||||
padding: 0 4px;
|
||||
}
|
||||
.vip-topic-hero-desc {
|
||||
position: relative;
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
color: var(--vt-muted);
|
||||
line-height: 1.6;
|
||||
margin: 0 auto 22px;
|
||||
padding: 0 4px;
|
||||
max-width: 100%;
|
||||
}
|
||||
.vip-topic-stats {
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin: 0 0 22px;
|
||||
padding: 0 4px;
|
||||
}
|
||||
.vip-topic-stat {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
min-width: 0;
|
||||
}
|
||||
.vip-topic-stat-value {
|
||||
display: block;
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
color: var(--vt-accent);
|
||||
line-height: 1.2;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.vip-topic-stat-label {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
font-size: 11px;
|
||||
line-height: 1.3;
|
||||
color: var(--vt-muted);
|
||||
}
|
||||
.vip-topic-hero-cta {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
max-width: 280px;
|
||||
margin: 0 auto;
|
||||
min-height: 48px;
|
||||
padding: 0 24px;
|
||||
border-radius: 999px;
|
||||
background: var(--vt-accent);
|
||||
color: var(--vt-accent-fg);
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.vip-topic-prep {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.vip-topic-prep-ico {
|
||||
display: block;
|
||||
font-size: 40px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.vip-topic-prep-txt {
|
||||
font-size: 14px;
|
||||
color: var(--vt-muted);
|
||||
}
|
||||
.vip-topic-progress {
|
||||
position: relative;
|
||||
margin: 18px auto 0;
|
||||
max-width: 240px;
|
||||
width: 100%;
|
||||
}
|
||||
.vip-topic-progress-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 12px;
|
||||
color: var(--vt-muted);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.vip-topic-progress-bar {
|
||||
height: 6px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
overflow: hidden;
|
||||
}
|
||||
.vip-topic[data-theme='light'] .vip-topic-progress-bar {
|
||||
background: rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
.vip-topic-progress-fill {
|
||||
height: 100%;
|
||||
border-radius: 999px;
|
||||
background: var(--vt-accent);
|
||||
}
|
||||
|
||||
/* —— 课纲 —— */
|
||||
.vip-topic-curr {
|
||||
border-top: 1px solid var(--vt-border);
|
||||
padding: 24px 12px 8px;
|
||||
}
|
||||
.vip-topic-curr-title {
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 6px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.vip-topic-curr-sub {
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
color: var(--vt-muted);
|
||||
margin-bottom: 16px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.vip-topic-card {
|
||||
margin-bottom: 10px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid var(--vt-border);
|
||||
background: var(--vt-card);
|
||||
overflow: hidden;
|
||||
}
|
||||
.vip-topic-card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
min-height: 48px;
|
||||
padding: 12px 14px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.vip-topic-card-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
line-height: 1.35;
|
||||
min-width: 0;
|
||||
}
|
||||
.vip-topic-chevron {
|
||||
display: inline-block;
|
||||
font-size: 10px;
|
||||
color: var(--vt-muted);
|
||||
transition: transform 0.15s ease;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.vip-topic-chevron.is-open {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
.vip-topic-card-count {
|
||||
font-size: 12px;
|
||||
color: var(--vt-muted);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.vip-topic-lesson {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
min-height: 56px;
|
||||
padding: 12px 14px;
|
||||
border-top: 1px solid var(--vt-border);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.vip-topic-lesson.is-locked {
|
||||
opacity: 0.72;
|
||||
}
|
||||
.vip-topic-lesson-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.vip-topic-lesson-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
.vip-topic-star {
|
||||
font-size: 14px;
|
||||
flex-shrink: 0;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
text-align: center;
|
||||
margin-top: -2px;
|
||||
}
|
||||
.vip-topic-lesson-name {
|
||||
font-size: 14px;
|
||||
line-height: 1.45;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
word-break: break-word;
|
||||
}
|
||||
.vip-topic-updating,
|
||||
.vip-topic-lock {
|
||||
font-size: 12px;
|
||||
flex-shrink: 0;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.vip-topic-done {
|
||||
flex-shrink: 0;
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
background: rgba(34, 197, 94, 0.2);
|
||||
color: #4ade80;
|
||||
}
|
||||
.vip-topic-lesson-dur {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
margin-left: 36px;
|
||||
font-size: 12px;
|
||||
color: var(--vt-muted);
|
||||
line-height: 1.3;
|
||||
}
|
||||
.vip-topic-lesson-arrow {
|
||||
font-size: 16px;
|
||||
color: var(--vt-accent);
|
||||
flex-shrink: 0;
|
||||
width: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.vip-topic-coming {
|
||||
padding: 40px 24px;
|
||||
text-align: center;
|
||||
border-top: 1px solid var(--vt-border);
|
||||
}
|
||||
.vip-topic-coming-ico {
|
||||
display: block;
|
||||
font-size: 40px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.vip-topic-coming-title {
|
||||
display: block;
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.vip-topic-coming-desc {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
color: var(--vt-muted);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.vip-topic-footer {
|
||||
border-top: 1px solid var(--vt-border);
|
||||
padding: 20px 16px calc(28px + env(safe-area-inset-bottom, 0px));
|
||||
text-align: center;
|
||||
}
|
||||
.vip-topic-footer-links {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 28px;
|
||||
margin-bottom: 12px;
|
||||
font-size: 14px;
|
||||
color: var(--vt-muted);
|
||||
min-height: 44px;
|
||||
align-items: center;
|
||||
}
|
||||
.vip-topic-footer-copy {
|
||||
font-size: 12px;
|
||||
color: var(--vt-muted);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.vip-topic-missing {
|
||||
display: block;
|
||||
padding: 80px 24px 24px;
|
||||
text-align: center;
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.vip-topic-modal {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 70;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
background: rgba(0, 0, 0, 0.55);
|
||||
}
|
||||
.vip-topic-modal-card {
|
||||
width: 100%;
|
||||
max-width: 340px;
|
||||
border-radius: 14px;
|
||||
border: 1px solid rgba(245, 158, 11, 0.3);
|
||||
background: #16161a;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.vip-topic[data-theme='light'] .vip-topic-modal-card {
|
||||
background: #fff;
|
||||
}
|
||||
.vip-topic-modal-ico {
|
||||
display: block;
|
||||
font-size: 26px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.vip-topic-modal-title {
|
||||
display: block;
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.vip-topic-modal-body {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
color: var(--vt-muted);
|
||||
line-height: 1.55;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.vip-topic-modal-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
.vip-topic-modal-btn {
|
||||
min-height: 40px;
|
||||
padding: 0 16px;
|
||||
border-radius: 999px;
|
||||
background: var(--vt-accent);
|
||||
color: var(--vt-accent-fg);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 40px;
|
||||
}
|
||||
.vip-topic-modal-btn.ghost {
|
||||
background: transparent;
|
||||
border: 1px solid var(--vt-border);
|
||||
color: var(--vt-muted);
|
||||
}
|
||||
|
||||
/* cloudphone Audience / Benefits / FAQ */
|
||||
.vip-topic-block {
|
||||
border-top: 1px solid var(--vt-border);
|
||||
padding: 24px 14px 8px;
|
||||
}
|
||||
.vip-topic-block-title {
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 6px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.vip-topic-block-sub {
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
color: var(--vt-muted);
|
||||
margin-bottom: 16px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.vip-topic-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
.vip-topic-grid-card {
|
||||
width: calc(50% - 5px);
|
||||
box-sizing: border-box;
|
||||
padding: 14px 12px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid var(--vt-border);
|
||||
background: var(--vt-card);
|
||||
}
|
||||
.vip-topic-grid-emoji {
|
||||
display: block;
|
||||
font-size: 22px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.vip-topic-grid-name {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 6px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.vip-topic-grid-desc {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: var(--vt-muted);
|
||||
line-height: 1.45;
|
||||
}
|
||||
.vip-topic-benefit {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: flex-start;
|
||||
padding: 14px 12px;
|
||||
margin-bottom: 8px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid var(--vt-border);
|
||||
background: var(--vt-card);
|
||||
}
|
||||
.vip-topic-benefit-num {
|
||||
flex-shrink: 0;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
text-align: center;
|
||||
border-radius: 999px;
|
||||
background: rgba(245, 158, 11, 0.18);
|
||||
color: var(--vt-accent);
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.vip-topic-benefit-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.vip-topic-benefit-title {
|
||||
display: block;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 4px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.vip-topic-benefit-desc {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: var(--vt-muted);
|
||||
line-height: 1.45;
|
||||
}
|
||||
.vip-topic-faq {
|
||||
margin-bottom: 8px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid var(--vt-border);
|
||||
background: var(--vt-card);
|
||||
overflow: hidden;
|
||||
}
|
||||
.vip-topic-faq-q {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
min-height: 48px;
|
||||
padding: 12px 14px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.vip-topic-faq-q-text {
|
||||
flex: 1;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.vip-topic-faq-chevron {
|
||||
flex-shrink: 0;
|
||||
font-size: 18px;
|
||||
color: var(--vt-muted);
|
||||
width: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
.vip-topic-faq-a {
|
||||
display: block;
|
||||
padding: 0 14px 14px;
|
||||
font-size: 13px;
|
||||
color: var(--vt-muted);
|
||||
line-height: 1.55;
|
||||
}
|
||||
415
apps/miniprogram/h5/src/pages/vip-course/index.tsx
Normal file
415
apps/miniprogram/h5/src/pages/vip-course/index.tsx
Normal file
@ -0,0 +1,415 @@
|
||||
/**
|
||||
* VIP 专题 / 云手机课 — 复刻 nomadvip
|
||||
* - /topic/[id]:Header + Breadcrumb + Hero + Curriculum
|
||||
* - /cloudphone:再加 Audience + Benefits + FAQ
|
||||
*/
|
||||
import { View, Text, ScrollView } from '@tarojs/components'
|
||||
import Taro, { useRouter } from '@tarojs/taro'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { H5Box, H5Txt } from '../../components/H5Box'
|
||||
import {
|
||||
getVipTopicConfig,
|
||||
getVipTopicCurriculum,
|
||||
resolveTopicId,
|
||||
} from '../../data/vipTopics'
|
||||
import {
|
||||
CLOUDPHONE_AUDIENCE,
|
||||
CLOUDPHONE_BENEFITS,
|
||||
CLOUDPHONE_CURRICULUM_META,
|
||||
CLOUDPHONE_FAQ,
|
||||
CLOUDPHONE_HERO,
|
||||
} from '../../data/vipCloudphoneLanding'
|
||||
import { goPage } from '../../utils/nav'
|
||||
import { resolveVipAccess } from '../../utils/vipAccess'
|
||||
import {
|
||||
getLastWatched,
|
||||
getProgress,
|
||||
getBookmarks,
|
||||
getCompletedLessons,
|
||||
isBookmarked,
|
||||
toggleBookmark,
|
||||
} from '../../utils/vipLearning'
|
||||
import { getSafeAreaMetrics } from '../../utils/safeArea'
|
||||
import { toggleH5Theme, useNomadroTheme } from '@/utils/h5Theme'
|
||||
import './index.scss'
|
||||
|
||||
export default function VipCoursePage() {
|
||||
const theme = useNomadroTheme()
|
||||
const router = useRouter()
|
||||
const topicId = resolveTopicId(router.params?.id)
|
||||
const isCloudphone = topicId === 'cloudphone'
|
||||
const config = getVipTopicConfig(topicId)
|
||||
const curriculum = useMemo(() => getVipTopicCurriculum(topicId), [topicId])
|
||||
const totalLessons = curriculum.modules.reduce((s, m) => s + m.lessons.length, 0)
|
||||
|
||||
const [isVip, setIsVip] = useState(false)
|
||||
const [ready, setReady] = useState(false)
|
||||
const [expanded, setExpanded] = useState<Record<number, boolean>>({})
|
||||
const [bookmarks, setBookmarks] = useState<Set<string>>(() => getBookmarks())
|
||||
const [completed, setCompleted] = useState<Set<string>>(() => getCompletedLessons())
|
||||
const [last, setLast] = useState(() => getLastWatched())
|
||||
const [progress, setProgress] = useState(() => getProgress(totalLessons))
|
||||
const [updatingName, setUpdatingName] = useState('')
|
||||
const [faqOpen, setFaqOpen] = useState<number | null>(0)
|
||||
const safe = getSafeAreaMetrics()
|
||||
const headerPadRight = Math.max(safe.menuRightPad, 12)
|
||||
|
||||
const heroTitle = isCloudphone ? CLOUDPHONE_HERO.title : `${config?.icon || ''} ${config?.title || ''}`
|
||||
const heroSub = isCloudphone ? CLOUDPHONE_HERO.subtitle : config?.subtitle || ''
|
||||
const heroDesc = isCloudphone ? '' : config?.desc || ''
|
||||
const heroStats = isCloudphone ? CLOUDPHONE_HERO.stats : config?.stats || []
|
||||
const currTitle = isCloudphone ? CLOUDPHONE_CURRICULUM_META.title : '实战课程'
|
||||
const currSub = isCloudphone
|
||||
? CLOUDPHONE_CURRICULUM_META.subtitle
|
||||
: '从入门到进阶,完整学习路径'
|
||||
|
||||
useEffect(() => {
|
||||
Taro.setNavigationBarTitle({
|
||||
title: isCloudphone ? '云手机实战课' : config?.title || '视频课程',
|
||||
})
|
||||
void resolveVipAccess(true).then((ok) => {
|
||||
setIsVip(ok)
|
||||
setReady(true)
|
||||
})
|
||||
}, [config?.title, isCloudphone])
|
||||
|
||||
useEffect(() => {
|
||||
setExpanded(Object.fromEntries(curriculum.modules.map((_, i) => [i, i === 0])))
|
||||
setLast(getLastWatched())
|
||||
setProgress(getProgress(totalLessons))
|
||||
setBookmarks(getBookmarks())
|
||||
setCompleted(getCompletedLessons())
|
||||
}, [topicId, curriculum.modules, totalLessons])
|
||||
|
||||
if (!config) {
|
||||
return (
|
||||
<H5Box className="vip-topic" data-theme={theme}>
|
||||
<H5Txt className="vip-topic-missing">模块不存在</H5Txt>
|
||||
<View className="vip-topic-hero-cta" onClick={() => goPage('/pages/vip/index')}>
|
||||
<Text>← 返回首页</Text>
|
||||
</View>
|
||||
</H5Box>
|
||||
)
|
||||
}
|
||||
|
||||
const isLivestreamUpdating = topicId === 'livestream' && isVip
|
||||
const showPrep = (topicId === 'indie' || topicId === 'aiagent') && !curriculum.hasContent
|
||||
|
||||
function onEnroll() {
|
||||
goPage('/pages/vip/index')
|
||||
}
|
||||
|
||||
function onPrimaryCta() {
|
||||
if (!isVip) {
|
||||
onEnroll()
|
||||
return
|
||||
}
|
||||
if (last) {
|
||||
goPage(`/pages/vip-lesson/index?m=${last.moduleIndex}&l=${last.lessonIndex}`)
|
||||
return
|
||||
}
|
||||
const first = curriculum.modules[0]?.lessons[0]
|
||||
if (first) {
|
||||
goPage(`/pages/vip-lesson/index?m=${first.moduleIndex}&l=${first.lessonIndex}`)
|
||||
}
|
||||
}
|
||||
|
||||
function openLesson(m: number, l: number, name: string) {
|
||||
if (isLivestreamUpdating) {
|
||||
setUpdatingName(name)
|
||||
return
|
||||
}
|
||||
if (!isVip) {
|
||||
Taro.showModal({
|
||||
title: '会员专享',
|
||||
content: '开通 VIP 后可观看全部视频课程',
|
||||
confirmText: '立即报名',
|
||||
success: (r) => {
|
||||
if (r.confirm) onEnroll()
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
goPage(`/pages/vip-lesson/index?m=${m}&l=${l}`)
|
||||
}
|
||||
|
||||
function onToggleBookmark(m: number, l: number, e: { stopPropagation?: () => void }) {
|
||||
e.stopPropagation?.()
|
||||
toggleBookmark(m, l)
|
||||
setBookmarks(getBookmarks())
|
||||
}
|
||||
|
||||
const ctaLabel = !isVip
|
||||
? '立即报名 →'
|
||||
: last
|
||||
? '继续学习 →'
|
||||
: '进入课程 →'
|
||||
|
||||
const headerCta = !isVip ? '报名' : '进入'
|
||||
|
||||
return (
|
||||
<H5Box className="vip-topic" data-theme={theme}>
|
||||
<View
|
||||
className="vip-topic-header"
|
||||
style={{ paddingTop: `${safe.statusBarHeight}px` }}
|
||||
>
|
||||
<View className="vip-topic-header-inner" style={{ paddingRight: `${headerPadRight}px` }}>
|
||||
<Text className="vip-topic-brand" onClick={() => goPage('/pages/vip/index')}>
|
||||
🌍 异度星球
|
||||
</Text>
|
||||
<View className="vip-topic-header-nav">
|
||||
<Text className="vip-topic-theme" onClick={() => toggleH5Theme(theme)}>
|
||||
{theme === 'dark' ? '☀️' : '🌙'}
|
||||
</Text>
|
||||
<View
|
||||
className="vip-topic-header-cta"
|
||||
onClick={() => {
|
||||
if (!isVip) onEnroll()
|
||||
else onPrimaryCta()
|
||||
}}
|
||||
>
|
||||
<Text>{headerCta}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<ScrollView
|
||||
scrollY
|
||||
className="vip-topic-scroll"
|
||||
style={{ height: `calc(100vh - ${safe.statusBarHeight + 44}px)` }}
|
||||
enhanced
|
||||
showScrollbar
|
||||
>
|
||||
<View className="vip-topic-crumb">
|
||||
<Text className="vip-topic-crumb-link" onClick={() => goPage('/pages/vip/index')}>
|
||||
首页
|
||||
</Text>
|
||||
<Text className="vip-topic-crumb-sep"> / </Text>
|
||||
<Text className="vip-topic-crumb-link" onClick={() => goPage('/pages/vip/index')}>
|
||||
模块
|
||||
</Text>
|
||||
<Text className="vip-topic-crumb-sep"> / </Text>
|
||||
<Text className="vip-topic-crumb-cur">
|
||||
{isCloudphone ? '云手机' : config.title}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View className="vip-topic-hero">
|
||||
<View className="vip-topic-hero-glow" />
|
||||
<H5Txt className="vip-topic-hero-title">{heroTitle}</H5Txt>
|
||||
<H5Txt className="vip-topic-hero-sub">{heroSub}</H5Txt>
|
||||
{heroDesc ? <H5Txt className="vip-topic-hero-desc">{heroDesc}</H5Txt> : null}
|
||||
|
||||
<View className="vip-topic-stats">
|
||||
{heroStats.map((s) => (
|
||||
<View key={s.label} className="vip-topic-stat">
|
||||
<Text className="vip-topic-stat-value">{s.value}</Text>
|
||||
<Text className="vip-topic-stat-label">{s.label}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
|
||||
{showPrep ? (
|
||||
<View className="vip-topic-prep">
|
||||
<Text className="vip-topic-prep-ico">{config.icon}</Text>
|
||||
<Text className="vip-topic-prep-txt">课程筹备中,敬请期待</Text>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{curriculum.hasContent ? (
|
||||
<View className="vip-topic-hero-cta" onClick={onPrimaryCta}>
|
||||
<Text>{ready ? ctaLabel : '…'}</Text>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{isVip && progress.completed > 0 ? (
|
||||
<View className="vip-topic-progress">
|
||||
<View className="vip-topic-progress-row">
|
||||
<Text>学习进度</Text>
|
||||
<Text>
|
||||
{progress.completed}/{totalLessons} 节
|
||||
</Text>
|
||||
</View>
|
||||
<View className="vip-topic-progress-bar">
|
||||
<View
|
||||
className="vip-topic-progress-fill"
|
||||
style={{ width: `${progress.percent}%` }}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
{isCloudphone ? (
|
||||
<>
|
||||
<View className="vip-topic-block">
|
||||
<H5Txt className="vip-topic-block-title">{CLOUDPHONE_AUDIENCE.title}</H5Txt>
|
||||
<H5Txt className="vip-topic-block-sub">{CLOUDPHONE_AUDIENCE.subtitle}</H5Txt>
|
||||
<View className="vip-topic-grid">
|
||||
{CLOUDPHONE_AUDIENCE.items.map((it) => (
|
||||
<View key={it.title} className="vip-topic-grid-card">
|
||||
<Text className="vip-topic-grid-emoji">{it.emoji}</Text>
|
||||
<Text className="vip-topic-grid-name">{it.title}</Text>
|
||||
<Text className="vip-topic-grid-desc">{it.desc}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="vip-topic-block">
|
||||
<H5Txt className="vip-topic-block-title">{CLOUDPHONE_BENEFITS.title}</H5Txt>
|
||||
<H5Txt className="vip-topic-block-sub">{CLOUDPHONE_BENEFITS.subtitle}</H5Txt>
|
||||
{CLOUDPHONE_BENEFITS.items.map((it) => (
|
||||
<View key={it.num} className="vip-topic-benefit">
|
||||
<Text className="vip-topic-benefit-num">{it.num}</Text>
|
||||
<View className="vip-topic-benefit-body">
|
||||
<Text className="vip-topic-benefit-title">{it.title}</Text>
|
||||
<Text className="vip-topic-benefit-desc">{it.desc}</Text>
|
||||
</View>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
{curriculum.hasContent ? (
|
||||
<View className="vip-topic-curr">
|
||||
<H5Txt className="vip-topic-curr-title">{currTitle}</H5Txt>
|
||||
<H5Txt className="vip-topic-curr-sub">{currSub}</H5Txt>
|
||||
|
||||
{curriculum.modules.map((mod, mi) => {
|
||||
const open = expanded[mi] !== false
|
||||
return (
|
||||
<View key={mod.title} className="vip-topic-card">
|
||||
<View
|
||||
className="vip-topic-card-head"
|
||||
onClick={() => setExpanded((p) => ({ ...p, [mi]: !open }))}
|
||||
>
|
||||
<Text className="vip-topic-card-left">
|
||||
<Text className={`vip-topic-chevron${open ? ' is-open' : ''}`}>▶</Text>
|
||||
<Text>
|
||||
{mod.emoji} {mod.title}
|
||||
</Text>
|
||||
</Text>
|
||||
<Text className="vip-topic-card-count">{mod.lessons.length} 节</Text>
|
||||
</View>
|
||||
{open
|
||||
? mod.lessons.map((les) => {
|
||||
const unlocked = isVip && !isLivestreamUpdating
|
||||
const key = `${les.moduleIndex}-${les.lessonIndex}`
|
||||
const starred =
|
||||
bookmarks.has(key) ||
|
||||
isBookmarked(les.moduleIndex, les.lessonIndex)
|
||||
const done = completed.has(key)
|
||||
return (
|
||||
<View
|
||||
key={key}
|
||||
className={`vip-topic-lesson${!unlocked ? ' is-locked' : ''}`}
|
||||
onClick={() =>
|
||||
openLesson(les.moduleIndex, les.lessonIndex, les.name)
|
||||
}
|
||||
>
|
||||
<View className="vip-topic-lesson-main">
|
||||
<View className="vip-topic-lesson-row">
|
||||
<Text
|
||||
className="vip-topic-star"
|
||||
onClick={(e) =>
|
||||
onToggleBookmark(les.moduleIndex, les.lessonIndex, e)
|
||||
}
|
||||
>
|
||||
{starred ? '⭐' : '☆'}
|
||||
</Text>
|
||||
<Text className="vip-topic-lesson-name">{les.name}</Text>
|
||||
{done ? <Text className="vip-topic-done">✓</Text> : null}
|
||||
{isLivestreamUpdating ? (
|
||||
<Text className="vip-topic-updating">🛠️</Text>
|
||||
) : null}
|
||||
{!isVip ? <Text className="vip-topic-lock">🔒</Text> : null}
|
||||
</View>
|
||||
<Text className="vip-topic-lesson-dur">{les.duration}</Text>
|
||||
</View>
|
||||
<Text className="vip-topic-lesson-arrow">
|
||||
{isLivestreamUpdating ? '···' : '→'}
|
||||
</Text>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
: null}
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
) : (
|
||||
<View className="vip-topic-coming">
|
||||
<Text className="vip-topic-coming-ico">{config.icon}</Text>
|
||||
<Text className="vip-topic-coming-title">课程筹备</Text>
|
||||
<Text className="vip-topic-coming-desc">
|
||||
{config.subtitle || '内容策划中,敬请期待'}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{isCloudphone ? (
|
||||
<View className="vip-topic-block">
|
||||
<H5Txt className="vip-topic-block-title">{CLOUDPHONE_FAQ.title}</H5Txt>
|
||||
{CLOUDPHONE_FAQ.items.map((item, i) => {
|
||||
const open = faqOpen === i
|
||||
return (
|
||||
<View key={item.q} className="vip-topic-faq">
|
||||
<View
|
||||
className="vip-topic-faq-q"
|
||||
onClick={() => setFaqOpen(open ? null : i)}
|
||||
>
|
||||
<Text className="vip-topic-faq-q-text">{item.q}</Text>
|
||||
<Text className="vip-topic-faq-chevron">{open ? '−' : '+'}</Text>
|
||||
</View>
|
||||
{open ? <Text className="vip-topic-faq-a">{item.a}</Text> : null}
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
<View className="vip-topic-footer">
|
||||
<View className="vip-topic-footer-links">
|
||||
<Text onClick={() => goPage('/pages/vip/index')}>返回首页</Text>
|
||||
<Text onClick={() => goPage('/pages/vip/index')}>模块列表</Text>
|
||||
</View>
|
||||
<Text className="vip-topic-footer-copy">
|
||||
{isCloudphone ? '🌍 云手机 · 低成本工作室搭建指南' : `${config.icon} ${config.title} · 异度星球`}
|
||||
</Text>
|
||||
</View>
|
||||
</ScrollView>
|
||||
|
||||
{updatingName ? (
|
||||
<View className="vip-topic-modal" onClick={() => setUpdatingName('')}>
|
||||
<View className="vip-topic-modal-card" onClick={(e) => e.stopPropagation?.()}>
|
||||
<Text className="vip-topic-modal-ico">🚧</Text>
|
||||
<Text className="vip-topic-modal-title">正在更新</Text>
|
||||
<Text className="vip-topic-modal-body">
|
||||
「{updatingName}」正在升级内容,将在完成后第一时间开放。
|
||||
</Text>
|
||||
<Text className="vip-topic-modal-body">
|
||||
现在可以先学习「云手机」课程,后续会自动同步最新章节。
|
||||
</Text>
|
||||
<View className="vip-topic-modal-actions">
|
||||
<View className="vip-topic-modal-btn ghost" onClick={() => setUpdatingName('')}>
|
||||
<Text>稍后再看</Text>
|
||||
</View>
|
||||
<View
|
||||
className="vip-topic-modal-btn"
|
||||
onClick={() => {
|
||||
setUpdatingName('')
|
||||
goPage('/pages/vip-course/index?id=cloudphone')
|
||||
}}
|
||||
>
|
||||
<Text>去学云手机</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
) : null}
|
||||
</H5Box>
|
||||
)
|
||||
}
|
||||
7
apps/miniprogram/h5/src/pages/vip-ebook/index.config.ts
Normal file
7
apps/miniprogram/h5/src/pages/vip-ebook/index.config.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export default definePageConfig({
|
||||
navigationStyle: 'custom',
|
||||
navigationBarTitleText: '电子书',
|
||||
navigationBarBackgroundColor: '#0a0e17',
|
||||
navigationBarTextStyle: 'white',
|
||||
backgroundColor: '#0a0e17',
|
||||
})
|
||||
289
apps/miniprogram/h5/src/pages/vip-ebook/index.scss
Normal file
289
apps/miniprogram/h5/src/pages/vip-ebook/index.scss
Normal file
@ -0,0 +1,289 @@
|
||||
/* EbookViewer + 小程序 reader 目录交互 — 真 px */
|
||||
.veb {
|
||||
min-height: 100vh;
|
||||
background: #0a0e17;
|
||||
color: #e8eef7;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue',
|
||||
'Noto Sans SC', 'Microsoft YaHei', sans-serif;
|
||||
font-size: 16px;
|
||||
line-height: 1.85;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.veb-loading {
|
||||
display: block;
|
||||
padding: 80px 24px 16px;
|
||||
text-align: center;
|
||||
color: #94a3b8;
|
||||
font-size: 15px;
|
||||
}
|
||||
.veb-locked-cta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 160px;
|
||||
margin: 16px auto 0;
|
||||
min-height: 44px;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(135deg, #ffe66d, #ff6b6b);
|
||||
color: #0a0e17;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.veb-progress {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 3px;
|
||||
background: linear-gradient(90deg, #ff6b6b, #ffe66d, #4ecdc4);
|
||||
z-index: 210;
|
||||
}
|
||||
|
||||
.veb-header {
|
||||
position: relative;
|
||||
z-index: 50;
|
||||
background: rgba(10, 14, 23, 0.96);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
.veb-header-inner {
|
||||
height: 52px;
|
||||
min-height: 52px;
|
||||
padding-left: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.veb-icon-btn {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.veb-icon-btn-hover {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
.veb-icon-btn-txt {
|
||||
font-size: 22px;
|
||||
line-height: 1;
|
||||
color: #f8fafc;
|
||||
font-weight: 600;
|
||||
}
|
||||
.veb-title-wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
padding: 0 4px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
.veb-title {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #f8fafc;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
line-height: 1.3;
|
||||
}
|
||||
.veb-sub {
|
||||
margin-top: 2px;
|
||||
font-size: 11px;
|
||||
color: #94a3b8;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.veb-scroll {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.veb-book {
|
||||
padding: 16px 16px 24px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.veb-section {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.veb-end {
|
||||
text-align: center;
|
||||
color: #64748b;
|
||||
font-size: 13px;
|
||||
padding: 24px 0 calc(48px + env(safe-area-inset-bottom, 0px));
|
||||
}
|
||||
|
||||
/* —— 目录抽屉(左侧,对齐 reader) —— */
|
||||
.veb-drawer-root {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 200;
|
||||
}
|
||||
.veb-mask {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(8, 6, 14, 0.58);
|
||||
}
|
||||
.veb-drawer {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 82%;
|
||||
max-width: 320px;
|
||||
background:
|
||||
radial-gradient(360px 180px at 0% 0%, rgba(78, 205, 196, 0.16), transparent 55%),
|
||||
linear-gradient(180deg, #141b2d, #0f1524 45%, #0a0e17);
|
||||
border-right: 1px solid rgba(255, 255, 255, 0.1);
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
animation: veb-drawer-in 0.22s ease both;
|
||||
}
|
||||
@keyframes veb-drawer-in {
|
||||
from {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
to {
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
.veb-drawer-hero {
|
||||
padding: 8px 16px 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.veb-drawer-brand {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.14em;
|
||||
color: #4ecdc4;
|
||||
font-weight: 700;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.veb-drawer-title {
|
||||
display: block;
|
||||
font-size: 20px;
|
||||
font-weight: 800;
|
||||
color: #f8fafc;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.veb-drawer-book {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
color: #94a3b8;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.veb-drawer-meter {
|
||||
height: 4px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
overflow: hidden;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.veb-drawer-meter-fill {
|
||||
height: 100%;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(90deg, #ff6b6b, #ffe66d, #4ecdc4);
|
||||
}
|
||||
.veb-drawer-stats {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 12px;
|
||||
color: #94a3b8;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.veb-drawer-search {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
padding: 0 12px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 10px;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
color: #e8eef7;
|
||||
font-size: 14px;
|
||||
}
|
||||
.veb-drawer-search-ph {
|
||||
color: #64748b;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.veb-drawer-list {
|
||||
flex: 1;
|
||||
min-height: 200px;
|
||||
padding: 4px 10px 8px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.veb-drawer-empty {
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
color: #64748b;
|
||||
font-size: 14px;
|
||||
}
|
||||
.veb-drawer-item {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: flex-start;
|
||||
min-height: 48px;
|
||||
padding: 12px 10px;
|
||||
margin-bottom: 2px;
|
||||
border-radius: 12px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.veb-drawer-item.is-active {
|
||||
background: rgba(78, 205, 196, 0.14);
|
||||
}
|
||||
.veb-drawer-idx {
|
||||
flex-shrink: 0;
|
||||
width: 28px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #4ecdc4;
|
||||
line-height: 1.45;
|
||||
padding-top: 1px;
|
||||
}
|
||||
.veb-drawer-name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 14px;
|
||||
color: #e8eef7;
|
||||
line-height: 1.45;
|
||||
word-break: break-word;
|
||||
}
|
||||
.veb-drawer-item.is-active .veb-drawer-name {
|
||||
color: #ffe66d;
|
||||
font-weight: 600;
|
||||
}
|
||||
.veb-drawer-close {
|
||||
flex-shrink: 0;
|
||||
margin: 8px 16px calc(12px + env(safe-area-inset-bottom, 0px));
|
||||
min-height: 44px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 14px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.veb-top {
|
||||
position: fixed;
|
||||
right: 16px;
|
||||
bottom: calc(24px + env(safe-area-inset-bottom, 0px));
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 50%;
|
||||
background: rgba(17, 24, 39, 0.95);
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
color: #ffe66d;
|
||||
z-index: 50;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
}
|
||||
282
apps/miniprogram/h5/src/pages/vip-ebook/index.tsx
Normal file
282
apps/miniprogram/h5/src/pages/vip-ebook/index.tsx
Normal file
@ -0,0 +1,282 @@
|
||||
/**
|
||||
* VIP 电子书 — 复刻 nomadvip EbookViewer 目录交互
|
||||
* 顶栏 ☰ 开目录(对齐小程序 reader),左侧抽屉可跳章节
|
||||
*/
|
||||
import { View, Text, ScrollView, Input } from '@tarojs/components'
|
||||
import Taro, { useRouter } from '@tarojs/taro'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { H5Box, H5Txt } from '../../components/H5Box'
|
||||
import { MarkdownView } from '../../components/MarkdownView'
|
||||
import { resolveVipEbookId, VIP_EBOOKS } from '../../data/vipEbooks'
|
||||
import { goPage } from '../../utils/nav'
|
||||
import { resolveVipAccess } from '../../utils/vipAccess'
|
||||
import { getSafeAreaMetrics } from '../../utils/safeArea'
|
||||
import { useNomadroTheme } from '@/utils/h5Theme'
|
||||
import './index.scss'
|
||||
|
||||
const EBOOK_PREFS = {
|
||||
fontSize: 16,
|
||||
lineHeight: '1.85',
|
||||
fontFamily: 'sans' as const,
|
||||
theme: 'vip' as const,
|
||||
}
|
||||
|
||||
type TocItem = { index: number; title: string }
|
||||
|
||||
export default function VipEbookPage() {
|
||||
const theme = useNomadroTheme()
|
||||
const router = useRouter()
|
||||
const bookId = resolveVipEbookId(router.params?.id)
|
||||
const book = VIP_EBOOKS[bookId]
|
||||
const safe = getSafeAreaMetrics()
|
||||
|
||||
const [allowed, setAllowed] = useState(book.free)
|
||||
const [ready, setReady] = useState(false)
|
||||
const [drawerOpen, setDrawerOpen] = useState(false)
|
||||
const [tocFilter, setTocFilter] = useState('')
|
||||
const [scrollInto, setScrollInto] = useState('')
|
||||
const [activeSec, setActiveSec] = useState(0)
|
||||
const [readProgress, setReadProgress] = useState(0)
|
||||
const [showBackTop, setShowBackTop] = useState(false)
|
||||
|
||||
const toc: TocItem[] = useMemo(() => {
|
||||
const titles =
|
||||
book.headers.length > 0
|
||||
? book.headers
|
||||
: book.sections.map((s, i) => {
|
||||
const m = s.match(/^#{1,2}\s+(.+)$/m)
|
||||
return m ? m[1].trim() : `章节 ${i + 1}`
|
||||
})
|
||||
// 目录项与 sections 对齐(跳转锚点)
|
||||
const n = Math.max(titles.length, book.sections.length)
|
||||
const items: TocItem[] = []
|
||||
for (let i = 0; i < n; i++) {
|
||||
items.push({
|
||||
index: Math.min(i, book.sections.length - 1),
|
||||
title: titles[i] || `章节 ${i + 1}`,
|
||||
})
|
||||
}
|
||||
return items
|
||||
}, [book])
|
||||
|
||||
const filteredToc = useMemo(() => {
|
||||
const q = tocFilter.trim().toLowerCase()
|
||||
if (!q) return toc
|
||||
return toc.filter((t) => t.title.toLowerCase().includes(q))
|
||||
}, [toc, tocFilter])
|
||||
|
||||
useEffect(() => {
|
||||
Taro.setNavigationBarTitle({ title: book.title })
|
||||
setScrollInto('')
|
||||
setDrawerOpen(false)
|
||||
setTocFilter('')
|
||||
setActiveSec(0)
|
||||
setReadProgress(0)
|
||||
void (async () => {
|
||||
if (book.free) {
|
||||
setAllowed(true)
|
||||
setReady(true)
|
||||
return
|
||||
}
|
||||
const vip = await resolveVipAccess(true)
|
||||
setAllowed(vip)
|
||||
setReady(true)
|
||||
if (!vip) {
|
||||
Taro.showModal({
|
||||
title: '会员专享',
|
||||
content: `开通 VIP 后可读《${book.title}》`,
|
||||
confirmText: '去开通',
|
||||
success: (r) => {
|
||||
if (r.confirm) goPage('/pages/vip/index')
|
||||
else Taro.navigateBack({ fail: () => goPage('/pages/vip/index') })
|
||||
},
|
||||
})
|
||||
}
|
||||
})()
|
||||
}, [book.free, book.title, bookId])
|
||||
|
||||
function onScroll(e: {
|
||||
detail?: { scrollTop?: number; scrollHeight?: number }
|
||||
}) {
|
||||
const top = Number(e.detail?.scrollTop || 0)
|
||||
const height = Number(e.detail?.scrollHeight || 1)
|
||||
const view = Math.max(1, height - 400)
|
||||
setReadProgress(Math.min(100, (top / view) * 100))
|
||||
setShowBackTop(top > 600)
|
||||
}
|
||||
|
||||
function openDrawer() {
|
||||
setDrawerOpen(true)
|
||||
}
|
||||
|
||||
function closeDrawer() {
|
||||
setDrawerOpen(false)
|
||||
}
|
||||
|
||||
function jumpTo(secIndex: number) {
|
||||
const idx = Math.max(0, Math.min(secIndex, book.sections.length - 1))
|
||||
setActiveSec(idx)
|
||||
setDrawerOpen(false)
|
||||
const id = `veb-sec-${idx}`
|
||||
// 先清空再设,触发 scroll-into-view
|
||||
setScrollInto('')
|
||||
setTimeout(() => setScrollInto(id), 120)
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
Taro.navigateBack({ fail: () => goPage('/pages/vip/index') })
|
||||
}
|
||||
|
||||
if (!ready) {
|
||||
return (
|
||||
<H5Box className="veb" data-theme={theme}>
|
||||
<H5Txt className="veb-loading">加载中…</H5Txt>
|
||||
</H5Box>
|
||||
)
|
||||
}
|
||||
|
||||
if (!allowed) {
|
||||
return (
|
||||
<H5Box className="veb" data-theme={theme}>
|
||||
<H5Txt className="veb-loading">🔒 开通会员后阅读《{book.title}》</H5Txt>
|
||||
<View className="veb-locked-cta" onClick={() => goPage('/pages/vip/index')}>
|
||||
<Text>立即开通</Text>
|
||||
</View>
|
||||
</H5Box>
|
||||
)
|
||||
}
|
||||
|
||||
const remainMin = Math.max(
|
||||
0,
|
||||
Math.ceil(book.estimatedMinutes * (1 - readProgress / 100)),
|
||||
)
|
||||
const drawerListH = `calc(100vh - ${safe.statusBarHeight + 200}px)`
|
||||
|
||||
return (
|
||||
<H5Box className="veb" data-theme={theme}>
|
||||
<View className="veb-progress" style={{ width: `${readProgress}%` }} />
|
||||
|
||||
{/* 顶栏:☰ 目录 | 标题(点也可开目录) | 右侧留胶囊位 */}
|
||||
<View className="veb-header" style={{ paddingTop: `${safe.statusBarHeight}px` }}>
|
||||
<View
|
||||
className="veb-header-inner"
|
||||
style={{ paddingRight: `${Math.max(safe.menuRightPad, 96)}px` }}
|
||||
>
|
||||
<View className="veb-icon-btn" onClick={openDrawer} hoverClass="veb-icon-btn-hover">
|
||||
<Text className="veb-icon-btn-txt">☰</Text>
|
||||
</View>
|
||||
<View className="veb-title-wrap" onClick={openDrawer}>
|
||||
<Text className="veb-title">{book.title}</Text>
|
||||
<Text className="veb-sub">
|
||||
{activeSec + 1}/{book.sections.length} · 约剩 {remainMin} 分钟 · 点此开目录
|
||||
</Text>
|
||||
</View>
|
||||
<View className="veb-icon-btn" onClick={goBack} hoverClass="veb-icon-btn-hover">
|
||||
<Text className="veb-icon-btn-txt">‹</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<ScrollView
|
||||
scrollY
|
||||
className="veb-scroll"
|
||||
style={{ height: `calc(100vh - ${safe.statusBarHeight + 52}px)` }}
|
||||
scrollIntoView={scrollInto}
|
||||
scrollWithAnimation
|
||||
enhanced
|
||||
showScrollbar
|
||||
onScroll={onScroll}
|
||||
>
|
||||
<View className="veb-book">
|
||||
{book.sections.map((sec, i) => (
|
||||
<View key={`sec-${i}`} id={`veb-sec-${i}`} className="veb-section">
|
||||
<MarkdownView markdown={sec} prefs={EBOOK_PREFS} />
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
<View className="veb-end">— 全书完 —</View>
|
||||
</ScrollView>
|
||||
|
||||
{/* 目录抽屉:mask 与 drawer 分离,避免点击穿透 */}
|
||||
{drawerOpen ? (
|
||||
<View className="veb-drawer-root">
|
||||
<View className="veb-mask" onClick={closeDrawer} />
|
||||
<View
|
||||
className="veb-drawer"
|
||||
style={{ paddingTop: `${safe.statusBarHeight + 8}px` }}
|
||||
catchMove
|
||||
>
|
||||
<View className="veb-drawer-hero">
|
||||
<Text className="veb-drawer-brand">CONTENTS</Text>
|
||||
<Text className="veb-drawer-title">章节目录</Text>
|
||||
<Text className="veb-drawer-book">《{book.title}》</Text>
|
||||
<View className="veb-drawer-meter">
|
||||
<View
|
||||
className="veb-drawer-meter-fill"
|
||||
style={{ width: `${readProgress}%` }}
|
||||
/>
|
||||
</View>
|
||||
<View className="veb-drawer-stats">
|
||||
<Text>进度 {Math.round(readProgress)}%</Text>
|
||||
<Text>
|
||||
{activeSec + 1}/{book.sections.length} 章
|
||||
</Text>
|
||||
</View>
|
||||
<Input
|
||||
className="veb-drawer-search"
|
||||
value={tocFilter}
|
||||
placeholder="筛选章节"
|
||||
placeholderClass="veb-drawer-search-ph"
|
||||
onInput={(e) => setTocFilter(e.detail.value)}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<ScrollView
|
||||
scrollY
|
||||
className="veb-drawer-list"
|
||||
style={{ height: drawerListH }}
|
||||
scrollWithAnimation
|
||||
enhanced
|
||||
showScrollbar
|
||||
>
|
||||
{filteredToc.length === 0 ? (
|
||||
<View className="veb-drawer-empty">
|
||||
<Text>无匹配章节</Text>
|
||||
</View>
|
||||
) : (
|
||||
filteredToc.map((item, listIdx) => {
|
||||
const active = item.index === activeSec
|
||||
return (
|
||||
<View
|
||||
key={`toc-${listIdx}-${item.index}`}
|
||||
className={`veb-drawer-item${active ? ' is-active' : ''}`}
|
||||
onClick={() => jumpTo(item.index)}
|
||||
>
|
||||
<Text className="veb-drawer-idx">
|
||||
{String(item.index + 1).padStart(2, '0')}
|
||||
</Text>
|
||||
<Text className="veb-drawer-name">{item.title}</Text>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
)}
|
||||
</ScrollView>
|
||||
|
||||
<View className="veb-drawer-close" onClick={closeDrawer}>
|
||||
<Text>关闭目录</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{showBackTop ? (
|
||||
<View
|
||||
className="veb-top"
|
||||
onClick={() => jumpTo(0)}
|
||||
>
|
||||
<Text>↑</Text>
|
||||
</View>
|
||||
) : null}
|
||||
</H5Box>
|
||||
)
|
||||
}
|
||||
6
apps/miniprogram/h5/src/pages/vip-lesson/index.config.ts
Normal file
6
apps/miniprogram/h5/src/pages/vip-lesson/index.config.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '课时',
|
||||
navigationBarBackgroundColor: '#0c0c0f',
|
||||
navigationBarTextStyle: 'white',
|
||||
backgroundColor: '#0c0c0f',
|
||||
})
|
||||
164
apps/miniprogram/h5/src/pages/vip-lesson/index.scss
Normal file
164
apps/miniprogram/h5/src/pages/vip-lesson/index.scss
Normal file
@ -0,0 +1,164 @@
|
||||
/* 真 px(weapp pxExclude) */
|
||||
.vip-lesson {
|
||||
min-height: 100vh;
|
||||
background: #0c0c0f;
|
||||
color: #f5f5f7;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue',
|
||||
'Noto Sans SC', 'Microsoft YaHei', sans-serif;
|
||||
font-size: 15px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.vip-lesson[data-theme='light'] {
|
||||
background: #f7f7f8;
|
||||
color: #111827;
|
||||
}
|
||||
.vip-lesson-video {
|
||||
width: 100%;
|
||||
height: 211px;
|
||||
background: #000;
|
||||
}
|
||||
.vip-lesson-lock {
|
||||
height: 211px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
background: #111;
|
||||
color: #e5e7eb;
|
||||
font-size: 15px;
|
||||
}
|
||||
.vip-lesson-lock-ico {
|
||||
font-size: 36px;
|
||||
}
|
||||
.vip-lesson-lock-btn {
|
||||
margin-top: 4px;
|
||||
min-height: 44px;
|
||||
padding: 0 24px;
|
||||
border-radius: 999px;
|
||||
background: #f59e0b;
|
||||
color: #111;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
line-height: 44px;
|
||||
}
|
||||
.vip-lesson-body {
|
||||
height: calc(100vh - 211px);
|
||||
padding: 14px 16px calc(40px + env(safe-area-inset-bottom, 0px));
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.vip-lesson-progress {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.vip-lesson-progress-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 12px;
|
||||
color: #9ca3af;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.vip-lesson-progress-bar {
|
||||
height: 6px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
overflow: hidden;
|
||||
}
|
||||
.vip-lesson-progress-fill {
|
||||
height: 100%;
|
||||
border-radius: 999px;
|
||||
background: #f59e0b;
|
||||
}
|
||||
.vip-lesson-crumb {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-bottom: 12px;
|
||||
font-size: 13px;
|
||||
color: #9ca3af;
|
||||
min-height: 36px;
|
||||
}
|
||||
.vip-lesson-crumb-sep {
|
||||
color: #6b7280;
|
||||
}
|
||||
.vip-lesson-title {
|
||||
display: block;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 6px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.vip-lesson-meta {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
color: #9ca3af;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.vip-lesson-nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 18px;
|
||||
min-height: 44px;
|
||||
}
|
||||
.vip-lesson-nav-btn {
|
||||
font-size: 14px;
|
||||
color: #f59e0b;
|
||||
padding: 10px 4px;
|
||||
min-height: 44px;
|
||||
line-height: 24px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.vip-lesson-nav-btn.is-disabled {
|
||||
opacity: 0;
|
||||
}
|
||||
.vip-lesson-nav-home {
|
||||
font-size: 13px;
|
||||
color: #9ca3af;
|
||||
padding: 8px 14px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
min-height: 36px;
|
||||
line-height: 20px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.vip-lesson-doc {
|
||||
margin-top: 8px;
|
||||
padding: 14px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
.vip-lesson-doc-title {
|
||||
display: block;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 12px;
|
||||
color: #f5f5f7;
|
||||
}
|
||||
.vip-lesson-dl {
|
||||
margin-top: 14px;
|
||||
padding: 14px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
.vip-lesson-dl-desc {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
color: #9ca3af;
|
||||
line-height: 1.5;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.vip-lesson-dl-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 44px;
|
||||
padding: 0 20px;
|
||||
border-radius: 999px;
|
||||
background: #f59e0b;
|
||||
color: #111;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
217
apps/miniprogram/h5/src/pages/vip-lesson/index.tsx
Normal file
217
apps/miniprogram/h5/src/pages/vip-lesson/index.tsx
Normal file
@ -0,0 +1,217 @@
|
||||
/**
|
||||
* 课时页 — 对照 nomadvip cloudphone/course/[m]/[l]
|
||||
* Video + LessonLayout 进度/导航 + 配套文档
|
||||
*/
|
||||
import { View, Text, Video, ScrollView } from '@tarojs/components'
|
||||
import Taro, { useRouter } from '@tarojs/taro'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { H5Box, H5Txt } from '../../components/H5Box'
|
||||
import { MarkdownView } from '../../components/MarkdownView'
|
||||
import { getVipLesson, VIP_COURSE_MODULES } from '../../data/vipCourse'
|
||||
import { VIP_LESSON_CONTENT } from '../../data/vipLessonContent'
|
||||
import { goPage } from '../../utils/nav'
|
||||
import { resolveVipAccess } from '../../utils/vipAccess'
|
||||
import {
|
||||
getProgress,
|
||||
markCompleted,
|
||||
setLastWatched,
|
||||
} from '../../utils/vipLearning'
|
||||
import { DEFAULT_PREFS, loadReaderPrefs } from '../../utils/readerPrefs'
|
||||
import { useNomadroTheme } from '@/utils/h5Theme'
|
||||
import './index.scss'
|
||||
|
||||
const TOTAL = VIP_COURSE_MODULES.reduce((s, m) => s + m.lessons.length, 0)
|
||||
|
||||
function findPrevNext(m: number, l: number) {
|
||||
const flat: { m: number; l: number; name: string }[] = []
|
||||
VIP_COURSE_MODULES.forEach((mod, mi) => {
|
||||
mod.lessons.forEach((les, li) => flat.push({ m: mi, l: li, name: les.name }))
|
||||
})
|
||||
const idx = flat.findIndex((x) => x.m === m && x.l === l)
|
||||
return {
|
||||
prev: idx > 0 ? flat[idx - 1] : null,
|
||||
next: idx >= 0 && idx < flat.length - 1 ? flat[idx + 1] : null,
|
||||
}
|
||||
}
|
||||
|
||||
export default function VipLessonPage() {
|
||||
const theme = useNomadroTheme()
|
||||
const router = useRouter()
|
||||
const m = Number(router.params?.m || 0)
|
||||
const l = Number(router.params?.l || 0)
|
||||
const lesson = useMemo(() => getVipLesson(m, l), [m, l])
|
||||
const content = lesson ? VIP_LESSON_CONTENT[lesson.key] : null
|
||||
const videoUrl = content?.videoUrl || lesson?.videoUrl || ''
|
||||
const markdown = content?.markdown || ''
|
||||
const prefs = useMemo(() => loadReaderPrefs() || DEFAULT_PREFS, [])
|
||||
const { prev, next } = useMemo(() => findPrevNext(m, l), [m, l])
|
||||
const [isVip, setIsVip] = useState(false)
|
||||
const [ready, setReady] = useState(false)
|
||||
const [progress, setProgress] = useState(() => getProgress(TOTAL))
|
||||
|
||||
useEffect(() => {
|
||||
void (async () => {
|
||||
const vip = await resolveVipAccess(true)
|
||||
setIsVip(vip)
|
||||
setReady(true)
|
||||
setProgress(getProgress(TOTAL))
|
||||
if (!vip) {
|
||||
Taro.showModal({
|
||||
title: '会员专享',
|
||||
content: '开通 VIP 后可观看本课视频与配套文档',
|
||||
confirmText: '去开通',
|
||||
success: (r) => {
|
||||
if (r.confirm) goPage('/pages/vip/index')
|
||||
else
|
||||
Taro.navigateBack({
|
||||
fail: () => goPage('/pages/vip-course/index?id=cloudphone'),
|
||||
})
|
||||
},
|
||||
})
|
||||
} else if (lesson) {
|
||||
setLastWatched(m, l, lesson.name)
|
||||
}
|
||||
})()
|
||||
}, [m, l, lesson])
|
||||
|
||||
useEffect(() => {
|
||||
if (lesson) {
|
||||
Taro.setNavigationBarTitle({
|
||||
title: lesson.name.replace(/^\d+\s*/, '').slice(0, 12),
|
||||
})
|
||||
}
|
||||
}, [lesson])
|
||||
|
||||
function onVideoEnded() {
|
||||
markCompleted(m, l)
|
||||
setProgress(getProgress(TOTAL))
|
||||
}
|
||||
|
||||
function goDir() {
|
||||
goPage('/pages/vip-course/index?id=cloudphone')
|
||||
}
|
||||
|
||||
if (!lesson) {
|
||||
return (
|
||||
<H5Box className="vip-lesson" data-theme={theme}>
|
||||
<H5Txt>章节不存在</H5Txt>
|
||||
</H5Box>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<H5Box className="vip-lesson" data-theme={theme}>
|
||||
{ready && isVip ? (
|
||||
<Video
|
||||
className="vip-lesson-video"
|
||||
src={videoUrl}
|
||||
controls
|
||||
showCenterPlayBtn
|
||||
enablePlayGesture
|
||||
objectFit="contain"
|
||||
id={`cloudphone-${m}-${l}`}
|
||||
onEnded={onVideoEnded}
|
||||
/>
|
||||
) : (
|
||||
<View className="vip-lesson-lock">
|
||||
<Text className="vip-lesson-lock-ico">🔒</Text>
|
||||
<Text>报名解锁本章节</Text>
|
||||
<View className="vip-lesson-lock-btn" onClick={() => goPage('/pages/vip/index')}>
|
||||
<Text>立即报名</Text>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
<ScrollView scrollY className="vip-lesson-body" enhanced showScrollbar>
|
||||
<View className="vip-lesson-progress">
|
||||
<View className="vip-lesson-progress-row">
|
||||
<Text>学习进度</Text>
|
||||
<Text>
|
||||
{progress.completed}/{TOTAL} 节 · {progress.percent}%
|
||||
</Text>
|
||||
</View>
|
||||
<View className="vip-lesson-progress-bar">
|
||||
<View
|
||||
className="vip-lesson-progress-fill"
|
||||
style={{ width: `${progress.percent}%` }}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="vip-lesson-crumb">
|
||||
<Text onClick={() => Taro.navigateBack({ fail: goDir })}>返回</Text>
|
||||
<Text className="vip-lesson-crumb-sep"> / </Text>
|
||||
<Text onClick={goDir}>课程首页</Text>
|
||||
</View>
|
||||
|
||||
<H5Txt className="vip-lesson-title">{lesson.name}</H5Txt>
|
||||
<H5Txt className="vip-lesson-meta">时长 {lesson.duration}</H5Txt>
|
||||
|
||||
<View className="vip-lesson-nav">
|
||||
{prev ? (
|
||||
<Text
|
||||
className="vip-lesson-nav-btn"
|
||||
onClick={() => {
|
||||
if (!isVip) {
|
||||
goPage('/pages/vip/index')
|
||||
return
|
||||
}
|
||||
goPage(`/pages/vip-lesson/index?m=${prev.m}&l=${prev.l}`)
|
||||
}}
|
||||
>
|
||||
← 上一节
|
||||
</Text>
|
||||
) : (
|
||||
<Text className="vip-lesson-nav-btn is-disabled"> </Text>
|
||||
)}
|
||||
<Text className="vip-lesson-nav-home" onClick={goDir}>
|
||||
目录
|
||||
</Text>
|
||||
{next ? (
|
||||
<Text
|
||||
className="vip-lesson-nav-btn"
|
||||
onClick={() => {
|
||||
if (!isVip) {
|
||||
goPage('/pages/vip/index')
|
||||
return
|
||||
}
|
||||
goPage(`/pages/vip-lesson/index?m=${next.m}&l=${next.l}`)
|
||||
}}
|
||||
>
|
||||
下一节 →
|
||||
</Text>
|
||||
) : (
|
||||
<Text className="vip-lesson-nav-btn is-disabled"> </Text>
|
||||
)}
|
||||
</View>
|
||||
|
||||
{ready && isVip && markdown ? (
|
||||
<View className="vip-lesson-doc">
|
||||
<H5Txt className="vip-lesson-doc-title">📄 配套文档</H5Txt>
|
||||
<MarkdownView markdown={markdown} prefs={prefs} />
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{ready && isVip ? (
|
||||
<View className="vip-lesson-dl">
|
||||
<H5Txt className="vip-lesson-doc-title">📥 课程资料下载</H5Txt>
|
||||
<H5Txt className="vip-lesson-dl-desc">
|
||||
课程配套资料已上传至网盘,报名后可前往下载
|
||||
</H5Txt>
|
||||
<View
|
||||
className="vip-lesson-dl-btn"
|
||||
onClick={() => {
|
||||
const url = 'https://pan.baidu.com/s/example'
|
||||
void Taro.setClipboardData({ data: url }).then(() => {
|
||||
Taro.showToast({ title: '网盘链接已复制', icon: 'none' })
|
||||
})
|
||||
}}
|
||||
>
|
||||
<Text>前往网盘下载</Text>
|
||||
</View>
|
||||
</View>
|
||||
) : null}
|
||||
</ScrollView>
|
||||
</H5Box>
|
||||
)
|
||||
}
|
||||
@ -2,17 +2,23 @@
|
||||
* Taro VIP landing — mirrors modules/vip LandingPage structure.
|
||||
*/
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { Text, Button } from '@tarojs/components'
|
||||
import { Text, Button, View } 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 {
|
||||
getCachedRemoteConfig,
|
||||
loadRemoteConfig,
|
||||
subscribeRemoteConfig,
|
||||
} from '@/services/remoteConfig'
|
||||
import type { NomadroRemoteConfig } from '@/data/remoteConfig.defaults'
|
||||
import { useNomadroTheme } from '@/utils/h5Theme'
|
||||
import { goHome } from '@/utils/nav'
|
||||
import { goHome, goPage } from '@/utils/nav'
|
||||
import { usePageShare, markPageShare } from '@/utils/pageShare'
|
||||
import { getSafeAreaMetrics } from '@/utils/safeArea'
|
||||
import { markVipPaidLocal, resolveVipAccess } from '@/utils/vipAccess'
|
||||
import { ensureLogin } from '@/utils/request'
|
||||
import './index.scss'
|
||||
|
||||
const isH5 = process.env.TARO_ENV === 'h5'
|
||||
@ -55,19 +61,18 @@ const TOPICS_DISPLAY = [
|
||||
] as const
|
||||
|
||||
const VIDEO_COURSES_DISPLAY = [
|
||||
// 过审展示文案;原文: 云手机 / 无人直播…
|
||||
{
|
||||
id: 'cloudphone',
|
||||
icon: '☁️',
|
||||
title: '云端安卓环境',
|
||||
desc: '低成本自建云端安卓环境,TikTok/YouTube 直播效率实战指南',
|
||||
title: '云手机',
|
||||
desc: '低成本自建云手机,TikTok/YouTube 无人直播实战指南',
|
||||
href: '/vip/cloudphone',
|
||||
},
|
||||
{
|
||||
id: 'livestream',
|
||||
icon: '📺',
|
||||
title: '直播效率',
|
||||
desc: 'TikTok/YouTube 直播效率,24 小时自动化',
|
||||
title: '无人直播',
|
||||
desc: 'TikTok/YouTube 无人直播,24 小时自动化',
|
||||
href: '/vip/topic/livestream',
|
||||
},
|
||||
{
|
||||
@ -90,16 +95,18 @@ const EBOOKS_DISPLAY = [
|
||||
{
|
||||
id: '1',
|
||||
title: '数字游民',
|
||||
desc: '地理优势运营与自动化杠杆',
|
||||
desc: '地理套利与自动化杠杆',
|
||||
href: '/vip/ebook',
|
||||
free: true,
|
||||
ebookId: 'nomad' as const,
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
title: '云端安卓环境',
|
||||
title: '云手机',
|
||||
desc: '低成本工作室搭建指南',
|
||||
href: '/vip/ebook/cloudphone',
|
||||
locked: true,
|
||||
free: false,
|
||||
ebookId: 'cloudphone' as const,
|
||||
},
|
||||
] as const
|
||||
|
||||
@ -159,9 +166,19 @@ function VipLanding() {
|
||||
const [offline, setOffline] = useState(false)
|
||||
const [faqOpen, setFaqOpen] = useState<number | null>(0)
|
||||
const [restoreDate] = useState(() => formatRestoreDateShort())
|
||||
const [isVip, setIsVip] = useState(false)
|
||||
|
||||
async function refreshVipStatus() {
|
||||
setIsVip(await resolveVipAccess(true))
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadRemoteConfig().then((r) => {
|
||||
void loadRemoteConfig(true).then((r) => {
|
||||
setCfg(r.config)
|
||||
setOffline(r.fromOffline)
|
||||
})
|
||||
void refreshVipStatus()
|
||||
return subscribeRemoteConfig((r) => {
|
||||
setCfg(r.config)
|
||||
setOffline(r.fromOffline)
|
||||
})
|
||||
@ -184,9 +201,10 @@ function VipLanding() {
|
||||
}, [])
|
||||
|
||||
const payOk = cfg.flags.payEnabled !== false
|
||||
const priceFen = cfg.copy.vipPriceFen || 29800
|
||||
const productId = cfg.copy.vipProductId || 'vip_membership'
|
||||
const cta = cfg.copy.vipCta || '立即加入'
|
||||
const priceFen = Number(cfg.copy.vipPriceFen) || 0
|
||||
const productId = String(cfg.copy.vipProductId || '')
|
||||
const isFreeVip = priceFen <= 0 || !productId
|
||||
const cta = cfg.copy.vipCta || (isFreeVip ? '免费加入' : '立即加入')
|
||||
const brand = cfg.copy.homeBrand || 'nomadro'
|
||||
const safe = useMemo(() => getSafeAreaMetrics(), [])
|
||||
const safeStyle = useMemo(
|
||||
@ -199,30 +217,121 @@ function VipLanding() {
|
||||
[safe],
|
||||
)
|
||||
|
||||
function onLogin() {
|
||||
Taro.showToast({ title: '请在门户登录', icon: 'none' })
|
||||
/** 页内锚点真滚动(小程序用 pageScrollTo,禁止 toast 糊弄) */
|
||||
function scrollToAnchor(anchorId: string) {
|
||||
const id = anchorId.replace(/^#/, '').trim()
|
||||
if (!id) return
|
||||
|
||||
if (isH5 && typeof document !== 'undefined') {
|
||||
document.getElementById(id)?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||
return
|
||||
}
|
||||
|
||||
const offset = Math.max(safe.headerHeight, 64) + 8
|
||||
setTimeout(() => {
|
||||
const q = Taro.createSelectorQuery()
|
||||
q.select(`#${id}`).boundingClientRect()
|
||||
q.selectViewport().scrollOffset()
|
||||
q.exec((res) => {
|
||||
const rect = res?.[0] as { top?: number } | undefined
|
||||
const vp = res?.[1] as { scrollTop?: number } | undefined
|
||||
if (!rect || typeof rect.top !== 'number') return
|
||||
const scrollTop = Math.max(0, Number(vp?.scrollTop || 0) + rect.top - offset)
|
||||
void Taro.pageScrollTo({ scrollTop, duration: 320 })
|
||||
})
|
||||
}, 32)
|
||||
}
|
||||
|
||||
async function onLogin() {
|
||||
if (isH5) {
|
||||
Taro.showToast({ title: '请在门户登录', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
await ensureLogin(true)
|
||||
await refreshVipStatus()
|
||||
Taro.showToast({ title: '已登录', icon: 'success' })
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : String(e)
|
||||
Taro.showToast({ title: msg.slice(0, 36) || '登录失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
function onLocked() {
|
||||
Taro.showToast({ title: '请开通会员', icon: 'none' })
|
||||
void Taro.showModal({
|
||||
title: '会员专享',
|
||||
content: '开通 VIP 后解锁私密社群、设备商城等权益',
|
||||
confirmText: '去开通',
|
||||
cancelText: '再看看',
|
||||
success: (r) => {
|
||||
if (r.confirm) scrollToAnchor('vip-cta')
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function openExternal(url: string, title = '外部链接') {
|
||||
void Taro.showModal({
|
||||
title,
|
||||
content: '小程序内无法直接打开外链,可复制后在浏览器打开',
|
||||
confirmText: '复制链接',
|
||||
cancelText: '取消',
|
||||
success: (r) => {
|
||||
if (!r.confirm) return
|
||||
void Taro.setClipboardData({ data: url }).then(() => {
|
||||
Taro.showToast({ title: '已复制', icon: 'success' })
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 微信内只走原生页;禁止 web-view */
|
||||
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' })
|
||||
}
|
||||
scrollToAnchor(href)
|
||||
return
|
||||
}
|
||||
const url = href.startsWith('http') ? href : `https://nomadro.cn${href}`
|
||||
|
||||
if (href.includes('ebook/cloudphone') || href.includes('/ebook/cloudphone')) {
|
||||
if (!isVip && !isFreeVip) {
|
||||
onLocked()
|
||||
return
|
||||
}
|
||||
goPage('/pages/vip-ebook/index?id=cloudphone')
|
||||
return
|
||||
}
|
||||
if (
|
||||
href === '/vip/ebook' ||
|
||||
href === '/ebook' ||
|
||||
(href.includes('ebook') && !href.includes('cloudphone'))
|
||||
) {
|
||||
goPage('/pages/vip-ebook/index?id=nomad')
|
||||
return
|
||||
}
|
||||
|
||||
if (href.includes('/topic/')) {
|
||||
const id = href.split('/topic/')[1]?.split(/[?#]/)[0] || 'cloudphone'
|
||||
goPage(`/pages/vip-course/index?id=${id}`)
|
||||
return
|
||||
}
|
||||
if (href.includes('cloudphone') && !href.includes('ebook')) {
|
||||
goPage('/pages/vip-course/index?id=cloudphone')
|
||||
return
|
||||
}
|
||||
if (href.includes('video')) {
|
||||
goPage('/pages/vip-course/index?id=cloudphone')
|
||||
return
|
||||
}
|
||||
|
||||
const url = href.startsWith('http')
|
||||
? href
|
||||
: `https://nomadro.cn${href.startsWith('/') ? href : `/${href}`}`
|
||||
if (isH5 && typeof window !== 'undefined') {
|
||||
window.open(url, '_blank', 'noopener,noreferrer')
|
||||
} else {
|
||||
Taro.setClipboardData({ data: url }).then(() => {
|
||||
Taro.showToast({ title: '链接已复制', icon: 'none' })
|
||||
})
|
||||
return
|
||||
}
|
||||
openExternal(url)
|
||||
}
|
||||
|
||||
async function onJoin() {
|
||||
@ -242,6 +351,26 @@ function VipLanding() {
|
||||
return
|
||||
}
|
||||
|
||||
// 点击前强制拉最新方案(后台一键切换免费/道具实时生效)
|
||||
try {
|
||||
const r = await loadRemoteConfig(true)
|
||||
setCfg(r.config)
|
||||
setOffline(r.fromOffline)
|
||||
} catch {
|
||||
/* 用缓存 */
|
||||
}
|
||||
const latest = getCachedRemoteConfig()
|
||||
const latestPrice = Number(latest.copy.vipPriceFen) || 0
|
||||
const latestPid = String(latest.copy.vipProductId || '')
|
||||
const free = latestPrice <= 0 || !latestPid
|
||||
|
||||
if (free) {
|
||||
markVipPaidLocal()
|
||||
setIsVip(true)
|
||||
Taro.showToast({ title: '已免费开放', icon: 'success' })
|
||||
return
|
||||
}
|
||||
|
||||
if (!payOk) {
|
||||
Taro.showToast({ title: '支付已关闭', icon: 'none' })
|
||||
return
|
||||
@ -249,8 +378,11 @@ function VipLanding() {
|
||||
|
||||
setBusy(true)
|
||||
try {
|
||||
const orderId = await payVirtualProduct(productId, priceFen)
|
||||
const orderId = await payVirtualProduct(latestPid, latestPrice)
|
||||
markVipPaidLocal()
|
||||
setIsVip(true)
|
||||
Taro.showToast({ title: `支付成功 ${orderId.slice(-6)}`, icon: 'success' })
|
||||
void refreshVipStatus()
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : String(e)
|
||||
if (!/cancel|取消|-2/i.test(msg)) {
|
||||
@ -311,7 +443,9 @@ function VipLanding() {
|
||||
<H5Txt className="vip-sectionTitle">模块</H5Txt>
|
||||
<H5Box className="vip-topicGrid" style={{ marginBottom: '1.5rem' }}>
|
||||
{TOPICS_DISPLAY.map((t) => {
|
||||
const locked = 'locked' in t && t.locked
|
||||
// 社群/商城等外链仍按配置锁;内容模块不锁入口(进页后再鉴权)
|
||||
const hardLock = t.id === 'community' || t.id === 'tools'
|
||||
const locked = hardLock && !isVip
|
||||
return (
|
||||
<H5Box
|
||||
key={t.id}
|
||||
@ -327,9 +461,9 @@ function VipLanding() {
|
||||
})}
|
||||
</H5Box>
|
||||
|
||||
<H5Txt id="video-courses" className="vip-sectionTitle">
|
||||
视频教程
|
||||
</H5Txt>
|
||||
<View id="video-courses" className="vip-sectionTitle">
|
||||
<Text>视频教程</Text>
|
||||
</View>
|
||||
<H5Box className="vip-topicGrid" style={{ marginBottom: '1.5rem' }}>
|
||||
{VIDEO_COURSES_DISPLAY.map((v) => (
|
||||
<H5Box
|
||||
@ -344,18 +478,24 @@ function VipLanding() {
|
||||
))}
|
||||
</H5Box>
|
||||
|
||||
<H5Txt id="ebooks" className="vip-sectionTitle">
|
||||
电子书
|
||||
</H5Txt>
|
||||
<View id="ebooks" className="vip-sectionTitle">
|
||||
<Text>电子书</Text>
|
||||
</View>
|
||||
<H5Box className="vip-ebookGrid">
|
||||
{EBOOKS_DISPLAY.map((e) => {
|
||||
const isFree = 'free' in e && e.free
|
||||
const locked = 'locked' in e && e.locked
|
||||
const isFree = Boolean(e.free) || isFreeVip
|
||||
const locked = !isFree && !isVip
|
||||
return (
|
||||
<H5Box
|
||||
key={e.id}
|
||||
className="vip-card vip-ebookCard"
|
||||
onClick={() => (locked ? onLocked() : openHref(e.href))}
|
||||
onClick={() => {
|
||||
if (locked) {
|
||||
onLocked()
|
||||
return
|
||||
}
|
||||
goPage(`/pages/vip-ebook/index?id=${e.ebookId}`)
|
||||
}}
|
||||
>
|
||||
<H5Txt className="vip-ebookEmoji">📖</H5Txt>
|
||||
<H5Box className="vip-ebookTitleRow">
|
||||
@ -444,7 +584,7 @@ function VipLanding() {
|
||||
</H5Box>
|
||||
|
||||
{/* LandingCTA */}
|
||||
<H5Box className="vip-section vip-ctaSection">
|
||||
<H5Box className="vip-section vip-ctaSection" id="vip-cta">
|
||||
<H5Box className="vip-ctaInner">
|
||||
<H5Box className="vip-ctaGlow" aria-hidden />
|
||||
<H5Box className="vip-ctaCard">
|
||||
@ -481,7 +621,7 @@ function VipLanding() {
|
||||
>
|
||||
{busy ? '拉起支付…' : `🔒 ${cta}`}
|
||||
</Button>
|
||||
<Button className="vip-ctaBtnSecondary" onClick={onLogin}>
|
||||
<Button className="vip-ctaBtnSecondary" onClick={() => void onLogin()}>
|
||||
已有账号
|
||||
</Button>
|
||||
</H5Box>
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
const STORAGE_KEY = 'nomadro_remote_config_v1'
|
||||
const CACHE_TTL_MS = 1000 * 60 * 30
|
||||
/** 小程序无 EventSource:meta 轮询间隔(近实时) */
|
||||
const META_POLL_MS = 8000
|
||||
const META_POLL_MS = 3000
|
||||
|
||||
type LoadResult = {
|
||||
config: NomadroRemoteConfig
|
||||
@ -60,14 +60,16 @@ function writeStorage(config: NomadroRemoteConfig) {
|
||||
|
||||
function metaUrls(): string[] {
|
||||
if (APP_TARGET === 'h5') return ['/api/config/meta']
|
||||
return [`${WEB_BASE}/api/config/meta`]
|
||||
// 小程序优先 api(证书合法 + 原始 flags,含 joinGroupAction);门户作兜底
|
||||
return [`${API_BASE}/api/config/meta`, `${WEB_BASE}/api/config/meta`]
|
||||
}
|
||||
|
||||
async function fetchRemote(): Promise<NomadroRemoteConfig | null> {
|
||||
const urls =
|
||||
APP_TARGET === 'h5'
|
||||
? ['/api/config']
|
||||
: [`${WEB_BASE}/api/config`, `${API_BASE}/v1/config`]
|
||||
: // 后台 VIP 写的是 API 侧 remote-config;门户旧 merge 会丢掉 joinGroupAction
|
||||
[`${API_BASE}/api/config`, `${WEB_BASE}/api/config`]
|
||||
|
||||
for (const url of urls) {
|
||||
try {
|
||||
@ -176,7 +178,10 @@ export function subscribeRemoteConfig(listener: Listener): () => void {
|
||||
|
||||
async function softCheckMeta() {
|
||||
const meta = await fetchMeta()
|
||||
if (!meta) return
|
||||
if (!meta) {
|
||||
await loadRemoteConfig(true)
|
||||
return
|
||||
}
|
||||
if (knownVersion && meta.version === knownVersion) return
|
||||
await loadRemoteConfig(true)
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
export type ReaderTheme = 'dark' | 'sepia' | 'light'
|
||||
export type ReaderTheme = 'dark' | 'sepia' | 'light' | 'vip'
|
||||
export type FontFamilyKey = 'sans' | 'serif'
|
||||
|
||||
export const FONT_SIZES = [
|
||||
@ -33,6 +33,7 @@ export const THEMES = [
|
||||
{ label: '夜', value: 'dark' as const },
|
||||
{ label: '暖', value: 'sepia' as const },
|
||||
{ label: '昼', value: 'light' as const },
|
||||
{ label: 'VIP', value: 'vip' as const },
|
||||
]
|
||||
|
||||
export type ReaderPrefs = {
|
||||
@ -118,6 +119,20 @@ export function themeColors(theme: ReaderTheme): ThemeColors {
|
||||
strong: '#2a1f14',
|
||||
}
|
||||
}
|
||||
if (theme === 'vip') {
|
||||
/* nomadvip EbookViewer 深色纸面 */
|
||||
return {
|
||||
text: '#e8eef7',
|
||||
muted: '#94a3b8',
|
||||
accent: '#4ecdc4',
|
||||
accent2: '#ffe66d',
|
||||
accentSoft: 'rgba(255, 230, 109, 0.12)',
|
||||
border: 'rgba(255, 255, 255, 0.12)',
|
||||
surface: 'rgba(255, 255, 255, 0.04)',
|
||||
code: '#ffe66d',
|
||||
strong: '#f8fafc',
|
||||
}
|
||||
}
|
||||
return {
|
||||
text: '#f3eefc',
|
||||
muted: '#b4a9c8',
|
||||
|
||||
57
apps/miniprogram/h5/src/utils/vipAccess.ts
Normal file
57
apps/miniprogram/h5/src/utils/vipAccess.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import Taro from '@tarojs/taro'
|
||||
import { API_BASE, STORAGE_TOKEN } from './config'
|
||||
import { ensureLogin } from './request'
|
||||
import {
|
||||
getCachedRemoteConfig,
|
||||
loadRemoteConfig,
|
||||
} from '../services/remoteConfig'
|
||||
|
||||
const LOCAL_PAID_KEY = 'nomadro_vip_paid'
|
||||
|
||||
/** 对齐 nomadvip paidType=vip */
|
||||
export function markVipPaidLocal(): void {
|
||||
try {
|
||||
Taro.setStorageSync(LOCAL_PAID_KEY, '1')
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
export function isVipPaidLocal(): boolean {
|
||||
try {
|
||||
return Taro.getStorageSync(LOCAL_PAID_KEY) === '1'
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/** 后台免费方案 / 已购 VIP / 本地已付标记 */
|
||||
export async function resolveVipAccess(forceRefresh = false): Promise<boolean> {
|
||||
try {
|
||||
if (forceRefresh) await loadRemoteConfig(true)
|
||||
} catch {
|
||||
/* use cache */
|
||||
}
|
||||
const cfg = getCachedRemoteConfig()
|
||||
const price = Number(cfg.copy.vipPriceFen) || 0
|
||||
const pid = String(cfg.copy.vipProductId || '').trim()
|
||||
if (price <= 0 || !pid) return true
|
||||
if (isVipPaidLocal()) return true
|
||||
|
||||
try {
|
||||
await ensureLogin(false)
|
||||
const token = Taro.getStorageSync(STORAGE_TOKEN)
|
||||
const res = await Taro.request({
|
||||
url: `${API_BASE}/api/ebook/pay/vip-status`,
|
||||
method: 'GET',
|
||||
header: token ? { Authorization: `Bearer ${token}` } : {},
|
||||
})
|
||||
if (res.statusCode < 400 && (res.data as { isVip?: boolean })?.isVip) {
|
||||
markVipPaidLocal()
|
||||
return true
|
||||
}
|
||||
} catch {
|
||||
/* offline */
|
||||
}
|
||||
return false
|
||||
}
|
||||
89
apps/miniprogram/h5/src/utils/vipLearning.ts
Normal file
89
apps/miniprogram/h5/src/utils/vipLearning.ts
Normal file
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* 学习进度 — 对照 src/modules/vip/app/cloudphone/lib/learning.ts
|
||||
* 用 Taro Storage,键名与 web localStorage 对齐便于同端调试
|
||||
*/
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
const PREFIX = 'lms-cloudphone-'
|
||||
const KEY_LAST = `${PREFIX}last`
|
||||
const KEY_COMPLETED = `${PREFIX}completed`
|
||||
const KEY_BOOKMARKS = `${PREFIX}bookmarks`
|
||||
|
||||
export type LastWatched = { moduleIndex: number; lessonIndex: number; name: string }
|
||||
|
||||
export function getLastWatched(): LastWatched | null {
|
||||
try {
|
||||
const raw = Taro.getStorageSync(KEY_LAST)
|
||||
if (!raw) return null
|
||||
const d = typeof raw === 'string' ? JSON.parse(raw) : raw
|
||||
if (typeof d?.moduleIndex !== 'number' || typeof d?.lessonIndex !== 'number') return null
|
||||
return { moduleIndex: d.moduleIndex, lessonIndex: d.lessonIndex, name: d.name || '' }
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export function setLastWatched(m: number, l: number, name: string): void {
|
||||
try {
|
||||
Taro.setStorageSync(KEY_LAST, JSON.stringify({ moduleIndex: m, lessonIndex: l, name }))
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
export function getCompletedLessons(): Set<string> {
|
||||
try {
|
||||
const raw = Taro.getStorageSync(KEY_COMPLETED)
|
||||
if (!raw) return new Set()
|
||||
const arr = typeof raw === 'string' ? JSON.parse(raw) : raw
|
||||
return new Set(Array.isArray(arr) ? arr : [])
|
||||
} catch {
|
||||
return new Set()
|
||||
}
|
||||
}
|
||||
|
||||
export function markCompleted(moduleIndex: number, lessonIndex: number): void {
|
||||
try {
|
||||
const set = getCompletedLessons()
|
||||
set.add(`${moduleIndex}-${lessonIndex}`)
|
||||
Taro.setStorageSync(KEY_COMPLETED, JSON.stringify([...set]))
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
export function getProgress(totalLessons: number): { completed: number; percent: number } {
|
||||
const completed = getCompletedLessons().size
|
||||
return {
|
||||
completed,
|
||||
percent: totalLessons > 0 ? Math.round((completed / totalLessons) * 100) : 0,
|
||||
}
|
||||
}
|
||||
|
||||
export function getBookmarks(): Set<string> {
|
||||
try {
|
||||
const raw = Taro.getStorageSync(KEY_BOOKMARKS)
|
||||
if (!raw) return new Set()
|
||||
const arr = typeof raw === 'string' ? JSON.parse(raw) : raw
|
||||
return new Set(Array.isArray(arr) ? arr : [])
|
||||
} catch {
|
||||
return new Set()
|
||||
}
|
||||
}
|
||||
|
||||
export function toggleBookmark(moduleIndex: number, lessonIndex: number): boolean {
|
||||
try {
|
||||
const set = getBookmarks()
|
||||
const key = `${moduleIndex}-${lessonIndex}`
|
||||
if (set.has(key)) set.delete(key)
|
||||
else set.add(key)
|
||||
Taro.setStorageSync(KEY_BOOKMARKS, JSON.stringify([...set]))
|
||||
return set.has(key)
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export function isBookmarked(moduleIndex: number, lessonIndex: number): boolean {
|
||||
return getBookmarks().has(`${moduleIndex}-${lessonIndex}`)
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
import Taro from '@tarojs/taro'
|
||||
import { APP_TARGET, STORAGE_TOKEN } from './config'
|
||||
import { ensureLogin, requestGateway } from './request'
|
||||
import { API_BASE, APP_TARGET, STORAGE_TOKEN } from './config'
|
||||
import { ensureLogin } from './request'
|
||||
|
||||
export type VirtualPayPayload = {
|
||||
signData: string
|
||||
@ -8,6 +8,7 @@ export type VirtualPayPayload = {
|
||||
paySig: string
|
||||
signature: string
|
||||
outTradeNo: string
|
||||
kind?: string
|
||||
}
|
||||
|
||||
function isCancel(err: unknown): boolean {
|
||||
@ -53,33 +54,35 @@ function invokeVirtualPayment(payData: VirtualPayPayload): Promise<void> {
|
||||
})
|
||||
}
|
||||
|
||||
async function createVipOrder(productId: string, goodsPrice: number): Promise<VirtualPayPayload> {
|
||||
/** VIP 会员下单:走 /pay/vip-order(不查小册)。旧包误走 /pay/order 时服务端也会识别道具 ID。 */
|
||||
async function createVipOrder(): Promise<VirtualPayPayload> {
|
||||
await ensureLogin(true)
|
||||
try {
|
||||
return await requestGateway<VirtualPayPayload>('/v1/miniprogram/wx/pay/order', {
|
||||
method: 'POST',
|
||||
data: { product_id: productId, goods_price: goodsPrice },
|
||||
})
|
||||
} catch {
|
||||
// 回退:走电子书同一套 /api/ebook/pay/order(若后台配置了 VIP 商品)
|
||||
const token = Taro.getStorageSync(STORAGE_TOKEN)
|
||||
const { API_BASE } = await import('./config')
|
||||
const token = Taro.getStorageSync(STORAGE_TOKEN)
|
||||
const urls = [
|
||||
`${API_BASE}/api/ebook/pay/vip-order`,
|
||||
`${API_BASE}/api/pay/vip-order`,
|
||||
]
|
||||
let lastDetail = 'VIP 下单失败'
|
||||
for (const url of urls) {
|
||||
const res = await Taro.request({
|
||||
url: `${API_BASE}/api/ebook/pay/order`,
|
||||
url,
|
||||
method: 'POST',
|
||||
data: { book_id: productId, product_id: productId },
|
||||
data: {},
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
||||
},
|
||||
})
|
||||
if (res.statusCode >= 400) {
|
||||
throw new Error(
|
||||
(res.data as { detail?: string })?.detail || 'VIP 下单失败',
|
||||
)
|
||||
if (res.statusCode < 400) {
|
||||
return res.data as VirtualPayPayload
|
||||
}
|
||||
const detail = (res.data as { detail?: string })?.detail
|
||||
if (typeof detail === 'string' && detail) lastDetail = detail
|
||||
if (res.statusCode === 401) {
|
||||
await ensureLogin(true)
|
||||
}
|
||||
return res.data as VirtualPayPayload
|
||||
}
|
||||
throw new Error(lastDetail)
|
||||
}
|
||||
|
||||
async function payTtMock(productId: string, goodsPriceFen: number): Promise<string> {
|
||||
@ -119,7 +122,8 @@ export async function payVirtualProduct(
|
||||
for (let attempt = 0; attempt < 3; attempt++) {
|
||||
try {
|
||||
if (attempt > 0) await ensureLogin(true)
|
||||
const payData = await createVipOrder(productId, goodsPriceFen)
|
||||
// 价格/道具以服务端 VIP 配置为准,不信任客户端
|
||||
const payData = await createVipOrder()
|
||||
try {
|
||||
await invokeVirtualPayment(payData)
|
||||
return payData.outTradeNo
|
||||
|
||||
@ -4,7 +4,20 @@
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
pnpm dev # 出 dist/,微信开发者工具打开本目录
|
||||
pnpm --dir apps/miniprogram/weapp build:weapp # 或根目录 pnpm build:weapp / dev:weapp
|
||||
# 微信开发者工具打开本目录(读 dist/)
|
||||
```
|
||||
|
||||
改页面请改 `apps/miniprogram/h5/src`,不要再复制一份 weapp/src。
|
||||
|
||||
## VIP(原生页,禁止 web-view)
|
||||
|
||||
对齐门户 / nomadvip:`vip` 落地 · `vip-course` 专题 · `vip-lesson` 课时 · `vip-ebook` 电子书。
|
||||
`config/index.ts` 对 VIP / 落地 scss 走 **真 px**(`pxExclude`),避免 `designWidth:750` 把字号压成一半。
|
||||
|
||||
电子书 / 课时内容从 `src/modules/vip/app/data` 抽取:
|
||||
|
||||
```bash
|
||||
python apps/miniprogram/h5/scripts/extract-vip-ebooks.py
|
||||
python apps/miniprogram/h5/scripts/extract-vip-lessons.py
|
||||
```
|
||||
|
||||
@ -28,7 +28,10 @@ const pxExclude = (file: string) =>
|
||||
/[\\/]pages[\\/]nav[\\/]index\.scss/.test(file) ||
|
||||
/[\\/]pages[\\/]book[\\/]index\.scss/.test(file) ||
|
||||
/[\\/]pages[\\/]community[\\/]index\.scss/.test(file) ||
|
||||
/[\\/]pages[\\/]vip[\\/]index\.scss/.test(file)
|
||||
/[\\/]pages[\\/]vip[\\/]index\.scss/.test(file) ||
|
||||
/[\\/]pages[\\/]vip-course[\\/]index\.scss/.test(file) ||
|
||||
/[\\/]pages[\\/]vip-lesson[\\/]index\.scss/.test(file) ||
|
||||
/[\\/]pages[\\/]vip-ebook[\\/]index\.scss/.test(file)
|
||||
|
||||
export default defineConfig(async (merge) => {
|
||||
const baseConfig: UserConfigExport = {
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
{
|
||||
"miniprogramRoot": "dist/",
|
||||
"projectname": "nomadro-weapp",
|
||||
"description": "Nomadro 微信小程序",
|
||||
"description": "Nomadro 微信小程序(无 vip-web)",
|
||||
"appid": "wxa55815dd741a540d",
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"es6": true,
|
||||
"minified": true,
|
||||
"postcss": false
|
||||
"postcss": false,
|
||||
"compileHotReLoad": true
|
||||
},
|
||||
"compileType": "miniprogram"
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": 4,
|
||||
"version": 5,
|
||||
"updatedAt": "2026-03-30T12:00:00.000Z",
|
||||
"modules": {
|
||||
"home": {
|
||||
@ -33,23 +33,30 @@
|
||||
"vip": {
|
||||
"enabled": true,
|
||||
"title": "会员中心"
|
||||
},
|
||||
"game": {
|
||||
"enabled": false,
|
||||
"title": "Nomad Day 3D",
|
||||
"note": "default hidden"
|
||||
}
|
||||
},
|
||||
"flags": {
|
||||
"payEnabled": true,
|
||||
"socialFollow": true,
|
||||
"socialFollowAuto": false,
|
||||
"joinGroupWechat": false,
|
||||
"joinGroupWechat": true,
|
||||
"joinGroupDouyin": true,
|
||||
"offlineBadge": false
|
||||
"offlineBadge": false,
|
||||
"joinGroupAction": "popup"
|
||||
},
|
||||
"copy": {
|
||||
"homeBrand": "nomadro",
|
||||
"homeTagline": "",
|
||||
"homeLead": "",
|
||||
"vipPriceFen": 29800,
|
||||
"vipProductId": "vip_membership",
|
||||
"vipCta": "立即加入",
|
||||
"vipProductId": "tiktok",
|
||||
"vipCta": "立即加入 · ¥298",
|
||||
"vipOfferKey": "tiktok",
|
||||
"wechatOaName": "异度世界",
|
||||
"joinGroupDouyinHint": "打开抖音搜群「数字游民」或扫码进群",
|
||||
"joinGroupDouyinQr": ""
|
||||
|
||||
@ -59,6 +59,8 @@ export type NomadroRemoteConfig = {
|
||||
meetups: ModuleToggle;
|
||||
destinations: ModuleToggle;
|
||||
home: ModuleToggle;
|
||||
/** 微信 H5/weapp 首页 Nomad Day 3D 入口;默认隐藏 */
|
||||
game?: ModuleToggle;
|
||||
};
|
||||
flags: {
|
||||
payEnabled: boolean;
|
||||
@ -73,6 +75,8 @@ export type NomadroRemoteConfig = {
|
||||
joinGroupWechat: boolean;
|
||||
/** 加群 → 抖音群(后台开关,用户无感知) */
|
||||
joinGroupDouyin: boolean;
|
||||
/** 加群点击:popup=弹窗;vip=跳会员页。本地默认 vip */
|
||||
joinGroupAction: "popup" | "vip";
|
||||
offlineBadge: boolean;
|
||||
};
|
||||
copy: {
|
||||
@ -160,7 +164,8 @@ export const DEFAULT_REMOTE_CONFIG: NomadroRemoteConfig = {
|
||||
},
|
||||
destinations: { enabled: true, title: "目的地" },
|
||||
meetups: { enabled: true, title: "活动" },
|
||||
vip: { enabled: true, title: "会员中心", note: "deep link only" },
|
||||
vip: { enabled: false, title: "会员中心", note: "deep link only" },
|
||||
game: { enabled: false, title: "Nomad Day 3D", note: "默认隐藏入口" },
|
||||
},
|
||||
flags: {
|
||||
payEnabled: true,
|
||||
@ -168,6 +173,7 @@ export const DEFAULT_REMOTE_CONFIG: NomadroRemoteConfig = {
|
||||
socialFollowAuto: false,
|
||||
joinGroupWechat: true,
|
||||
joinGroupDouyin: false,
|
||||
joinGroupAction: "popup",
|
||||
offlineBadge: false,
|
||||
},
|
||||
copy: {
|
||||
@ -175,8 +181,8 @@ export const DEFAULT_REMOTE_CONFIG: NomadroRemoteConfig = {
|
||||
homeTagline: "",
|
||||
homeLead: "",
|
||||
vipPriceFen: 29800,
|
||||
vipProductId: "vip_membership",
|
||||
vipCta: "立即加入",
|
||||
vipProductId: "tiktok",
|
||||
vipCta: "立即加入 · ¥298",
|
||||
wechatOaName: "异度世界",
|
||||
joinGroupDouyinHint: "打开抖音搜群「数字游民」或扫码进群",
|
||||
joinGroupDouyinQr: "",
|
||||
@ -283,6 +289,10 @@ export function mergeRemoteConfig(
|
||||
);
|
||||
}
|
||||
const pf = (partial.flags || {}) as Partial<NomadroRemoteConfig["flags"]>;
|
||||
const joinAction =
|
||||
pf.joinGroupAction === "popup" || pf.joinGroupAction === "vip"
|
||||
? pf.joinGroupAction
|
||||
: base.flags.joinGroupAction;
|
||||
return {
|
||||
...base,
|
||||
...partial,
|
||||
@ -295,6 +305,7 @@ export function mergeRemoteConfig(
|
||||
socialFollowAuto: asBool(pf.socialFollowAuto, base.flags.socialFollowAuto),
|
||||
joinGroupWechat: asBool(pf.joinGroupWechat, base.flags.joinGroupWechat),
|
||||
joinGroupDouyin: asBool(pf.joinGroupDouyin, base.flags.joinGroupDouyin),
|
||||
joinGroupAction: joinAction,
|
||||
offlineBadge: asBool(pf.offlineBadge, base.flags.offlineBadge),
|
||||
},
|
||||
copy: { ...base.copy, ...(partial.copy || {}) },
|
||||
|
||||
Loading…
Reference in New Issue
Block a user