<template>
	<view class="dynamic-list">
		<view @click="toShowDetail(item.title)" class="dynamic-item" v-for="(item,index) in list" :key="index">
			<view class="item-left">
				<view class="ilo">
					<text class="item-title">
						<text class="item-top" v-if="item.isTop">{{ tip }}</text>
						{{ item.title }}
					</text>
				</view>
				<view class="ilt">
					<text class="item-content" decode>{{ getContent(item.content) }}</text>
				</view>
				<view class="ilth">
					<view class="ilth-left">
						<u-icon size="28rpx" name="eye" :label="item.readCount+' 人阅读'"></u-icon>
					</view>
					<view class="ilth-right">
						{{ item.date }}
					</view>
				</view>
			</view>
			<view class="item-right">
				<image :src="item.img"></image>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	props:{
		list:{
			type: Array,
			default: []
		},
		tip:{
			type: String,
			default: '置顶'
		}
	},
	data() {
		return {};
	},
	methods: {
		// 将富文本内容中标签删除，提取文字部分作为内容展示
		getContent(content){
			const reg = /<[^>]+>/gi; //筛选标签
			return content.split(reg)
			.filter(item => (item !== '')&&(item !== '\n')).join('');
		},
		toShowDetail(title){
			uni.navigateTo({
				url: `/pages/article/articleDetails?title=${title}`
			})
		}
	}
}
</script>

<style scoped lang="scss">
.dynamic-list {
	margin-top: 30rpx;
	.dynamic-item{
		min-height: 190rpx;
		display: flex;
		justify-content: space-between;
		padding-bottom: 30rpx;
		margin-bottom: 30rpx;
		border-bottom: 3rpx solid #eeeeee;
		.item-left{
			width: 65%;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			.ilo{
				color: #000;
				display: flex;
				align-items: center;
				.item-title{
					font-size: 34rpx;
					.item-top{
						color: #e5463d;
						font-size: 28rpx;
						padding: 4rpx;
						border: 2rpx solid #e5463d;
						margin-right: 12rpx;
						border-radius: 12rpx;
					}
				}
			}
			.ilt{
				color: #9b9b9b;
				font-size: 28rpx;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
				margin: 10rpx 0;
			}
			.ilth{
				color: #9b9b9b;
				display: flex;
				justify-content: space-between;
				align-items: flex-end;
				font-size: 28rpx;
			}
		}
		.item-right{
			// width: 25%;
			image{
				border-radius: 12rpx;
				width: 200rpx;
				height: 150rpx;
			}
		}
	}
}
</style>