diff --git a/pages/home/home.vue b/pages/home/home.vue index 3252a10..e671d58 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -248,7 +248,7 @@ import { storeList } from '../../request/api/api' import { getPlatformQualificationsApi } from '../../request/api/platform' -import { getStoreDrugListBySalespersonApi, getHomeTopProductsApi, getHomeZonesApi } from "@/request/api/product"; +import { getStoreDrugListBySalespersonApi, getHomeTopProductsApi, getHomeZonesApi, checkOnlineConsultationConfigApi } from "@/request/api/product"; import request from "@/request/api/request"; export default { @@ -318,20 +318,36 @@ export default { url: '/pages/Inquiries/Inquiries?type=' + type }) }, - golist(type) { + async golist(type) { if (type === 3) { - // 检查是否配置了在线复诊负责人 - if (!this.defaultDoctorId) { + // 检查药店在线复诊配置(委托诊所和医生) + try { + const storeId = uni.getStorageSync('store_id'); + const res = await checkOnlineConsultationConfigApi({ store_id: storeId }); + if (!res.data?.result?.can_use) { + uni.showToast({ + title: res.data?.result?.message || '该药店暂不支持在线复诊功能', + icon: 'none', + duration: 2000 + }); + return; + } + // 使用接口返回的医生ID + const doctorId = res.data.result.doctor_id || this.defaultDoctorId; + // 获取委托诊所ID,如果有委托诊所则使用委托诊所ID,否则使用当前诊所ID + const delegateStoreId = res.data.result.delegate_store_id || storeId; + return uni.navigateTo({ + url: '/subPackages/product/product?doctor_id=' + doctorId + '®ister_type=3&delegate_store_id=' + delegateStoreId + }); + } catch (error) { + console.error('检查在线复诊配置失败:', error); uni.showToast({ - title: '该门店暂不支持在线复诊', + title: '网络异常,请稍后重试', icon: 'none', duration: 2000 }); return; } - return uni.navigateTo({ - url: '/subPackages/product/product?doctor_id=' + this.defaultDoctorId + '®ister_type=3' - }) } uni.navigateTo({ url: '/pages/Inquiries/Inquiries?type=' + type @@ -592,19 +608,34 @@ export default { }); }, // 直接购买 - buyProduct(item) { - // 检查是否配置了在线复诊负责人 - if (!this.defaultDoctorId) { + async buyProduct(item) { + // 检查药店在线复诊配置(委托诊所和医生) + try { + const storeId = uni.getStorageSync('store_id'); + const res = await checkOnlineConsultationConfigApi({ store_id: storeId }); + if (!res.data?.result?.can_use) { + uni.showToast({ + title: res.data?.result?.message || '该药店暂不支持在线复诊功能', + icon: 'none', + duration: 2000 + }); + return; + } + // 使用接口返回的医生ID + const doctorId = res.data.result.doctor_id || this.defaultDoctorId; + // 获取委托诊所ID,如果有委托诊所则使用委托诊所ID,否则使用当前诊所ID + const delegateStoreId = res.data.result.delegate_store_id || storeId; + uni.navigateTo({ + url: `/subPackages/product/product?doctor_id=${doctorId}®ister_type=3&delegate_store_id=${delegateStoreId}` + }); + } catch (error) { + console.error('检查在线复诊配置失败:', error); uni.showToast({ - title: '该门店暂不支持在线复诊', + title: '网络异常,请稍后重试', icon: 'none', duration: 2000 }); - return; } - uni.navigateTo({ - url: `/subPackages/product/product?doctor_id=${this.defaultDoctorId}®ister_type=3` - }); }, // 预览资质证明 previewQualification(item) { diff --git a/request/api/im.js b/request/api/im.js index e736d62..628d282 100644 --- a/request/api/im.js +++ b/request/api/im.js @@ -60,4 +60,13 @@ export async function getChatRegisterInfoApi(params) { export function upLoadChatFileApi(params) { return console.log('aaaaaaaaaaaaaaaaaaa', uploadFile('/chat-friends/upload-chat-file', params)) return uploadFile('/chat-friends/upload-chat-file', params) +} + +/** + * 获取医生信息 + * @param params { doctor_id: string } + * @returns {Promise<*>} + */ +export async function getDoctorInfoApi(params) { + return await get('/chat-friends/get-doctor-info', params, 3) } \ No newline at end of file diff --git a/request/api/product.js b/request/api/product.js index 598788e..bb65726 100644 --- a/request/api/product.js +++ b/request/api/product.js @@ -47,4 +47,13 @@ export async function getHomeZonesApi(params) { */ export async function updateIntroductionImagesApi(params) { return await post('/product/update-introduction-images', params, 3) +} + +/** + * 检查药店在线复诊配置(委托诊所和医生) + * @param params { store_id: number } + * @returns {Promise<*>} + */ +export async function checkOnlineConsultationConfigApi(params) { + return await get('/store/check-online-consultation-config', params, 3) } \ No newline at end of file diff --git a/subPackages/chat/chat.vue b/subPackages/chat/chat.vue index 7c0e712..a2b83d5 100644 --- a/subPackages/chat/chat.vue +++ b/subPackages/chat/chat.vue @@ -524,7 +524,7 @@ */ import { webSocketManager } from '@/utils/ws/websocket'; import { ChatManager } from '@/store/chat/chat.js'; -import {getChatRegisterInfoApi, sendToUserApi, upLoadChatFileApi} from "@/request/api/im"; +import {getChatRegisterInfoApi, sendToUserApi, upLoadChatFileApi, getDoctorInfoApi} from "@/request/api/im"; import { checkDev } from '@/utils/utils'; // 根据环境获取上传URL @@ -657,13 +657,19 @@ export default { this.messages = ChatManager.getRoomMessages(option.room_id); } - // 5. 设置导航栏标题 - uni.setNavigationBarTitle({ - title: `与${this.doctorUserInfo.nick_name}医生的对话`, - success: () => { - console.log('修改标题成功'); - } - }); + // 5. 检查医生信息是否完整,如果不完整则从API获取 + const nickName = this.doctorUserInfo.nick_name; + if (!nickName || nickName === 'undefined' || nickName === 'null') { + this.fetchDoctorInfo(doctorId); + } else { + // 设置导航栏标题 + uni.setNavigationBarTitle({ + title: `与${nickName}医生的对话`, + success: () => { + console.log('修改标题成功'); + } + }); + } // 6. 初次渲染滚动到底部 // Fix: 页面加载时延时触发滚动到锚点 @@ -718,6 +724,49 @@ export default { }, methods: { + /** + * 获取医生信息 + * 当进入聊天页面时,如果医生信息不完整(undefined),则调用此方法获取 + */ + async fetchDoctorInfo(doctorId) { + try { + // 移除可能存在的前缀 + const cleanDoctorId = String(doctorId).replace('doctor-', ''); + const res = await getDoctorInfoApi({ doctor_id: cleanDoctorId }); + + if (res.data && res.data.result) { + const doctorInfo = res.data.result; + // 更新医生信息 + this.doctorUserInfo = { + ...this.doctorUserInfo, + nick_name: doctorInfo.nick_name || '医生', + avatar: doctorInfo.avatar || this.doctorAvatar, + department: doctorInfo.department || '', + title: doctorInfo.title || '' + }; + + // 更新医生头像 + if (doctorInfo.avatar) { + this.doctorAvatar = doctorInfo.avatar; + } + + // 更新导航栏标题 + uni.setNavigationBarTitle({ + title: `与${this.doctorUserInfo.nick_name}医生的对话`, + success: () => { + console.log('修改标题成功'); + } + }); + } + } catch (error) { + console.error('获取医生信息失败:', error); + // 即使获取失败,也设置一个默认标题 + uni.setNavigationBarTitle({ + title: '与医生的对话' + }); + } + }, + /** * 检查隐私授权 * 微信小程序从2023年9月起要求在使用敏感API前获取用户隐私授权 diff --git a/subPackages/doctor/doctor-userinfo.vue b/subPackages/doctor/doctor-userinfo.vue index 1d9969f..649e3c0 100644 --- a/subPackages/doctor/doctor-userinfo.vue +++ b/subPackages/doctor/doctor-userinfo.vue @@ -188,6 +188,7 @@ export default { heathList: [], // 健康信息 rInfo: [], // 健康信息 registerType: "0", // 新增:挂号类型(0线下/1线上) + delegateStoreId: '', // 委托诊所ID(购药时使用) } }, onLoad(e) { @@ -212,6 +213,8 @@ export default { this.rInfo = {} } } + // 获取委托诊所ID(如果有) + this.delegateStoreId = e.delegate_store_id || ''; console.log(e) }, @@ -335,12 +338,16 @@ export default { title: "加载中...", mask: true }); + // 如果是购药类型(register_type=3)且有委托诊所ID,则使用委托诊所ID;否则使用当前门店ID + const storeId = (this.registerType === '3' && this.delegateStoreId) + ? this.delegateStoreId + : (uni.getStorageSync('store_id') || '11001'); registe({ method: "post", data: { user_id: uni.getStorageSync('user_id'), user_patient_id: this.actived, - store_id: uni.getStorageSync('store_id') || '11001', + store_id: storeId, service_user_id: this.Did, register_type: this.registerType // 新增:挂号类型参数 } diff --git a/subPackages/product/product.vue b/subPackages/product/product.vue index 9305988..6816989 100644 --- a/subPackages/product/product.vue +++ b/subPackages/product/product.vue @@ -192,6 +192,7 @@ export default { doctorId: 0, r_type: 0, + delegateStoreId: '', // 委托诊所ID cartCount: 0, cartPosition: { x: 0, y: 0 }, cartMove: { startX: 0, startY: 0, moving: false }, @@ -219,6 +220,8 @@ export default { onLoad(e) { this.doctorId = e.doctor_id; this.r_type = e.register_type; + // 获取委托诊所ID(如果有) + this.delegateStoreId = e.delegate_store_id || ''; // 根据首页传入的专区类型初始化分类(默认OTC) if (e.zone_type) { this.selectedCategory = e.zone_type; @@ -327,9 +330,12 @@ export default { }, handClickProduct(item) { - uni.navigateTo({ - url: `/subPackages/product/symptoms?id=${item.drug.id}&drug_name=${item.drug.drug_name}&is_otc=${item.drug.is_otc}&image=${item.drug.image}&price=${item.price}` - }); + // 传递委托诊所ID(如果有) + let url = `/subPackages/product/symptoms?id=${item.drug.id}&drug_name=${item.drug.drug_name}&is_otc=${item.drug.is_otc}&image=${item.drug.image}&price=${item.price}`; + if (this.delegateStoreId) { + url += `&delegate_store_id=${this.delegateStoreId}`; + } + uni.navigateTo({ url }); }, // 悬浮球逻辑 diff --git a/subPackages/product/symptoms.vue b/subPackages/product/symptoms.vue index 5c8a1de..ff8e4c4 100644 --- a/subPackages/product/symptoms.vue +++ b/subPackages/product/symptoms.vue @@ -298,7 +298,7 @@