feat(miniprogram): 微信订阅消息引导 + 个人中心消息 badge 占位
- 新增 wechat-templates.ts 集中管理模板 ID - 预约成功后引导用户订阅预约提醒 - 随访记录提交后引导订阅随访提醒 - 个人中心新增消息中心入口 + 未读数 badge(MVP 占位 unreadCount: 0)
This commit is contained in:
@@ -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' });
|
||||
|
||||
@@ -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' });
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
))}
|
||||
|
||||
5
apps/miniprogram/src/services/wechat-templates.ts
Normal file
5
apps/miniprogram/src/services/wechat-templates.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export const TEMPLATE_IDS = {
|
||||
APPOINTMENT_REMINDER: '',
|
||||
FOLLOWUP_REMINDER: '',
|
||||
REPORT_NOTIFICATION: '',
|
||||
};
|
||||
Reference in New Issue
Block a user