|
|
@@ -53,6 +53,7 @@ import { ref, computed } from 'vue'
|
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
|
import CustomNav from '@/components/custom-nav.vue'
|
|
|
import { listUserBindingsByPatient, type UserBindingResponse, type UserBindingPageResponse } from '@/api/userBinding'
|
|
|
+import { downloadAvatar } from '@/api/user'
|
|
|
import { getUserInfo } from '@/api/user'
|
|
|
|
|
|
// 为避免与导入的类型冲突,重命名本地接口
|
|
|
@@ -79,7 +80,14 @@ const pageData = ref({
|
|
|
|
|
|
const defaultAvatar = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
|
|
|
|
|
+// 下载后本地临时保存的图片路径(uni.downloadFile 会产出 tempFilePath)
|
|
|
+const downloadedAvatar = ref<string | null>(null)
|
|
|
+
|
|
|
+// 优先使用已下载的本地头像,若无则使用后端返回的 avatar 字段,再次 fallback 到默认头像
|
|
|
const doctorAvatar = computed(() => {
|
|
|
+ if (downloadedAvatar.value) {
|
|
|
+ return downloadedAvatar.value
|
|
|
+ }
|
|
|
if (doctorInfo.value?.avatar) {
|
|
|
return doctorInfo.value.avatar
|
|
|
}
|
|
|
@@ -157,6 +165,17 @@ const fetchDoctorInfo = async () => {
|
|
|
introduction: userInfo.introduction || '暂无介绍',
|
|
|
avatar: userInfo.avatar
|
|
|
}
|
|
|
+ // 尝试从后端下载用户头像(如果后端未返回 avatar 或想替换为下载后的临时路径)
|
|
|
+ try {
|
|
|
+ if (boundDoctor.boundUserId) {
|
|
|
+ const dlRes: any = await downloadAvatar(String(boundDoctor.boundUserId))
|
|
|
+ if (dlRes && dlRes.statusCode === 200 && dlRes.tempFilePath) {
|
|
|
+ downloadedAvatar.value = dlRes.tempFilePath
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ console.warn('下载医生头像失败:', err)
|
|
|
+ }
|
|
|
} else {
|
|
|
// 如果获取详细信息失败,使用绑定接口返回的基础信息
|
|
|
doctorInfo.value = {
|
|
|
@@ -169,6 +188,17 @@ const fetchDoctorInfo = async () => {
|
|
|
specialty: '未知',
|
|
|
introduction: '暂无介绍'
|
|
|
}
|
|
|
+ // 尝试下载头像(绑定接口返回的数据中可能没有 avatar)
|
|
|
+ try {
|
|
|
+ if (boundDoctor.boundUserId) {
|
|
|
+ const dlRes: any = await downloadAvatar(String(boundDoctor.boundUserId))
|
|
|
+ if (dlRes && dlRes.statusCode === 200 && dlRes.tempFilePath) {
|
|
|
+ downloadedAvatar.value = dlRes.tempFilePath
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ console.warn('下载医生头像失败:', err)
|
|
|
+ }
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('获取医生详细信息失败:', error)
|