|
@@ -16,7 +16,9 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ <view class="action-buttons">
|
|
|
|
|
+ <button class="action-btn danger" @click="unbindDoctor">解除绑定</button>
|
|
|
|
|
+ </view>
|
|
|
|
|
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
@@ -32,7 +34,7 @@
|
|
|
import { ref, computed, onMounted } from 'vue'
|
|
import { ref, computed, onMounted } from 'vue'
|
|
|
import { onLoad, onShow } from '@dcloudio/uni-app'
|
|
import { onLoad, onShow } from '@dcloudio/uni-app'
|
|
|
import CustomNav from '@/components/custom-nav.vue'
|
|
import CustomNav from '@/components/custom-nav.vue'
|
|
|
-import { listUserBindingsByPatient, type UserBindingResponse, type UserBindingPageResponse } from '@/api/userBinding'
|
|
|
|
|
|
|
+import { listUserBindingsByPatient, deleteUserBinding, type UserBindingResponse, type UserBindingPageResponse } from '@/api/userBinding'
|
|
|
import { downloadAvatar } from '@/api/user'
|
|
import { downloadAvatar } from '@/api/user'
|
|
|
import { formatDate } from '@/utils/date'
|
|
import { formatDate } from '@/utils/date'
|
|
|
import { avatarCache } from '@/utils/avatarCache'
|
|
import { avatarCache } from '@/utils/avatarCache'
|
|
@@ -46,6 +48,7 @@ interface LocalDoctorInfo {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const doctorInfo = ref<LocalDoctorInfo | null>(null)
|
|
const doctorInfo = ref<LocalDoctorInfo | null>(null)
|
|
|
|
|
+const currentBinding = ref<UserBindingResponse | null>(null)
|
|
|
const userBindings = ref<UserBindingResponse[]>([])
|
|
const userBindings = ref<UserBindingResponse[]>([])
|
|
|
const pageData = ref({
|
|
const pageData = ref({
|
|
|
pageNum: 1,
|
|
pageNum: 1,
|
|
@@ -124,6 +127,7 @@ const fetchDoctorInfo = async () => {
|
|
|
// 如果有绑定的医生,获取第一个医生的详细信息
|
|
// 如果有绑定的医生,获取第一个医生的详细信息
|
|
|
if (pageResult.records && pageResult.records.length > 0) {
|
|
if (pageResult.records && pageResult.records.length > 0) {
|
|
|
const boundDoctor = pageResult.records[0]
|
|
const boundDoctor = pageResult.records[0]
|
|
|
|
|
+ currentBinding.value = boundDoctor
|
|
|
|
|
|
|
|
// 直接使用绑定接口返回的信息,不再调用额外的用户详情接口
|
|
// 直接使用绑定接口返回的信息,不再调用额外的用户详情接口
|
|
|
doctorInfo.value = {
|
|
doctorInfo.value = {
|
|
@@ -176,6 +180,56 @@ const bindDoctor = () => {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 解除绑定医生
|
|
|
|
|
+const unbindDoctor = () => {
|
|
|
|
|
+ if (!currentBinding.value) return
|
|
|
|
|
+
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ title: '确认解除绑定',
|
|
|
|
|
+ content: `确定要解除与 ${doctorInfo.value?.name} 的绑定关系吗?`,
|
|
|
|
|
+ success: async (res) => {
|
|
|
|
|
+ if (res.confirm) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ uni.showLoading({ title: '正在解除绑定...' })
|
|
|
|
|
+
|
|
|
|
|
+ // 调用解除绑定接口
|
|
|
|
|
+ const response = await deleteUserBinding({
|
|
|
|
|
+ patientUserId: currentBinding.value!.patientUserId,
|
|
|
|
|
+ boundUserId: currentBinding.value!.boundUserId
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+
|
|
|
|
|
+ const resp = response.data as any
|
|
|
|
|
+ if (resp && resp.code === 200) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '解除绑定成功',
|
|
|
|
|
+ icon: 'success'
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // 清空医生信息
|
|
|
|
|
+ doctorInfo.value = null
|
|
|
|
|
+ currentBinding.value = null
|
|
|
|
|
+ downloadedAvatar.value = null
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: resp?.message || '解除绑定失败',
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+ console.error('解除绑定失败:', error)
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '解除绑定失败',
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
onLoad(() => {
|
|
onLoad(() => {
|
|
|
fetchDoctorInfo()
|
|
fetchDoctorInfo()
|
|
|
})
|
|
})
|
|
@@ -270,6 +324,11 @@ onShow(() => {
|
|
|
color: #333;
|
|
color: #333;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+.danger {
|
|
|
|
|
+ background-color: #ff4757;
|
|
|
|
|
+ color: #fff;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
.empty-state {
|
|
.empty-state {
|
|
|
display: flex;
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
flex-direction: column;
|