Browse Source

feat(patient-family): 实现家属解绑功能并移除未完成按钮

- 移除了“健康动态”、“发送提醒”和“邀请复诊”按钮
- 新增“解除绑定”危险操作按钮
- 引入 deleteUserBinding API 用于解除家属绑定
- 添加确认弹窗提示用户二次确认解绑操作
- 解绑成功后自动刷新家属列表
- 增加 .danger 样式类用于标示危险操作按钮
- 实现完整的解绑逻辑包括加载状态和错误处理
mcbaiyun 1 month ago
parent
commit
38101e5aeb
1 changed files with 48 additions and 23 deletions
  1. 48 23
      src/pages/patient-family/index/my-family.vue

+ 48 - 23
src/pages/patient-family/index/my-family.vue

@@ -17,9 +17,7 @@
       
       <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="inviteRevisitInfo">邀请复诊</button>
+        <button class="action-btn danger" @click="unbindFamily(family)">解除绑定</button>
       </view>
     </view>
     
@@ -34,7 +32,7 @@
 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 { listUserBindingsByBoundUser, deleteUserBinding, type UserBindingResponse, type UserBindingPageResponse } from '@/api/userBinding'
 import { downloadAvatar } from '@/api/user'
 import { avatarCache } from '@/utils/avatarCache'
 
@@ -150,26 +148,48 @@ const viewHealthData = (family: FamilyInfo) => {
   })
 }
 
-const viewHealthNews = (family: FamilyInfo) => {
-  uni.showToast({
-    title: '健康动态功能开发中',
-    icon: 'none'
-  })
-}
-
-const sendReminder = (family: FamilyInfo) => {
-  uni.showToast({
-    title: '发送提醒功能开发中',
-    icon: 'none'
-  })
-}
-
-const inviteRevisitInfo = () => {
+const unbindFamily = (family: FamilyInfo) => {
   uni.showModal({
-    title: '提示',
-    content: '根据最新规定,家属不能主动邀请复诊。患者需要在患者端主动发起复诊请求。',
-    showCancel: false,
-    confirmText: '知道了'
+    title: '确认解除绑定',
+    content: `确定要解除与 ${family.boundUserNickname} 的绑定关系吗?`,
+    success: async (res) => {
+      if (res.confirm) {
+        try {
+          uni.showLoading({ title: '正在解除绑定...' })
+          
+          // 调用解除绑定接口
+          const response = await deleteUserBinding({
+            patientUserId: family.patientUserId,
+            boundUserId: family.boundUserId
+          })
+          
+          uni.hideLoading()
+          
+          const resp = response.data as any
+          if (resp && resp.code === 200) {
+            uni.showToast({
+              title: '解除绑定成功',
+              icon: 'success'
+            })
+            
+            // 重新加载家人列表
+            fetchFamilies()
+          } else {
+            uni.showToast({
+              title: resp?.message || '解除绑定失败',
+              icon: 'none'
+            })
+          }
+        } catch (error) {
+          uni.hideLoading()
+          console.error('解除绑定失败:', error)
+          uni.showToast({
+            title: '解除绑定失败',
+            icon: 'none'
+          })
+        }
+      }
+    }
   })
 }
 
@@ -270,6 +290,11 @@ onShow(() => {
   color: #333;
 }
 
+.danger {
+  background-color: #ff4757;
+  color: #fff;
+}
+
 .empty-state {
   display: flex;
   flex-direction: column;