feat(miniprogram): 微信订阅消息引导 + 个人中心消息 badge 占位
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

- 新增 wechat-templates.ts 集中管理模板 ID
- 预约成功后引导用户订阅预约提醒
- 随访记录提交后引导订阅随访提醒
- 个人中心新增消息中心入口 + 未读数 badge(MVP 占位 unreadCount: 0)
This commit is contained in:
iven
2026-04-24 12:47:25 +08:00
parent 38e53efaec
commit 0fe4cab593
5 changed files with 43 additions and 0 deletions

View File

@@ -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' });

View File

@@ -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' });

View File

@@ -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;

View File

@@ -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() {
>
<Text className='menu-icon'>{item.icon}</Text>
<Text className='menu-label'>{item.label}</Text>
{item.badge && unreadCount > 0 && (
<View className='menu-badge'>
<Text className='menu-badge-text'>{unreadCount > 99 ? '99+' : unreadCount}</Text>
</View>
)}
<Text className='menu-arrow'></Text>
</View>
))}

View File

@@ -0,0 +1,5 @@
export const TEMPLATE_IDS = {
APPOINTMENT_REMINDER: '',
FOLLOWUP_REMINDER: '',
REPORT_NOTIFICATION: '',
};