diff --git a/.gitignore b/.gitignore
index 683e3f5..797bf55 100644
--- a/.gitignore
+++ b/.gitignore
@@ -117,3 +117,4 @@ dist
/.hbuilderx/
/.idea/
/database/
+/utils/utils.js
\ No newline at end of file
diff --git a/pages.json b/pages.json
index c66f920..ae1c6aa 100644
--- a/pages.json
+++ b/pages.json
@@ -475,6 +475,13 @@
"navigationBarTitleText": "转诊消息",
"enablePullDownRefresh": true
}
+ },
+ {
+ "path": "transfer/transfer-consultation",
+ "style": {
+ "navigationBarTitleText": "转诊咨询",
+ "enablePullDownRefresh": false
+ }
}
]
}
diff --git a/request/api/transferPrescription.js b/request/api/transferPrescription.js
index 13cc7e4..cc01bf4 100644
--- a/request/api/transferPrescription.js
+++ b/request/api/transferPrescription.js
@@ -34,3 +34,20 @@ export async function agreeTransferPrescriptionApi(params) {
export async function rejectTransferPrescriptionApi(params) {
return await post('/transfer-prescription/reject', params, 3)
}
+
+/**
+ * 获取转诊问题列表(用于咨询页面)
+ * @returns {Promise<*>}
+ */
+export async function getTransferQuestionsApi() {
+ return await get('/transfer-prescription/get-questions', {}, 3)
+}
+
+/**
+ * 提交转诊问题答案
+ * @param params { transfer_id: number, answers: Array<{question_id: number, answer: string}> }
+ * @returns {Promise<*>}
+ */
+export async function submitTransferQuestionsApi(params) {
+ return await post('/transfer-prescription/submit-questions', params, 3)
+}
\ No newline at end of file
diff --git a/subPackages/chat/chat.vue b/subPackages/chat/chat.vue
index 739a967..03627c5 100644
--- a/subPackages/chat/chat.vue
+++ b/subPackages/chat/chat.vue
@@ -220,6 +220,20 @@ export default {
},
onLoad: function (option) {
+ // 确保 room_id 存在
+ if (!option.room_id) {
+ console.error('聊天页面缺少room_id参数');
+ uni.showToast({
+ title: '房间ID不能为空',
+ icon: 'none'
+ });
+ setTimeout(() => {
+ uni.navigateBack();
+ }, 1500);
+ return;
+ }
+
+ // 先设置基础信息
this.doctorUserInfo = option;
if (option.avatar) this.doctorAvatar = option.avatar;
this.currentUserId = 'user-' + uni.getStorageSync('user_id') || 'user-2512';
@@ -228,6 +242,7 @@ export default {
if (doctorId.includes('-type-')) doctorId = doctorId.split('-type-')[0];
this.doctorId = doctorId;
+ // 立即进入房间并设置ChatManager(确保消息能正确路由)
if (typeof ChatManager !== 'undefined') {
ChatManager.enterRoom(option.room_id);
ChatManager.resetUnreadCount(option.room_id);
@@ -244,6 +259,8 @@ export default {
const nickName = this.doctorUserInfo.nick_name;
if (nickName && nickName !== 'undefined' && nickName !== 'null') {
uni.setNavigationBarTitle({ title: `与${nickName}医生的对话` });
+ } else {
+ uni.setNavigationBarTitle({ title: '与医生的对话' });
}
this.$nextTick(() => {
@@ -264,6 +281,15 @@ export default {
},
onShow() {
+ // 确保房间ID已设置(从ChatManager获取,作为备用)
+ if (!this.doctorUserInfo.room_id && typeof ChatManager !== 'undefined') {
+ const currentRoomId = ChatManager.getCurrentRoomId();
+ if (currentRoomId) {
+ this.doctorUserInfo.room_id = currentRoomId;
+ }
+ }
+
+ // 注册事件监听器
uni.$on('new-room-message', this.handleNewRoomMessage);
uni.$on('load-room-message', this.handLoadMessageList);
uni.$on('no-more-history', this.handNoMessageList);
@@ -279,7 +305,12 @@ export default {
mounted() {
this.recorderManager = uni.getRecorderManager();
this.initRecorder();
- if (typeof webSocketManager !== 'undefined') webSocketManager.addMessageHandler(this.handleSocketMessage);
+ // 延迟注册WebSocket消息处理器,确保onLoad已执行完成,room_id已设置
+ this.$nextTick(() => {
+ if (typeof webSocketManager !== 'undefined') {
+ webSocketManager.addMessageHandler(this.handleSocketMessage);
+ }
+ });
this.calculateScrollViewHeight();
},
@@ -487,7 +518,11 @@ export default {
},
handleSocketMessage(data) {
- if (data.room_id === this.doctorUserInfo.room_id) {
+ // 获取当前房间ID(优先使用doctorUserInfo.room_id,如果未设置则从ChatManager获取)
+ const currentRoomId = this.doctorUserInfo.room_id || (typeof ChatManager !== 'undefined' ? ChatManager.getCurrentRoomId() : null);
+
+ // 如果房间ID匹配,或者消息的房间ID与当前房间ID匹配,则处理消息
+ if (data.room_id && (data.room_id === currentRoomId || data.room_id === this.doctorUserInfo.room_id)) {
this.addMessage(data);
this.scrollToBottom();
}
diff --git a/subPackages/chat/components/TransferMessageBubble.vue b/subPackages/chat/components/TransferMessageBubble.vue
index 0ea2140..8dd0048 100644
--- a/subPackages/chat/components/TransferMessageBubble.vue
+++ b/subPackages/chat/components/TransferMessageBubble.vue
@@ -27,6 +27,24 @@
转诊原因:
{{ messageData.transfer_reason }}
+
+
+
+
+ ❓
+ 咨询问题
+
+
+
+ {{ index + 1 }}.
+ {{ qa.question }}
+
+
+ {{ qa.answer === '是' ? '✓' : '✗' }}
+ {{ qa.answer }}
+
+
+