<template>
	<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
		<cus-header title='对话记录' bgColor="transparent"></cus-header>
		<div class="list">
			<div v-for="(item,index) in list">
				<div class="time">{{item.createdAt}}</div>
				<div class="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="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>
			</div>
		</div>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				agentId:'',
				deviceId:'',
				sessionId:'',
				list:[]
			}
		},
		onLoad(option) {
			this.agentId = option?.agentId;
			this.deviceId = option?.deviceId;
			this.sessionId = option?.sessionId;
			this.getList();
		},
		methods:{
			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;
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page{
		background: #F7F6F9;
		padding: 0 30rpx 40rpx;
		box-sizing: border-box;
		
		.list{
			
		}
	}
</style>