Restructure /wechat nav (VIP submenu for ebooks/course/shop/memo), rebuild ops pages with shared wx UI, and wire vip-library remote content end-to-end with README paths. Co-authored-by: Cursor <cursoragent@cursor.com>
269 lines
7.5 KiB
TypeScript
269 lines
7.5 KiB
TypeScript
/**
|
||
* 微信 VIP 落地页远程配置 — platforms.weapp.vipContent
|
||
* 缺省=现网硬编码;离线兜底;抖音端勿读。
|
||
*/
|
||
|
||
export type VipTopicItem = {
|
||
id: string
|
||
icon: string
|
||
title: string
|
||
desc: string
|
||
href: string
|
||
enabled?: boolean
|
||
locked?: boolean
|
||
sort?: number
|
||
}
|
||
|
||
export type VipVideoItem = {
|
||
id: string
|
||
icon: string
|
||
title: string
|
||
desc: string
|
||
href: string
|
||
enabled?: boolean
|
||
sort?: number
|
||
}
|
||
|
||
export type VipEbookItem = {
|
||
id: string
|
||
title: string
|
||
desc: string
|
||
ebookId: string
|
||
free?: boolean
|
||
enabled?: boolean
|
||
sort?: number
|
||
}
|
||
|
||
export type VipCompareItem = {
|
||
feature: string
|
||
single: string
|
||
member: string
|
||
}
|
||
|
||
export type VipFaqItem = {
|
||
q: string
|
||
a: string
|
||
}
|
||
|
||
export type WeappVipContent = {
|
||
heroEyebrow: string
|
||
heroTitleAccent: string
|
||
heroTitleRest: string
|
||
heroLead: string
|
||
showStats: boolean
|
||
showTopics: boolean
|
||
showVideos: boolean
|
||
showEbooks: boolean
|
||
showCompare: boolean
|
||
showFaq: boolean
|
||
showCta: boolean
|
||
reviewMode: boolean
|
||
stats: {
|
||
topics: string
|
||
ebooks: string
|
||
videos: string
|
||
updateFrequency: string
|
||
}
|
||
topics: VipTopicItem[]
|
||
videos: VipVideoItem[]
|
||
ebooks: VipEbookItem[]
|
||
compareTitle: string
|
||
compareDesc: string
|
||
compare: VipCompareItem[]
|
||
faqTitle: string
|
||
faqSub: string
|
||
faq: VipFaqItem[]
|
||
ctaChips: string[]
|
||
ctaSecondary: string
|
||
ctaHintWeapp: string
|
||
ctaHintH5: string
|
||
}
|
||
|
||
export const DEFAULT_WEAPP_VIP: WeappVipContent = {
|
||
heroEyebrow: 'nomadro',
|
||
heroTitleAccent: '全模块解锁',
|
||
heroTitleRest: '持续更新 · 抱团出海',
|
||
heroLead: '一次付费,解锁电子书、视频教程、知识社群、即时问答,每周更新',
|
||
showStats: true,
|
||
showTopics: true,
|
||
showVideos: true,
|
||
showEbooks: true,
|
||
showCompare: true,
|
||
showFaq: true,
|
||
showCta: true,
|
||
reviewMode: false,
|
||
stats: {
|
||
topics: '4',
|
||
ebooks: '2',
|
||
videos: '40+',
|
||
updateFrequency: '每周',
|
||
},
|
||
topics: [
|
||
{ id: 'ebook', icon: '📖', title: '电子书', desc: '知识沉淀·随时阅读', href: '#ebooks', enabled: true },
|
||
{
|
||
id: 'cloudphone',
|
||
icon: '🎬',
|
||
title: '视频教程',
|
||
desc: '实战演练·即学即用',
|
||
href: '#video-courses',
|
||
enabled: true,
|
||
},
|
||
{
|
||
id: 'community',
|
||
icon: '👥',
|
||
title: '知识社群',
|
||
desc: '抱团出海',
|
||
href: '/pages/vip-memo/index',
|
||
enabled: true,
|
||
locked: true,
|
||
},
|
||
{
|
||
id: 'tools',
|
||
icon: '🛒',
|
||
title: '设备自助下单',
|
||
desc: '开箱即用',
|
||
href: '/pages/vip-store/index',
|
||
enabled: true,
|
||
locked: true,
|
||
},
|
||
],
|
||
videos: [
|
||
{
|
||
id: 'cloudphone',
|
||
icon: '☁️',
|
||
title: '云手机',
|
||
desc: '低成本自建云手机,TikTok/YouTube 无人直播实战指南',
|
||
href: '/vip/cloudphone',
|
||
enabled: true,
|
||
},
|
||
{
|
||
id: 'livestream',
|
||
icon: '📺',
|
||
title: '无人直播',
|
||
desc: 'TikTok/YouTube 无人直播,24 小时自动化',
|
||
href: '/vip/topic/livestream',
|
||
enabled: true,
|
||
},
|
||
{
|
||
id: 'indie',
|
||
icon: '🛠️',
|
||
title: '独立开发',
|
||
desc: '从想法到产品,独立开发者全流程指南',
|
||
href: '/vip/topic/indie',
|
||
enabled: true,
|
||
},
|
||
{
|
||
id: 'aiagent',
|
||
icon: '🤖',
|
||
title: 'AI Agent',
|
||
desc: 'AIGC 与智能体,Vibe Coding 跨界创造',
|
||
href: '/vip/topic/aiagent',
|
||
enabled: true,
|
||
},
|
||
],
|
||
ebooks: [
|
||
{
|
||
id: '1',
|
||
title: '数字游民',
|
||
desc: '地理套利与自动化杠杆',
|
||
ebookId: 'nomad',
|
||
free: true,
|
||
enabled: true,
|
||
},
|
||
{
|
||
id: '2',
|
||
title: '云手机',
|
||
desc: '低成本集群搭建指南',
|
||
ebookId: 'cloudphone',
|
||
free: false,
|
||
enabled: true,
|
||
},
|
||
],
|
||
compareTitle: '单品 vs 会员',
|
||
compareDesc: '一次付费,全部解锁',
|
||
compare: [
|
||
{ feature: '电子书', single: '按需开通', member: '全解锁' },
|
||
{ feature: '视频教程', single: '按需开通', member: '全解锁' },
|
||
{ feature: '知识社群', single: '—', member: '✓' },
|
||
{ feature: '即时问答', single: '—', member: '✓' },
|
||
{ feature: '持续更新', single: '—', member: '✓' },
|
||
],
|
||
faqTitle: '常见问题',
|
||
faqSub: '购买前可快速了解会员权益与流程;点击问题展开详情。',
|
||
faq: [
|
||
{
|
||
q: '会员包含哪些内容?',
|
||
a: '电子书、视频教程、知识社群、即时问答、设备自助下单等全部解锁,并享受持续更新。',
|
||
},
|
||
{
|
||
q: '如何加入?',
|
||
a: '点击「立即加入」完成支付即可,支付成功后自动开通,无需人工审核。',
|
||
},
|
||
{
|
||
q: '为什么越早加入越划算?',
|
||
a: '会员采用阶梯定价:越早锁定席位,单价越低;在恢复原价前完成支付,可长期享受全部内容与后续更新,整体投入更省、权益不打折。',
|
||
},
|
||
],
|
||
ctaChips: ['阶梯定价', '数字交付', '持续更新', '不支持退款'],
|
||
ctaSecondary: '已有账号',
|
||
ctaHintWeapp: '微信小程序虚拟支付',
|
||
ctaHintH5: '浏览器请走门户 /vip 支付',
|
||
}
|
||
|
||
function mergeList<T extends { id?: string; enabled?: boolean; sort?: number }>(
|
||
base: T[],
|
||
patch: unknown,
|
||
): T[] {
|
||
if (!Array.isArray(patch)) return base.map((x) => ({ ...x }))
|
||
if (!patch.length) return []
|
||
return patch
|
||
.filter((x): x is T => !!x && typeof x === 'object')
|
||
.map((x, i) => ({ ...x, sort: typeof x.sort === 'number' ? x.sort : i }))
|
||
.sort((a, b) => Number(a.sort || 0) - Number(b.sort || 0))
|
||
}
|
||
|
||
export function mergeWeappVipContent(
|
||
partial?: Partial<WeappVipContent> | null,
|
||
): WeappVipContent {
|
||
const base = JSON.parse(JSON.stringify(DEFAULT_WEAPP_VIP)) as WeappVipContent
|
||
if (!partial) return base
|
||
return {
|
||
...base,
|
||
...partial,
|
||
showStats: typeof partial.showStats === 'boolean' ? partial.showStats : base.showStats,
|
||
showTopics: typeof partial.showTopics === 'boolean' ? partial.showTopics : base.showTopics,
|
||
showVideos: typeof partial.showVideos === 'boolean' ? partial.showVideos : base.showVideos,
|
||
showEbooks: typeof partial.showEbooks === 'boolean' ? partial.showEbooks : base.showEbooks,
|
||
showCompare: typeof partial.showCompare === 'boolean' ? partial.showCompare : base.showCompare,
|
||
showFaq: typeof partial.showFaq === 'boolean' ? partial.showFaq : base.showFaq,
|
||
showCta: typeof partial.showCta === 'boolean' ? partial.showCta : base.showCta,
|
||
reviewMode: typeof partial.reviewMode === 'boolean' ? partial.reviewMode : base.reviewMode,
|
||
stats: { ...base.stats, ...(partial.stats || {}) },
|
||
topics: mergeList(base.topics, partial.topics ?? base.topics),
|
||
videos: mergeList(base.videos, partial.videos ?? base.videos),
|
||
ebooks: mergeList(base.ebooks, partial.ebooks ?? base.ebooks),
|
||
compare: Array.isArray(partial.compare) ? partial.compare : base.compare,
|
||
faq: Array.isArray(partial.faq) ? partial.faq : base.faq,
|
||
ctaChips: Array.isArray(partial.ctaChips) ? partial.ctaChips.map(String) : base.ctaChips,
|
||
}
|
||
}
|
||
|
||
export type ConfigWithWeapp = {
|
||
platforms?: {
|
||
weapp?: {
|
||
vipContent?: Partial<WeappVipContent>
|
||
}
|
||
tt?: unknown
|
||
}
|
||
}
|
||
|
||
/** 只读微信 platforms.weapp.vipContent;缺省=包内默认(现网 UI) */
|
||
export function resolveWeappVipContent(config: ConfigWithWeapp | null | undefined): WeappVipContent {
|
||
const stored = config?.platforms?.weapp?.vipContent
|
||
return mergeWeappVipContent(stored)
|
||
}
|
||
|
||
export function visibleItems<T extends { enabled?: boolean }>(items: T[]): T[] {
|
||
return items.filter((x) => x.enabled !== false)
|
||
}
|