const { ROUTES, openStaticRoute } = require('../../utils/static-ux/route-map') const { createTcmHomeHubCards } = require('../../utils/static-ux/tcm') const HOME_PAGE_BLUEPRINT = Object.freeze({ brandName: '玄知中医', greeting: '晚上好', subtitle: '今天想学点什么?从典籍、工具或养生主题开始。', searchPlaceholder: '搜索典籍、术语、AI问答...', searchBadge: 'AI', searchRoute: ROUTES.tcm.searchBooks, portalTitle: '学习入口', encyclopediaTitle: '中医百科', encyclopediaCards: [ { key: 'classic', icon: '书', title: '经典书城', route: ROUTES.tabs.library }, { key: 'meridian', icon: '穴', title: '经络穴位', status: '待开放' }, { key: 'disease', icon: '病', title: '疾病百科', status: '待开放' } ], toolsTitle: '学习工具', toolCards: [ { key: 'qa', icon: '问', title: 'AI问答', route: ROUTES.tabs.ai }, { key: 'formula', icon: '方', title: '方剂笔记', route: `${ROUTES.tcm.assets}?kind=notes` }, { key: 'constitution', icon: '诊', title: '体质诊断', route: ROUTES.tabs.ai }, { key: 'wellness', icon: '养', title: '智能饮片' } ], wellnessTitle: '养生调理', wellnessCards: [ { key: 'constitution-check', icon: '🧬', title: 'AI体质检测', status: '待开放', route: ROUTES.tabs.ai }, { key: 'medicated-diet', icon: '🍲', title: '药膳', status: '待开放' }, { key: 'ingredient', icon: '🥬', title: '食材', status: '待开放' } ], classicsTitle: '热门典籍', classicsActionText: '进入书城', classicsActionRoute: ROUTES.tabs.library, classicsBooks: [ { key: 'huangdi-neijing-suwen', coverText: '黄', title: '黄帝内经素问', route: `${ROUTES.tcm.bookDetail}?scene=classic-a` }, { key: 'shang-han-lun', coverText: '伤', title: '伤寒论', route: `${ROUTES.tcm.bookDetail}?scene=classic-b` }, { key: 'wen-bing-tiao-bian', coverText: '温', title: '温病条辨', route: `${ROUTES.tcm.searchBooks}?keyword=温病条辨` }, { key: 'bencao-gangmu-bieming-lu', coverText: '本', title: '本草纲目别名录', route: `${ROUTES.tcm.searchBooks}?keyword=本草纲目` } ] }) function cloneItems(items) { return items.map(item => ({ ...item })) } function createHomePageData() { return { brandName: HOME_PAGE_BLUEPRINT.brandName, greeting: HOME_PAGE_BLUEPRINT.greeting, subtitle: HOME_PAGE_BLUEPRINT.subtitle, searchPlaceholder: HOME_PAGE_BLUEPRINT.searchPlaceholder, searchBadge: HOME_PAGE_BLUEPRINT.searchBadge, searchRoute: HOME_PAGE_BLUEPRINT.searchRoute, portalTitle: HOME_PAGE_BLUEPRINT.portalTitle, portalCards: createTcmHomeHubCards(), encyclopediaTitle: HOME_PAGE_BLUEPRINT.encyclopediaTitle, encyclopediaCards: cloneItems(HOME_PAGE_BLUEPRINT.encyclopediaCards), toolsTitle: HOME_PAGE_BLUEPRINT.toolsTitle, toolCards: cloneItems(HOME_PAGE_BLUEPRINT.toolCards), wellnessTitle: HOME_PAGE_BLUEPRINT.wellnessTitle, wellnessCards: cloneItems(HOME_PAGE_BLUEPRINT.wellnessCards), classicsTitle: HOME_PAGE_BLUEPRINT.classicsTitle, classicsActionText: HOME_PAGE_BLUEPRINT.classicsActionText, classicsActionRoute: HOME_PAGE_BLUEPRINT.classicsActionRoute, classicsBooks: cloneItems(HOME_PAGE_BLUEPRINT.classicsBooks) } } function navigateToRoute(route) { openStaticRoute(route, wx) } function showPendingToast(title) { if (typeof wx?.showToast !== 'function') { return } wx.showToast({ title: title ? `${title}待开放` : '功能建设中', icon: 'none' }) } function handleHomeEntry(route, title) { if (openStaticRoute(route, wx)) { return } showPendingToast(title) } Page({ data: createHomePageData(), handleSearchTap() { handleHomeEntry(this.data.searchRoute, '搜索') }, handleEncyclopediaTap(event) { const { route, title } = event.currentTarget.dataset handleHomeEntry(route, title) }, handlePortalTap(event) { navigateToRoute(event.currentTarget.dataset.route) }, handleToolTap(event) { const { route, title } = event.currentTarget.dataset handleHomeEntry(route, title) }, handleWellnessTap(event) { const { route, title } = event.currentTarget.dataset handleHomeEntry(route, title) }, handleClassicActionTap() { handleHomeEntry(this.data.classicsActionRoute, this.data.classicsActionText) }, handleClassicTap(event) { const { route, title } = event.currentTarget.dataset handleHomeEntry(route, title) } }) module.exports = { HOME_PAGE_BLUEPRINT, createHomePageData }