no message

This commit is contained in:
wangdongbo 2026-02-10 16:41:07 +08:00
parent 1e5881043b
commit 4e6cdf4bdd
6 changed files with 47 additions and 47 deletions

View File

@ -1,4 +1,4 @@
MP_API_BASE_URL=https://patient.youcan365.com MP_API_BASE_URL=https://patient.youcan365.com
MP_CACHE_PREFIX=development MP_CACHE_PREFIX=development
MP_WX_APP_ID=wx6ee11733526b4f04 MP_WX_APP_ID=wx6ee11733526b4f04
MP_TIM_SDK_APP_ID=1600123876 MP_TIM_SDK_APP_ID=1600126296

View File

@ -1,4 +1,4 @@
MP_API_BASE_URL=http://localhost:8080 MP_API_BASE_URL=http://localhost:8080
MP_CACHE_PREFIX=development MP_CACHE_PREFIX=development
MP_WX_APP_ID=wx6ee11733526b4f04 MP_WX_APP_ID=wx6ee11733526b4f04
MP_TIM_SDK_APP_ID=1600123876 MP_TIM_SDK_APP_ID=1600126296

View File

@ -8,7 +8,7 @@
<view class="input-area"> <view class="input-area">
<textarea v-if="!showVoiceInput" class="text-input" v-model="inputText" placeholder="我来说两句..." <textarea v-if="!showVoiceInput" class="text-input" v-model="inputText" placeholder="我来说两句..."
@confirm="sendTextMessage" @focus="handleInputFocus" @input="handleInput" @confirm="sendTextMessage" @focus="handleInputFocus" @input="handleInput"
:auto-height="true" :show-confirm-bar="false" :adjust-position="true" :cursor-spacing="80" /> :auto-height="true" :show-confirm-bar="false" :adjust-position="true" :cursor-spacing="40" />
<input v-else class="voice-input-btn" :class="{ recording: isRecording }" @touchstart="startRecord" <input v-else class="voice-input-btn" :class="{ recording: isRecording }" @touchstart="startRecord"
@touchmove="onRecordTouchMove" @touchend="stopRecord" @touchcancel="cancelRecord" :placeholder="isRecording ? '松开发送' : '按住说话'" disabled> @touchmove="onRecordTouchMove" @touchend="stopRecord" @touchcancel="cancelRecord" :placeholder="isRecording ? '松开发送' : '按住说话'" disabled>
</input> </input>

View File

@ -9,7 +9,11 @@
>{{ patientInfo.sex }} · {{ patientInfo.age }}</text >{{ patientInfo.sex }} · {{ patientInfo.age }}</text
> >
</view> </view>
<view class="status-badge" :class="chatStatusInfo.badgeClass" v-if="chatStatusInfo.badgeText"> <view
class="status-badge"
:class="chatStatusInfo.badgeClass"
v-if="chatStatusInfo.badgeText"
>
<text class="badge-text">{{ chatStatusInfo.badgeText }}</text> <text class="badge-text">{{ chatStatusInfo.badgeText }}</text>
</view> </view>
</view> </view>
@ -571,7 +575,6 @@ const initTIMCallbacks = async () => {
uniqueMessages.push(message); uniqueMessages.push(message);
} }
}); });
messageList.value = uniqueMessages; messageList.value = uniqueMessages;
console.log( console.log(
"消息列表已更新,原始", "消息列表已更新,原始",
@ -663,7 +666,7 @@ const loadMessageList = async () => {
// //
await fetchGroupOrderStatus(); await fetchGroupOrderStatus();
timChatManager.enterConversation(chatInfo.value.conversationID || "test1"); timChatManager.enterConversation(chatInfo.value.conversationID);
// - // -
if ( if (
@ -758,6 +761,7 @@ const onScroll = throttle((e) => {
// //
const handleScrollToUpper = async () => { const handleScrollToUpper = async () => {
console.log("【handleScrollToUpper】触发上滑事件准备加载更多"); console.log("【handleScrollToUpper】触发上滑事件准备加载更多");
return;
console.log( console.log(
" 当前状态: isLoadingMore=", " 当前状态: isLoadingMore=",
isLoadingMore.value, isLoadingMore.value,
@ -827,15 +831,12 @@ onShow(() => {
checkLoginAndInitTIM(); checkLoginAndInitTIM();
} else if (timChatManager.tim && !timChatManager.isLoggedIn) { } else if (timChatManager.tim && !timChatManager.isLoggedIn) {
timChatManager.ensureIMConnection(); timChatManager.ensureIMConnection();
} else if (timChatManager.tim && timChatManager.isLoggedIn && chatInfo.value.conversationID) { } else if (
timChatManager.tim &&
messageList.value = []; timChatManager.isLoggedIn &&
isCompleted.value = false; chatInfo.value.conversationID
lastFirstMessageId.value = ""; )
loadMessageList(); startIMMonitoring(30000);
}
startIMMonitoring(30000);
}); });
// //

View File

@ -1,9 +1,6 @@
<template> <template>
<view class="message-page"> <view class="message-page">
<!-- 标题栏 -->
<view class="message-header">
<text class="header-title">咨询</text>
</view>
<!-- 消息列表 --> <!-- 消息列表 -->
<scroll-view <scroll-view
@ -201,6 +198,7 @@ const initIM = async () => {
// //
const loadConversationList = async () => { const loadConversationList = async () => {
debugger
if (loading.value) return; if (loading.value) return;
// loading.value = true; // loading.value = true;
@ -487,18 +485,7 @@ const handleRefresh = async () => {
}; };
// //
onLoad(() => { onLoad( async() => {
console.log("消息列表页面加载");
});
//
const cleanMessageText = (text) => {
if (!text) return "";
return text.replace(/[\r\n]+/g, " ").trim();
};
//
onShow(async () => {
try { try {
// IM // IM
const imReady = await initIM(); const imReady = await initIM();
@ -514,6 +501,17 @@ onShow(async () => {
} }
}); });
//
const cleanMessageText = (text) => {
if (!text) return "";
return text.replace(/[\r\n]+/g, " ").trim();
};
//
onShow(async () => {
});
// //
onHide(() => { onHide(() => {
// //

View File

@ -1439,15 +1439,15 @@ class TimChatManager {
// 更新当前会话ID // 更新当前会话ID
this.currentConversationID = conversationID this.currentConversationID = conversationID
// 清空当前消息列表 // 清空消息列表,只重置分页状态
this.messageList = [] // this.messageList = []
// 重置分页状态 // 重置分页状态
this.nextReqMessageID = "" this.nextReqMessageID = ""
this.isCompleted = false this.isCompleted = false
this.isLoadingMore = false this.isLoadingMore = false
console.log(" 会话ID已更新消息列表已清空,分页状态已重置") console.log(" 会话ID已更新分页状态已重置")
// 进入群聊会话默认加载20条消息 // 进入群聊会话默认加载20条消息
this.enterGroupConversation(conversationID, 20) this.enterGroupConversation(conversationID, 20)
@ -1455,6 +1455,7 @@ class TimChatManager {
// 进入群聊会话 // 进入群聊会话
async enterGroupConversation(groupID, count = 20) { async enterGroupConversation(groupID, count = 20) {
console.log("【enterGroupConversation】进入群聊会话, groupID:", groupID, "count:", count) console.log("【enterGroupConversation】进入群聊会话, groupID:", groupID, "count:", count)
let conversationID = groupID let conversationID = groupID
@ -1470,8 +1471,8 @@ class TimChatManager {
console.log(" conversationID:", conversationID, "actualGroupID:", actualGroupID) console.log(" conversationID:", conversationID, "actualGroupID:", actualGroupID)
// 清空消息列表,准备加载新会话的消息 // 不清空消息列表,只在首次进入时清空
this.messageList = [] // this.messageList = []
// 确保设置当前会话ID防止消息混淆 // 确保设置当前会话ID防止消息混淆
this.currentConversationID = conversationID this.currentConversationID = conversationID
@ -2220,8 +2221,8 @@ class TimChatManager {
// 确保使用当前会话的conversationID // 确保使用当前会话的conversationID
const conversationID = this.conversation.conversationID || this.currentConversationID const conversationID = this.conversation.conversationID || this.currentConversationID
// 获取图片尺寸信息 // 使用默认尺寸,不调用接口获取图片信息
const imageInfo = await this.getImageInfo(imageFile); const defaultImageInfo = { width: 400, height: 300 }
const localMessage = { const localMessage = {
ID: `local_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, ID: `local_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
@ -2230,8 +2231,8 @@ class TimChatManager {
payload: { payload: {
imageInfoArray: [{ imageInfoArray: [{
url: this.getImageUrl(imageFile), url: this.getImageUrl(imageFile),
width: imageInfo.width, width: defaultImageInfo.width,
height: imageInfo.height height: defaultImageInfo.height
}] }]
}, },
lastTime: Date.now(), lastTime: Date.now(),