diff --git a/pages/home/history/index.vue b/pages/home/history/index.vue index e44797c..5872706 100644 --- a/pages/home/history/index.vue +++ b/pages/home/history/index.vue @@ -46,12 +46,16 @@ - {{ group.header }} + {{ group.id }} - + - B + {{ item.title }} - {{ item.content }} + @@ -178,9 +185,20 @@ export default { type: "human", }, ], + chatHistoryAI: [], // ai咨询历史记录 + chatHistoryTeacher: [], // 人工咨询历史记录 }; }, computed: { + // 当前tab的历史记录 + currentHistoryList() { + if (this.activeTab === "1") { + return this.chatHistoryAI; + } else { + return this.chatHistoryTeacher; + } + }, + // 根据当前tab过滤历史记录 filteredHistoryList() { return this.historyList.filter((item) => { @@ -220,7 +238,58 @@ export default { return groups; }, }, + + onLoad() { + this.getChatHistoryList(); + // this.GetDialogueList_User(); + }, + methods: { + // 获取ai历史记录 + async getChatHistoryList() { + this.$u.api.GetConversationPage().then((res) => { + this.chatHistoryAI = res.data; + // if (this.chatHistoryAI.length > 0) { + // this.chatHistoryAI = res.data.map((group) => { + // // 对每个组的conversation数组进行倒序排序 + // return { + // ...group, + // conversation: group.conversation.sort((a, b) => { + // // 将日期字符串转换为时间戳并比较(倒序) + // return ( + // new Date(b.startTime).getTime() - + // new Date(a.startTime).getTime() + // ); + // }), + // }; + // }); + // } + console.log("this.chatHistoryAI", this.chatHistoryAI); + }); + }, + + // 获取人工咨询数据 + async GetDialogueList_User() { + this.$u.api.GetDialogueList_UserApi().then((res) => { + this.chatHistoryTeacher = res.data; + // if (this.chatHistoryTeacher.length > 0) { + // this.chatHistoryTeacher = res.data.map((group) => { + // // 对每个组的conversation数组进行倒序排序 + // return { + // ...group, + // conversation: group.conversation.sort((a, b) => { + // // 将日期字符串转换为时间戳并比较(倒序) + // return ( + // new Date(b.startTime).getTime() - + // new Date(a.startTime).getTime() + // ); + // }), + // }; + // }); + // } + }); + }, + // 格式化时间显示 formatTime(timestamp) { const now = new Date(); @@ -277,6 +346,12 @@ export default { switchTab(tab) { this.activeTab = tab; + // 切换tab时,刷新当前tab的历史记录 + if (tab === "1") { + this.getChatHistoryList(); + } else { + this.GetDialogueList_User(); + } }, // 显示/隐藏右上角更多菜单 @@ -348,6 +423,10 @@ export default { (item) => !this.selectedItems.includes(item.id) ); + console.log('删除后的历史记录:',this.historyList); + + return + // 重置状态 this.selectedItems = []; this.selectAll = false; @@ -358,18 +437,6 @@ export default { type: "success", }); }, - - handleDelete(item, callback) { - console.log("handleDelete", item); - - setTimeout(() => { - this.$refs.uToast.show({ - title: "撤回成功", - type: "success", - }); - callback(true); - }, 1500); - }, }, }; @@ -543,22 +610,21 @@ export default { .item-header { display: flex; align-items: center; - margin-bottom: 24rpx; + margin-bottom: 30rpx; .item-icon { - width: 48rpx; - height: 48rpx; - background-color: #4f6aff; + width: 50rpx; + height: 50rpx; + background-color: rgba(79, 106, 255, 0.1); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-right: 16rpx; - .icon-text { - color: #ffffff; - font-size: 24rpx; - font-weight: bold; + .icon-image { + width: 26rpx; + height: 26rpx; } } diff --git a/static/common/images/icon_chat2.png b/static/common/images/icon_chat2.png new file mode 100644 index 0000000..0dcd7ff Binary files /dev/null and b/static/common/images/icon_chat2.png differ diff --git a/static/common/images/icon_chat3.png b/static/common/images/icon_chat3.png new file mode 100644 index 0000000..4967e22 Binary files /dev/null and b/static/common/images/icon_chat3.png differ