|
@@ -2,15 +2,17 @@
|
|
|
<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
|
|
|
<cus-header title='对话记录' bgColor="transparent"></cus-header>
|
|
|
<div class="list" v-if="list.length">
|
|
|
- <div class="l_item" v-for="(item,index) in list">
|
|
|
- <div class="time">{{item.createdAt}}</div>
|
|
|
- <div class="pre adf my" v-if="item.chatType===1">
|
|
|
- <div class="text my">{{item.content}}</div>
|
|
|
- <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/6edb131a-66f9-4a2a-a865-7b74e3dd52ed.png"></image>
|
|
|
- </div>
|
|
|
- <div class="pre adf ai" v-else-if="item.chatType===2">
|
|
|
- <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/bcde7118-fc4e-4fa6-96ca-ebe1e0beba2f.png"></image>
|
|
|
- <div class="text ai">{{item.content}}</div>
|
|
|
+ <div class="l_item" v-for="(item,index) in list" :key="index">
|
|
|
+ <div class="time">{{item.date}}</div>
|
|
|
+ <div v-for="(pre,idx) in item.items" :key="idx">
|
|
|
+ <div class="pre adf my" v-if="pre.chatType===1">
|
|
|
+ <div class="text my">{{pre.content}}</div>
|
|
|
+ <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/6edb131a-66f9-4a2a-a865-7b74e3dd52ed.png"></image>
|
|
|
+ </div>
|
|
|
+ <div class="pre adf ai" v-else-if="pre.chatType===2">
|
|
|
+ <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/bcde7118-fc4e-4fa6-96ca-ebe1e0beba2f.png"></image>
|
|
|
+ <div class="text ai">{{pre.content}}</div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -29,33 +31,7 @@
|
|
|
agentId:'',
|
|
|
deviceId:'',
|
|
|
sessionId:'',
|
|
|
- list:[
|
|
|
- // {
|
|
|
- // createdAt:'2025-05-30 06:25:53',
|
|
|
- // chatType:1,
|
|
|
- // content:'你好哇'
|
|
|
- // },
|
|
|
- // {
|
|
|
- // createdAt:'2025-05-30 06:27:53',
|
|
|
- // chatType:2,
|
|
|
- // content:'你好,很高兴认识你,我是AI智能陪绑助手小智。'
|
|
|
- // },
|
|
|
- // {
|
|
|
- // createdAt:'2025-05-30 06:27:53',
|
|
|
- // chatType:2,
|
|
|
- // content:'有什么可以帮您的吗?'
|
|
|
- // },
|
|
|
- // {
|
|
|
- // createdAt:'2025-05-30 06:31:53',
|
|
|
- // chatType:1,
|
|
|
- // content:'今天天气如何'
|
|
|
- // },
|
|
|
- // {
|
|
|
- // createdAt:'2025-05-30 06:33:53',
|
|
|
- // chatType:2,
|
|
|
- // content:'我也母鸡啦'
|
|
|
- // }
|
|
|
- ]
|
|
|
+ list:[]
|
|
|
}
|
|
|
},
|
|
|
onLoad(option) {
|
|
@@ -68,8 +44,25 @@
|
|
|
getList(){
|
|
|
this.$api.get(`/agent/${this.agentId}/${this.deviceId}/chat-history/${this.sessionId}`).then(res=>{
|
|
|
if(res.data.code!==0) return this.$showToast(res.data.msg)
|
|
|
- this.list = res.data.data;
|
|
|
+ this.list = this.groupedMessages(res.data.data||[])
|
|
|
})
|
|
|
+ },
|
|
|
+ groupedMessages(data) {
|
|
|
+ const groups = {};
|
|
|
+ data.forEach(msg => {
|
|
|
+ const dateKey = msg.createdAt;
|
|
|
+ if (!groups[dateKey]) {
|
|
|
+ groups[dateKey] = {
|
|
|
+ date: dateKey,
|
|
|
+ items: []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ groups[dateKey].items.push(msg);
|
|
|
+ });
|
|
|
+
|
|
|
+ return Object.values(groups).sort((a, b) =>
|
|
|
+ new Date(a.date) - new Date(b.date)
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -99,13 +92,15 @@
|
|
|
height: 78rpx;
|
|
|
border-radius: 50%;
|
|
|
}
|
|
|
- .text{
|
|
|
+ .text{
|
|
|
+ max-width: calc(100% - 98rpx);
|
|
|
padding: 24rpx;
|
|
|
font-family: PingFangSC, PingFang SC;
|
|
|
font-weight: 400;
|
|
|
font-size: 28rpx;
|
|
|
line-height: 48rpx;
|
|
|
border-radius: 20rpx;
|
|
|
+ box-sizing: border-box;
|
|
|
}
|
|
|
&.my{
|
|
|
justify-content: flex-end;
|