Explorar o código

feat(user-binding): 新增解除用户绑定功能

- 在 userBinding API 中新增 DeleteUserBindingRequest 接口
- 实现 deleteUserBinding 方法用于删除用户绑定关系
- 在我的患者页面中替换操作按钮,新增“解除绑定”功能
- 引入 deleteUserBinding 接口并实现解绑逻辑
- 更新按钮样式,将 secondary 替换为 danger 样式
- 移除未使用的健康动态、发送提醒和邀请复诊按钮功能
mcbaiyun hai 1 mes
pai
achega
c87cfdd2b9
Modificáronse 2 ficheiros con 63 adicións e 26 borrados
  1. 16 0
      src/api/userBinding.ts
  2. 47 26
      src/pages/doctor/index/my-patients.vue

+ 16 - 0
src/api/userBinding.ts

@@ -31,6 +31,11 @@ export interface UserBindingPageResponse {
   pages: number
 }
 
+export interface DeleteUserBindingRequest {
+  patientUserId: string
+  boundUserId: string
+}
+
 import request from './request'
 
 export async function listUserBindingsByPatient(
@@ -104,6 +109,17 @@ export async function createUserBinding(payload: any) {
   return res
 }
 
+// 删除用户绑定关系 POST /user-binding/delete
+export async function deleteUserBinding(payload: DeleteUserBindingRequest) {
+  const res: any = await request({
+    url: 'https://wx.baiyun.work/user-binding/delete',
+    method: 'POST',
+    header: { 'Content-Type': 'application/json' },
+    data: payload
+  })
+  return res
+}
+
 // 检查用户绑定关系 POST /user-binding/check
 // 检查绑定关系:支持将 Snowflake ID 以字符串传入,避免精度问题
 export async function checkUserBinding(payload: { patientUserId: string | number; boundUserId: string | number }) {

+ 47 - 26
src/pages/doctor/index/my-patients.vue

@@ -17,9 +17,7 @@
       
       <view class="action-buttons">
         <button class="action-btn primary" @click="viewHealthData(patient)">健康数据</button>
-        <button class="action-btn secondary" @click="viewHealthNews(patient)">健康动态</button>
-        <button class="action-btn secondary" @click="sendReminder(patient)">发送提醒</button>
-        <button class="action-btn secondary" @click="inviteRevisitInfo">邀请复诊</button>
+        <button class="action-btn danger" @click="unbindPatient(patient)">解除绑定</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,49 @@ const viewHealthData = (patient: PatientInfo) => {
   })
 }
 
-const viewHealthNews = (patient: PatientInfo) => {
-  uni.showToast({
-    title: '健康动态功能开发中',
-    icon: 'none'
-  })
-}
-
-const sendReminder = (patient: PatientInfo) => {
-  uni.showToast({
-    title: '发送提醒功能开发中',
-    icon: 'none'
-  })
-}
-
-const inviteRevisitInfo = () => {
+// 解除绑定
+const unbindPatient = (patient: PatientInfo) => {
   uni.showModal({
-    title: '提示',
-    content: '根据最新规定,医生不能主动邀请复诊。患者需要在患者端主动发起复诊请求。',
-    showCancel: false,
-    confirmText: '知道了'
+    title: '确认解除绑定',
+    content: `确定要解除与 ${patient.boundUserNickname} 的绑定关系吗?`,
+    success: async (res) => {
+      if (res.confirm) {
+        try {
+          uni.showLoading({ title: '正在解除绑定...' })
+          
+          // 调用解除绑定接口
+          const response = await deleteUserBinding({
+            patientUserId: patient.patientUserId,
+            boundUserId: patient.boundUserId
+          })
+          
+          uni.hideLoading()
+          
+          const resp = response.data as any
+          if (resp && resp.code === 200) {
+            uni.showToast({
+              title: '解除绑定成功',
+              icon: 'success'
+            })
+            
+            // 重新加载病人列表
+            fetchPatients()
+          } else {
+            uni.showToast({
+              title: resp?.message || '解除绑定失败',
+              icon: 'none'
+            })
+          }
+        } catch (error) {
+          uni.hideLoading()
+          console.error('解除绑定失败:', error)
+          uni.showToast({
+            title: '解除绑定失败',
+            icon: 'none'
+          })
+        }
+      }
+    }
   })
 }
 
@@ -265,9 +286,9 @@ onShow(() => {
   color: #fff;
 }
 
-.secondary {
-  background-color: #f0f0f0;
-  color: #333;
+.danger {
+  background-color: #ff4757;
+  color: #fff;
 }
 
 .empty-state {