<template>
	<view class="content">
	  <z-nav-bar title="会话记录" bgColor="#5188e5" fontColor="#fff"></z-nav-bar>
	  <view class="list_wrap">
		  <view class="list_content" v-if="list&&list.length>0">
			  <view v-for="(item, index) in list" :key="index" class="list_item" @click="clickRecord(item, index)">
				  <text>{{item.chatName}}</text>
			</view>
		  </view>
		  <text class="null_text" v-else>{{null_text}}</text>
	  </view>
	</view>
</template>

<script>
import $http from "@/config/requestConfig.js";
export default {
	data() {
		return {
			list: [],
			null_text: ''
		};
	},
	//第一次加载
	onLoad(e) {
		
	},
	//页面显示
	onShow() {
		this.getData();
	},
	//方法
	methods: {
		//获取数据
		getData() {
			uni.showLoading({
				title: '加载中'
			})
			this.$http.request({
				url: 'common/ragFlowApi/getChats',
				method: "POST",
				data: {
					chatId: '',
					sessionId: '',
					page: 1,
					pageSize: 300
				},
				header: {
					"Content-Type": "application/json",
				},
			})
			.then(res=> {
				if(res.code==0){
					uni.hideLoading();
					if(res.list&&res.list.length>0){
						this.list = res.list;
					}else{
						this.list = [];
						this.null_text = '暂无数据';
					}
				}
			});
		},
		//点击会话跳转到首页记录
		clickRecord(item, index){
			uni.setStorageSync('homeParams', { data: item, index: index });
			uni.switchTab({
				url: '/pages/home/index'
			});
		},
		onPageJump(url) {
			uni.navigateTo({
				url: url,
			});
		}
	},
};
</script>

<style lang="scss" scoped>
@import "@/static/mixin.scss";
.list_wrap{
	padding-bottom: 20rpx;
}
.list_content{
	margin: 20rpx 30rpx;
	border-radius: 10rpx;
	background-color: #fff;
	padding: 20rpx 30rpx;
	box-shadow: 0px 0px 10px 0px #a7bbe4;
	
	text{
		display: block;
		width: 100%;
		font-size: 30rpx;
		line-height: 50rpx;
		padding: 20rpx 0;
		border-bottom: 1rpx solid #e5dcdc;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	.list_item:last-child text{
		border-bottom: none;
	}
}
.null_text{
	display: block;
	text-align: center;
	font-size: 30rpx;
	color: #999;
	padding-top: 150rpx;
}
</style>