瀏覽代碼

feat(patient-family): 新增我的家人页面及功能调整

- 在 pages.json 中添加 my-family 页面路径配置
- 修改 index.vue 页面,将健康监控、联系医生、疑问解答等功能替换为健康知识模块
- 新增 my-family.vue 页面,用于展示家属绑定的家人列表及相关操作按钮
- 实现家人列表的数据获取逻辑,包括分页和头像下载功能
- 添加空状态提示,当没有绑定家人时显示相应图标和文字
- 调整样式布局,优化家庭成员卡片的视觉呈现效果
- 暂时禁用部分功能按钮,并给出开发中的提示信息
mcbaiyun 1 月之前
父節點
當前提交
01754cbd51
共有 3 個文件被更改,包括 295 次插入30 次删除
  1. 6 0
      src/pages.json
  2. 6 30
      src/pages/patient-family/index/index.vue
  3. 283 0
      src/pages/patient-family/index/my-family.vue

+ 6 - 0
src/pages.json

@@ -126,6 +126,12 @@
 				"navigationBarTitleText": "家属基本信息"
 			}
 		},
+		{
+			"path": "pages/patient-family/index/my-family",
+			"style": {
+				"navigationBarTitleText": "我的家人"
+			}
+		},
 		{
 			"path": "pages/public/profile/qr/index",
 			"style": {

+ 6 - 30
src/pages/patient-family/index/index.vue

@@ -30,33 +30,13 @@
               <text class="item-desc">管理被监护的家人</text>
             </view>
           </view>
-          <view class="function-item green" @click="onItemClick('健康监控')">
+          <view class="function-item purple" @click="onItemClick('健康知识')">
             <view class="item-content">
               <view class="title-row">
                 <view class="item-line"></view>
-                <text class="item-title">健康监控</text>
+                <text class="item-title">健康知识</text>
               </view>
-              <text class="item-desc">查看家人健康数据</text>
-            </view>
-          </view>
-        </view>
-        <view class="function-row">
-          <view class="function-item orange" @click="onItemClick('联系医生')">
-            <view class="item-content">
-              <view class="title-row">
-                <view class="item-line"></view>
-                <text class="item-title">联系医生</text>
-              </view>
-              <text class="item-desc">与医生沟通交流</text>
-            </view>
-          </view>
-          <view class="function-item purple" @click="onItemClick('疑问解答')">
-            <view class="item-content">
-              <view class="title-row">
-                <view class="item-line"></view>
-                <text class="item-title">疑问解答</text>
-              </view>
-              <text class="item-desc">咨询健康相关问题</text>
+              <text class="item-desc">获取健康相关知识</text>
             </view>
           </view>
         </view>
@@ -277,13 +257,9 @@ function handleScan(res: any) {
 
 function onItemClick(type: string) {
   if (type === '家人管理') {
-    uni.navigateTo({ url: '/pages/patient-family/family/index' })
-  } else if (type === '健康监控') {
-    uni.navigateTo({ url: '/pages/patient-family/health/index' })
-  } else if (type === '联系医生') {
-    uni.navigateTo({ url: '/pages/patient-family/doctor/index' })
-  } else if (type === '疑问解答') {
-    uni.navigateTo({ url: '/pages/patient-family/qa/index' })
+    uni.navigateTo({ url: '/pages/patient-family/index/my-family' })
+  } else if (type === '健康知识') {
+    uni.showToast({ title: '健康知识功能开发中', icon: 'none' })
   } else {
     uni.showToast({ title: '功能正在开发中', icon: 'none' })
   }

+ 283 - 0
src/pages/patient-family/index/my-family.vue

@@ -0,0 +1,283 @@
+<template>
+  <CustomNav title="我的家人" leftType="back" />
+  <view class="page-container">
+    <view class="family-card" v-for="family in families" :key="family.id">
+      <view class="family-header">
+        <view class="avatar-section">
+          <view class="avatar-frame">
+            <image class="avatar-img" :src="familyAvatar(family)" mode="aspectFill" />
+          </view>
+        </view>
+        <view class="family-info">
+          <text class="family-name">{{ family.boundUserNickname }}</text>
+          <text class="family-phone" v-if="family.boundUserPhone">联系电话: {{ family.boundUserPhone }}</text>
+          <text class="family-phone" v-else>联系电话: 未提供</text>
+        </view>
+      </view>
+      
+      <view class="action-buttons">
+        <button class="action-btn primary" @click="viewHealthData(family)">健康数据</button>
+        <button class="action-btn secondary" @click="viewHealthNews(family)">健康动态</button>
+        <button class="action-btn secondary" @click="sendReminder(family)">发送提醒</button>
+        <button class="action-btn secondary" @click="inviteRevisit(family)">邀请复诊</button>
+      </view>
+    </view>
+    
+    <view class="empty-state" v-if="families.length === 0">
+      <image class="empty-icon" src="/static/icons/remixicon/account-circle-line.svg" />
+      <text class="empty-text">暂无绑定的家人</text>
+    </view>
+  </view>
+</template>
+
+<script setup lang="ts">
+import { ref } from 'vue'
+import { onLoad, onShow } from '@dcloudio/uni-app'
+import CustomNav from '@/components/custom-nav.vue'
+import { listUserBindingsByBoundUser, type UserBindingResponse, type UserBindingPageResponse } from '@/api/userBinding'
+import { downloadAvatar } from '@/api/user'
+
+interface FamilyInfo extends UserBindingResponse {
+  avatar?: string
+}
+
+const families = ref<FamilyInfo[]>([])
+const pageData = ref({
+  pageNum: 1,
+  pageSize: 10,
+  total: 0,
+  pages: 0
+})
+
+const defaultAvatar = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
+
+// 获取家人列表
+const fetchFamilies = async () => {
+  uni.showLoading({ title: '加载中...' })
+  
+  try {
+    const token = uni.getStorageSync('token')
+    if (!token) {
+      uni.hideLoading()
+      uni.showToast({
+        title: '未登录',
+        icon: 'none'
+      })
+      return
+    }
+    
+    // 获取当前用户ID(家属ID)
+    const userInfo = uni.getStorageSync('user_info')
+    const familyUserId = userInfo?.id
+    
+    if (!familyUserId) {
+      uni.hideLoading()
+      uni.showToast({
+        title: '获取用户信息失败',
+        icon: 'none'
+      })
+      return
+    }
+    
+    // 查询家属绑定的家人列表(使用新的接口)
+    const response = await listUserBindingsByBoundUser(
+      familyUserId, 
+      'PATIENT', 
+      {
+        pageNum: pageData.value.pageNum,
+        pageSize: pageData.value.pageSize
+      }
+    )
+    
+    uni.hideLoading()
+    
+    const resp = response.data as any
+    
+    if (resp && resp.code === 200 && resp.data) {
+      const pageResult = resp.data as UserBindingPageResponse
+      families.value = pageResult.records as FamilyInfo[]
+      pageData.value.total = pageResult.total
+      pageData.value.pages = pageResult.pages
+      
+      // 为每个家人尝试下载头像
+      for (const family of families.value) {
+        try {
+          if (family.patientUserId) {
+            const dlRes: any = await downloadAvatar(String(family.patientUserId))
+            if (dlRes && dlRes.statusCode === 200 && dlRes.tempFilePath) {
+              family.avatar = dlRes.tempFilePath
+            }
+          }
+        } catch (err) {
+          console.warn('下载家人头像失败:', err)
+        }
+      }
+    } else {
+      uni.showToast({
+        title: '获取家人信息失败',
+        icon: 'none'
+      })
+    }
+  } catch (error) {
+    uni.hideLoading()
+    console.error('获取家人信息失败:', error)
+    uni.showToast({
+      title: '获取家人信息失败',
+      icon: 'none'
+    })
+  }
+}
+
+const familyAvatar = (family: FamilyInfo) => {
+  if (family.avatar) {
+    return family.avatar
+  }
+  return defaultAvatar
+}
+
+const viewHealthData = (family: FamilyInfo) => {
+  uni.showToast({
+    title: '健康数据功能开发中',
+    icon: 'none'
+  })
+}
+
+const viewHealthNews = (family: FamilyInfo) => {
+  uni.showToast({
+    title: '健康动态功能开发中',
+    icon: 'none'
+  })
+}
+
+const sendReminder = (family: FamilyInfo) => {
+  uni.showToast({
+    title: '发送提醒功能开发中',
+    icon: 'none'
+  })
+}
+
+const inviteRevisit = (family: FamilyInfo) => {
+  uni.showToast({
+    title: '邀请复诊功能开发中',
+    icon: 'none'
+  })
+}
+
+onLoad(() => {
+  fetchFamilies()
+})
+
+// 如果在微信小程序端且未登录,自动跳转到登录页
+onShow(() => {
+  const token = uni.getStorageSync('token')
+  if (!token) {
+    uni.reLaunch({ url: '/pages/public/login/index' })
+  }
+})
+</script>
+
+<style scoped>
+.page-container {
+  min-height: 100vh;
+  background-color: #f5f5f5;
+  padding-top: calc(var(--status-bar-height) + 44px);
+  padding-bottom: 40rpx;
+}
+
+.family-card {
+  background-color: #fff;
+  margin: 20rpx;
+  border-radius: 20rpx;
+  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
+  overflow: hidden;
+}
+
+.family-header {
+  display: flex;
+  padding: 40rpx;
+  border-bottom: 1rpx solid #eee;
+}
+
+.avatar-section {
+  margin-right: 30rpx;
+}
+
+.avatar-frame {
+  width: 120rpx;
+  height: 120rpx;
+  border-radius: 50%;
+  overflow: hidden;
+  border: 1px solid rgba(128, 128, 128, 0.5);
+}
+
+.avatar-img {
+  width: 100%;
+  height: 100%;
+  object-fit: cover;
+}
+
+.family-info {
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+}
+
+.family-name {
+  font-size: 36rpx;
+  font-weight: bold;
+  color: #333;
+  margin-bottom: 10rpx;
+}
+
+.family-phone {
+  font-size: 28rpx;
+  color: #666;
+}
+
+.action-buttons {
+  display: flex;
+  padding: 30rpx 40rpx;
+  gap: 20rpx;
+  flex-wrap: wrap;
+}
+
+.action-btn {
+  flex: 1;
+  border-radius: 10rpx;
+  font-size: 28rpx;
+  line-height: 70rpx;
+  min-width: 40%;
+}
+
+.primary {
+  background-color: #3742fa;
+  color: #fff;
+}
+
+.secondary {
+  background-color: #f0f0f0;
+  color: #333;
+}
+
+.empty-state {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+  padding: 100rpx 40rpx;
+}
+
+.empty-icon {
+  width: 120rpx;
+  height: 120rpx;
+  margin-bottom: 30rpx;
+  opacity: 0.5;
+}
+
+.empty-text {
+  font-size: 32rpx;
+  color: #666;
+  margin-bottom: 40rpx;
+}
+</style>