feat: 对家列表的调整

This commit is contained in:
zoujing 2025-07-28 21:34:23 +08:00
parent 15200ce3b8
commit 0efc7fe6a0
6 changed files with 108 additions and 27 deletions

View File

@ -85,15 +85,24 @@
import OneFeelMK002 from '../module/OneFeelMK002.vue'; import OneFeelMK002 from '../module/OneFeelMK002.vue';
import { agentChatStream } from '../../request/api/AgentChatStream'; import { agentChatStream } from '../../request/api/AgentChatStream';
import { mainPageData } from '../../request/api/MainPageData'; import { mainPageData } from '../../request/api/MainPageData';
import { conversationMsgList } from '../../request/api/ConversationMsgList';
import { recentConversation } from '../../request/api/RecentConversation';
// ///
const statusBarHeight = ref(20); const statusBarHeight = ref(20);
const timer = ref(null) const timer = ref(null)
const holdKeyboard = ref(false) // focus /// focus
const holdKeyboardFlag = ref(true) // const holdKeyboard = ref(false)
///
const holdKeyboardFlag = ref(true)
///
const scrollTop = ref(99999);
///
const chatMsgList = ref([]) const chatMsgList = ref([])
///
const inputMessage = ref('') const inputMessage = ref('')
/// ///
@ -101,11 +110,12 @@
/// agentId /// agentId
const agentId = ref('1') const agentId = ref('1')
/// ID /// ID
const conversationId = ref('1931957498711957505') const conversationId = ref('')
///
const mainPageDataModel = ref({}) const mainPageDataModel = ref({})
// //
const scrollTop = ref(99999); let isSessionActive = false;
// //
@ -135,6 +145,7 @@
// #endif // #endif
} }
///
const scrollToBottom = () => { const scrollToBottom = () => {
nextTick(() => { nextTick(() => {
nextTick(() => { nextTick(() => {
@ -142,19 +153,35 @@
}); });
}); });
} }
///
const setTimeoutScrollToBottom = () => {
setTimeout(() => {
scrollToBottom()
}, 100)
}
/// ///
const handleReply = (text) => { const handleReply = (text) => {
sendMessage(text) sendMessage(text)
setTimeout(() => { setTimeoutScrollToBottom()
scrollToBottom()
}, 100)
}; };
/// ///
const handleReplyInstruct = (text) => { const handleReplyInstruct = (text) => {
sendMessage(text, true) sendMessage(text, true)
scrollToBottom() setTimeoutScrollToBottom()
}
///
const sendMessageAction = (inputText) => {
console.log("输入消息:", inputText)
if (!inputText.trim()) return;
handleNoHideKeyboard()
sendMessage(inputText)
if(!isSessionActive) {
inputMessage.value = ''
}
setTimeoutScrollToBottom()
} }
onLoad(() => { onLoad(() => {
@ -165,10 +192,26 @@
}); });
}); });
onMounted(() => { onMounted( async() => {
getMainPageData() getMainPageData()
await loadRecentConversation()
loadConversationMsgList()
}) })
/// id
const loadRecentConversation = async() => {
const res = await recentConversation()
if(res.code === 0) {
conversationId.value = res.data.conversationId
}
}
///
let historyCurrentPageNum = 1
const loadConversationMsgList = async() => {
const args = { pageNum: historyCurrentPageNum++, pageSize : 10, conversationId: conversationId.value }
const res = await conversationMsgList(args)
}
/// ///
const getMainPageData = async() => { const getMainPageData = async() => {
@ -181,7 +224,7 @@
} }
} }
/// ///
const initData = () => { const initData = () => {
const msg = { const msg = {
msgId: `msg_${0}`, msgId: `msg_${0}`,
@ -192,17 +235,16 @@
} }
/// ///
const sendMessageAction = (inputText) => {
console.log("输入消息:", inputText)
if (!inputText.trim()) return;
handleNoHideKeyboard()
sendMessage(inputText)
inputMessage.value = ''
scrollToBottom()
}
const sendMessage = (message, isInstruct = false) => { const sendMessage = (message, isInstruct = false) => {
if (isSessionActive) {
uni.showToast({
title: '请等待当前回复完成',
icon: 'none'
});
return;
}
isSessionActive = true;
const newMsg = { const newMsg = {
msgId: `msg_${chatMsgList.value.length}`, msgId: `msg_${chatMsgList.value.length}`,
msgType: MessageRole.ME, msgType: MessageRole.ME,
@ -217,7 +259,7 @@
console.log("发送的新消息:",JSON.stringify(newMsg)) console.log("发送的新消息:",JSON.stringify(newMsg))
} }
///
let loadingTimer = null; let loadingTimer = null;
let typeWriterTimer = null; let typeWriterTimer = null;
let aiMsgBuffer = ''; // let aiMsgBuffer = ''; //
@ -260,9 +302,19 @@
typeWriterTimer = null; typeWriterTimer = null;
} }
// 2. //
agentChatStream(args, (chunk) => { agentChatStream(args, (chunk) => {
console.log('分段内容:', chunk) console.log('分段内容:', chunk)
if (chunk.error) {
chatMsgList.value[aiMsgIndex].msg = '请求错误,请重试';
clearInterval(finishInterval);
isTyping = false;
typeWriterTimer = null;
isSessionActive = false; //
console.error('流式错误:', chunk.message, chunk.detail);
return;
}
if (chunk && chunk.content) { if (chunk && chunk.content) {
// //
if (loadingTimer) { if (loadingTimer) {
@ -285,10 +337,14 @@
if (aiMsgBuffer.length === 0) { if (aiMsgBuffer.length === 0) {
clearInterval(finishInterval); clearInterval(finishInterval);
isTyping = false; isTyping = false;
isSessionActive = false; //
scrollToBottom(); scrollToBottom();
} }
}, 50); }, 50);
} }
}).catch(e => {
isSessionActive = false; //
console.log('error:', e)
}); });
// //

View File

@ -4,7 +4,7 @@
<!-- :style="backgroundStyle" --> <!-- :style="backgroundStyle" -->
<view class="top-item1-left"> <view class="top-item1-left">
<image :src="initPageImages.welcomeImageUrl"></image> <image :src="initPageImages.welcomeImageUrl"></image>
<text>{{ currentDate }} 多云 -36 </text> <text>{{ currentDate }} 多云 -36 gg </text>
</view> </view>
<view class="top-item1-right"> <view class="top-item1-right">
<image :src="initPageImages.logoImageUrl"></image> <image :src="initPageImages.logoImageUrl"></image>

View File

@ -30,8 +30,19 @@ function agentChatStream(params, onChunk) {
resolve(res.data); resolve(res.data);
}, },
fail(err) { fail(err) {
console.log("====> ", JSON.stringify(err))
reject(err); reject(err);
} },
complete(res) {
if(res.statusCode === 500) {
console.log("====> ", JSON.stringify(res))
if (onChunk) {
onChunk({ error: true, message: '服务器错误', detail: res });
}
reject(res);
}
}
}); });
requestTask.onHeadersReceived(res => { requestTask.onHeadersReceived(res => {

View File

@ -0,0 +1,7 @@
import request from "../base/request";
function conversationMsgList(args) {
return request.post('/hotelBiz/chat/conversationMessageList', args);
}
export { conversationMsgList }

View File

@ -0,0 +1,7 @@
import request from "../base/request";
function recentConversation() {
return request.get('/hotelBiz/chat/recentConversation');
}
export{ recentConversation }

View File

@ -306,7 +306,7 @@ export default {
<style lang="scss"> <style lang="scss">
.zero-markdown-view { .zero-markdown-view {
padding: 15rpx; padding: 0;
position: relative; position: relative;
} }
</style> </style>