From 0fe4cab5930687e64bba4d931cba622b78003f94 Mon Sep 17 00:00:00 2001 From: iven Date: Fri, 24 Apr 2026 12:47:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(miniprogram):=20=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E6=B6=88=E6=81=AF=E5=BC=95=E5=AF=BC=20+=20?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83=E6=B6=88=E6=81=AF=20badge?= =?UTF-8?q?=20=E5=8D=A0=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 wechat-templates.ts 集中管理模板 ID - 预约成功后引导用户订阅预约提醒 - 随访记录提交后引导订阅随访提醒 - 个人中心新增消息中心入口 + 未读数 badge(MVP 占位 unreadCount: 0) --- .../src/pages/appointment/create/index.tsx | 8 ++++++++ .../src/pages/followup/detail/index.tsx | 5 +++++ apps/miniprogram/src/pages/profile/index.scss | 18 ++++++++++++++++++ apps/miniprogram/src/pages/profile/index.tsx | 7 +++++++ .../src/services/wechat-templates.ts | 5 +++++ 5 files changed, 43 insertions(+) create mode 100644 apps/miniprogram/src/services/wechat-templates.ts diff --git a/apps/miniprogram/src/pages/appointment/create/index.tsx b/apps/miniprogram/src/pages/appointment/create/index.tsx index 664c73e..c554924 100644 --- a/apps/miniprogram/src/pages/appointment/create/index.tsx +++ b/apps/miniprogram/src/pages/appointment/create/index.tsx @@ -3,6 +3,7 @@ import { View, Text, Input } from '@tarojs/components'; import Taro from '@tarojs/taro'; import { listDoctors, createAppointment, calendarView } from '../../../services/appointment'; import { useAuthStore } from '../../../stores/auth'; +import { TEMPLATE_IDS } from '@/services/wechat-templates'; import StepIndicator from '../../../components/StepIndicator'; import WeekCalendar from '../../../components/WeekCalendar'; import './index.scss'; @@ -111,6 +112,13 @@ export default function AppointmentCreate() { reason: reason.trim() || undefined, }); Taro.showToast({ title: '预约成功', icon: 'success' }); + // 订阅消息引导 + const tmplId = TEMPLATE_IDS.APPOINTMENT_REMINDER; + if (tmplId) { + try { + await Taro.requestSubscribeMessage({ tmplIds: [tmplId] }); + } catch { /* 用户拒绝 */ } + } setTimeout(() => Taro.navigateBack(), 1500); } catch { Taro.showToast({ title: '预约失败', icon: 'none' }); diff --git a/apps/miniprogram/src/pages/followup/detail/index.tsx b/apps/miniprogram/src/pages/followup/detail/index.tsx index 1cd7c7b..be0d18e 100644 --- a/apps/miniprogram/src/pages/followup/detail/index.tsx +++ b/apps/miniprogram/src/pages/followup/detail/index.tsx @@ -3,6 +3,7 @@ import { View, Text, Textarea } from '@tarojs/components'; import Taro, { useRouter } from '@tarojs/taro'; import { getTaskDetail, submitRecord } from '../../../services/followup'; import type { FollowUpTask } from '../../../services/followup'; +import { TEMPLATE_IDS } from '@/services/wechat-templates'; import Loading from '../../../components/Loading'; import ErrorState from '../../../components/ErrorState'; import './index.scss'; @@ -41,6 +42,10 @@ export default function FollowUpDetail() { content: { text: content.trim() }, }); Taro.showToast({ title: '提交成功', icon: 'success' }); + const tmplId = TEMPLATE_IDS.FOLLOWUP_REMINDER; + if (tmplId) { + try { await Taro.requestSubscribeMessage({ tmplIds: [tmplId] }); } catch { /* 用户拒绝 */ } + } setContent(''); } catch { Taro.showToast({ title: '提交失败', icon: 'none' }); diff --git a/apps/miniprogram/src/pages/profile/index.scss b/apps/miniprogram/src/pages/profile/index.scss index b7833ce..3169ecb 100644 --- a/apps/miniprogram/src/pages/profile/index.scss +++ b/apps/miniprogram/src/pages/profile/index.scss @@ -72,6 +72,24 @@ color: $tx3; } +.menu-badge { + background: $dan; + border-radius: 20px; + min-width: 36px; + height: 36px; + display: flex; + align-items: center; + justify-content: center; + padding: 0 10px; + margin-right: 12px; +} + +.menu-badge-text { + font-size: 20px; + color: white; + font-weight: bold; +} + .profile-logout { margin: 24px; background: $card; diff --git a/apps/miniprogram/src/pages/profile/index.tsx b/apps/miniprogram/src/pages/profile/index.tsx index 0dc817a..3c13c41 100644 --- a/apps/miniprogram/src/pages/profile/index.tsx +++ b/apps/miniprogram/src/pages/profile/index.tsx @@ -4,6 +4,7 @@ import { useAuthStore } from '../../stores/auth'; import './index.scss'; const MENU_ITEMS = [ + { label: '消息中心', icon: '🔔', path: '/pages/profile/messages/index', badge: true }, { label: '就诊人管理', icon: '👥', path: '/pages/profile/family/index' }, { label: '我的报告', icon: '📋', path: '/pages/profile/reports/index' }, { label: '我的随访', icon: '💬', path: '/pages/profile/followups/index' }, @@ -13,6 +14,7 @@ const MENU_ITEMS = [ export default function Profile() { const { user, restore: restoreAuth, logout } = useAuthStore(); + const unreadCount = 0; // MVP 占位,后续对接 erp-message API useDidShow(() => { restoreAuth(); @@ -54,6 +56,11 @@ export default function Profile() { > {item.icon} {item.label} + {item.badge && unreadCount > 0 && ( + + {unreadCount > 99 ? '99+' : unreadCount} + + )} ))} diff --git a/apps/miniprogram/src/services/wechat-templates.ts b/apps/miniprogram/src/services/wechat-templates.ts new file mode 100644 index 0000000..7d3c2aa --- /dev/null +++ b/apps/miniprogram/src/services/wechat-templates.ts @@ -0,0 +1,5 @@ +export const TEMPLATE_IDS = { + APPOINTMENT_REMINDER: '', + FOLLOWUP_REMINDER: '', + REPORT_NOTIFICATION: '', +};