186 lines
5.1 KiB
JavaScript
186 lines
5.1 KiB
JavaScript
const { ROUTES, openStaticRoute } = require('../../utils/static-ux/route-map')
|
|
|
|
const AI_PAGE_BLUEPRINT = Object.freeze({
|
|
title: 'AI助手',
|
|
historyText: '历史',
|
|
disclaimerText: '本功能仅供学习参考,不能替代专业医师诊断。',
|
|
tabs: [
|
|
{
|
|
key: 'qa',
|
|
label: 'AI答疑'
|
|
},
|
|
{
|
|
key: 'analysis',
|
|
label: '辨证分析'
|
|
},
|
|
{
|
|
key: 'constitution',
|
|
label: '体质检测'
|
|
}
|
|
],
|
|
panels: {
|
|
qa: {
|
|
key: 'qa',
|
|
badge: 'AI答疑',
|
|
heading: '您好,我是中医学习助手',
|
|
subheading: '围绕中医理论、术语和典籍原文快速提问',
|
|
highlights: ['解答中医理论问题', '解释典籍原文含义', '给出学习型出处引用'],
|
|
examples: ['什么是阴阳?', '气虚和阳虚有什么区别?', '如何理解肝主疏泄?'],
|
|
formType: 'qa',
|
|
actionTitle: '输入你的问题',
|
|
inputPlaceholder: '例如:什么是气虚?',
|
|
actionButtonText: '发送'
|
|
},
|
|
analysis: {
|
|
key: 'analysis',
|
|
badge: '辨证分析',
|
|
heading: '先整理症状,再查看学习型辨证分析',
|
|
subheading: '把症状整理为结构化输入,再看学习型辨证思路',
|
|
highlights: ['输入主要症状', '补充舌象、脉象、体质', '查看学习型辨证结论'],
|
|
examples: ['乏力、睡眠差应如何整理输入?', '舌淡苔白常见于哪些证型?', '如何理解脾虚湿困?'],
|
|
formType: 'analysis',
|
|
actionTitle: '整理辨证输入',
|
|
primaryField: {
|
|
label: '主要症状',
|
|
placeholder: '主要症状,多个用逗号分隔'
|
|
},
|
|
secondaryFields: [
|
|
{
|
|
key: 'tongue',
|
|
placeholder: '舌象'
|
|
},
|
|
{
|
|
key: 'pulse',
|
|
placeholder: '脉象'
|
|
},
|
|
{
|
|
key: 'constitution',
|
|
placeholder: '体质'
|
|
},
|
|
{
|
|
key: 'course',
|
|
placeholder: '病程'
|
|
}
|
|
],
|
|
noteField: {
|
|
label: '补充说明',
|
|
placeholder: '例如:近两周明显乏力,睡眠浅。'
|
|
},
|
|
actionButtonText: '开始分析'
|
|
},
|
|
constitution: {
|
|
key: 'constitution',
|
|
badge: '体质检测',
|
|
heading: '体质检测即将开放',
|
|
subheading: '九种体质入口先按设计稿保留为 UI-first 模式',
|
|
highlights: ['后续会补齐问卷式体质评估', '保持学习参考语义', '不会输出医疗诊断结论'],
|
|
examples: ['我总怕冷属于哪种体质?', '气虚质有哪些特征?', '体质结果将如何回到典籍学习?'],
|
|
formType: 'constitution',
|
|
actionTitle: '体质检测即将开放',
|
|
actionDescription:
|
|
'当前回合先严格对齐 UI 结构,问卷式体质检测会在后续接入真实题目与结果逻辑。',
|
|
actionButtonText: '查看其它待开放能力'
|
|
}
|
|
}
|
|
})
|
|
|
|
function cloneTabs(tabs) {
|
|
return tabs.map(item => ({ ...item }))
|
|
}
|
|
|
|
function cloneSecondaryFields(fields) {
|
|
return fields.map(item => ({ ...item }))
|
|
}
|
|
|
|
function createPanelByKey(panelKey) {
|
|
const sourcePanel = AI_PAGE_BLUEPRINT.panels[panelKey] || AI_PAGE_BLUEPRINT.panels.qa
|
|
|
|
return {
|
|
...sourcePanel,
|
|
highlights: [...sourcePanel.highlights],
|
|
examples: [...sourcePanel.examples],
|
|
primaryField: sourcePanel.primaryField ? { ...sourcePanel.primaryField } : undefined,
|
|
secondaryFields: sourcePanel.secondaryFields
|
|
? cloneSecondaryFields(sourcePanel.secondaryFields)
|
|
: undefined,
|
|
noteField: sourcePanel.noteField ? { ...sourcePanel.noteField } : undefined
|
|
}
|
|
}
|
|
|
|
function createAiPageData() {
|
|
return {
|
|
title: AI_PAGE_BLUEPRINT.title,
|
|
historyText: AI_PAGE_BLUEPRINT.historyText,
|
|
disclaimerText: AI_PAGE_BLUEPRINT.disclaimerText,
|
|
secondaryEntries: [
|
|
{
|
|
key: 'ai-history',
|
|
title: 'AI历史',
|
|
subtitle: '查看中医问答与辨证分析的静态历史页',
|
|
route: ROUTES.tcm.aiHistory
|
|
},
|
|
{
|
|
key: 'mingli-interpret',
|
|
title: '命理解读',
|
|
subtitle: '进入命理方向的静态解读页',
|
|
route: ROUTES.mingli.interpret
|
|
}
|
|
],
|
|
tabs: cloneTabs(AI_PAGE_BLUEPRINT.tabs),
|
|
activeTabKey: 'qa',
|
|
currentPanel: createPanelByKey('qa')
|
|
}
|
|
}
|
|
|
|
function showPlaceholderToast(title) {
|
|
if (typeof wx?.showToast === 'function') {
|
|
wx.showToast({
|
|
title: title || '功能建设中',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
}
|
|
|
|
function showNavigate(route) {
|
|
if (openStaticRoute(route, wx)) {
|
|
return
|
|
}
|
|
|
|
showPlaceholderToast()
|
|
}
|
|
|
|
Page({
|
|
data: createAiPageData(),
|
|
|
|
handleTabTap(event) {
|
|
const { tabKey } = event.currentTarget.dataset
|
|
|
|
if (!AI_PAGE_BLUEPRINT.panels[tabKey] || tabKey === this.data.activeTabKey) {
|
|
return
|
|
}
|
|
|
|
this.setData({
|
|
activeTabKey: tabKey,
|
|
currentPanel: createPanelByKey(tabKey)
|
|
})
|
|
},
|
|
|
|
handleHistoryTap() {
|
|
showNavigate(ROUTES.tcm.aiHistory)
|
|
},
|
|
|
|
handleSecondaryEntryTap(event) {
|
|
showNavigate(event.currentTarget.dataset.route)
|
|
},
|
|
|
|
handleActionTap() {
|
|
showPlaceholderToast()
|
|
}
|
|
})
|
|
|
|
module.exports = {
|
|
AI_PAGE_BLUEPRINT,
|
|
createPanelByKey,
|
|
createAiPageData
|
|
}
|