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 { agentChatStream } from '../../request/api/AgentChatStream';
import { mainPageData } from '../../request/api/MainPageData';
import { conversationMsgList } from '../../request/api/ConversationMsgList';
import { recentConversation } from '../../request/api/RecentConversation';
//
///
const statusBarHeight = ref(20);
const timer = ref(null)
const holdKeyboard = ref(false) // focus
const holdKeyboardFlag = ref(true) //
/// focus
const holdKeyboard = ref(false)
///
const holdKeyboardFlag = ref(true)
///
const scrollTop = ref(99999);
///
const chatMsgList = ref([])
///
const inputMessage = ref('')
///
@ -101,11 +110,12 @@
/// agentId
const agentId = ref('1')
/// ID
const conversationId = ref('1931957498711957505')
const conversationId = ref('')
///
const mainPageDataModel = ref({})
//
const scrollTop = ref(99999);
//
let isSessionActive = false;
//
@ -135,6 +145,7 @@
// #endif
}
///
const scrollToBottom = () => {
nextTick(() => {
nextTick(() => {
@ -142,19 +153,35 @@
});
});
}
///
const setTimeoutScrollToBottom = () => {
setTimeout(() => {
scrollToBottom()
}, 100)
}
///
const handleReply = (text) => {
sendMessage(text)
setTimeout(() => {
scrollToBottom()
}, 100)
setTimeoutScrollToBottom()
};
///
const handleReplyInstruct = (text) => {
sendMessage(text, true)
scrollToBottom()
setTimeoutScrollToBottom()
}
///
const sendMessageAction = (inputText) => {
console.log("输入消息:", inputText)
if (!inputText.trim()) return;
handleNoHideKeyboard()
sendMessage(inputText)
if(!isSessionActive) {
inputMessage.value = ''
}
setTimeoutScrollToBottom()
}
onLoad(() => {
@ -165,10 +192,26 @@
});
});
onMounted(() => {
onMounted( async() => {
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() => {
@ -181,7 +224,7 @@
}
}
///
///
const initData = () => {
const msg = {
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) => {
if (isSessionActive) {
uni.showToast({
title: '请等待当前回复完成',
icon: 'none'
});
return;
}
isSessionActive = true;
const newMsg = {
msgId: `msg_${chatMsgList.value.length}`,
msgType: MessageRole.ME,
@ -217,7 +259,7 @@
console.log("发送的新消息:",JSON.stringify(newMsg))
}
///
let loadingTimer = null;
let typeWriterTimer = null;
let aiMsgBuffer = ''; //
@ -260,9 +302,19 @@
typeWriterTimer = null;
}
// 2.
//
agentChatStream(args, (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 (loadingTimer) {
@ -285,10 +337,14 @@
if (aiMsgBuffer.length === 0) {
clearInterval(finishInterval);
isTyping = false;
isSessionActive = false; //
scrollToBottom();
}
}, 50);
}
}).catch(e => {
isSessionActive = false; //
console.log('error:', e)
});
//

View File

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

View File

@ -30,8 +30,19 @@ function agentChatStream(params, onChunk) {
resolve(res.data);
},
fail(err) {
console.log("====> ", JSON.stringify(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 => {

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">
.zero-markdown-view {
padding: 15rpx;
padding: 0;
position: relative;
}
</style>