feat(mp): 小程序功能完善 — 服务层扩展 + 页面优化

- 新增 actionInbox 服务层(待办事项列表/线程查询)
- consultation 服务扩展(会话详情/发送消息)
- 多页面代码优化(profile/messages/health/article)
- 新增 navigate 工具函数
This commit is contained in:
iven
2026-05-13 23:26:38 +08:00
parent 93c77c5857
commit 616e0a1539
10 changed files with 141 additions and 23 deletions

View File

@@ -69,13 +69,12 @@ function GuestHome({ modeClass }: { modeClass: string }) {
]);
if (bannerData.status === 'fulfilled' && bannerData.value?.length > 0) {
const baseUrl = process.env.TARO_APP_API_URL || 'http://localhost:3000/api/v1';
const fileBase = baseUrl.replace(/\/api\/v1$/, '');
const apiBase = process.env.TARO_APP_API_URL || 'http://localhost:3000/api/v1';
const withLocal = await Promise.all(
bannerData.value.map(async (b) => {
if (!b.image_url) return b;
try {
const fullUrl = b.image_url.startsWith('http') ? b.image_url : `${fileBase}${b.image_url}`;
const fullUrl = b.image_url.startsWith('http') ? b.image_url : `${apiBase}${b.image_url}`;
const res = await Taro.downloadFile({ url: fullUrl });
if (res.tempFilePath) {
return { ...b, local_path: res.tempFilePath };
@@ -94,6 +93,7 @@ function GuestHome({ modeClass }: { modeClass: string }) {
}
} catch {
setBanners(FALLBACK_SLIDES);
Taro.showToast({ title: '内容加载失败', icon: 'none' });
}
};
@@ -135,7 +135,11 @@ function GuestHome({ modeClass }: { modeClass: string }) {
{articles.length > 0 ? (
<View className='guest-articles'>
{articles.map((article) => (
<View className='guest-article-card' key={article.id}>
<View
className='guest-article-card'
key={article.id}
onClick={() => Taro.navigateTo({ url: `/pages/article/detail/index?id=${article.id}` })}
>
{article.cover_image && (
<Image className='guest-article-cover' src={article.cover_image} mode='aspectFill' />
)}
@@ -261,7 +265,7 @@ function HomeDashboard({ modeClass }: { modeClass: string }) {
const hour = new Date().getHours();
const greeting = hour < 12 ? '上午好' : hour < 18 ? '下午好' : '晚上好';
const displayName = user?.display_name || currentPatient?.name || '访客';
const displayName = user?.display_name || currentPatient?.name || user?.username || (user?.phone ? `${user.phone.slice(-4)}` : '') || '用户';
const summary = todaySummary || {};
const indicators = [!!summary.blood_pressure, !!summary.heart_rate, !!summary.blood_sugar, !!summary.weight];