<template>
	<!-- 新鲜事/话题列表 -->
	<view class="topic-list flex items-center">
		<image style="width: 200rpx; height: 150rpx;" :src="item.cover" lazy-load mode="aspectFill"></image>
		<view class="my-20" style="width: 500rpx; ">
			<view class="text-black text-32 asset_name">{{item.asset_name}}</view>
			<view class="text-gray-400 text-26 my-10 digest">{{item.digest}}</view>
			<view v-if="type!='history'" class="operation">
				<view>点击量：{{formatNumber(item.read_num)}}</view>
				<view>今日：{{formatNumber(item.today)}}</view>
				<!-- <view v-if='item.type==2' class="download"><u-icon name="download" color="#9CA3AF "
						size="24"></u-icon>下载</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	/*
	 * newsTopicList 新鲜事页话题列表
	 * @description 用于新鲜事页中话题栏下面的话题列表
	 * @author MrThinco
	 * @property {Object} item 信息
	 */
	export default {
		props: {
			item: {
				type: Object,
				default: () => ({})
			},
			type: {
				type: String,
				default: ""
			}
		},
		data() {
			return {

			}
		},
		methods: {
			formatNumber(num) {
				if (num >= 10000) {
					return (num / 10000).toFixed(1) + 'w'; // 保留一位小数并加上'w'
				} else if (num >= 1000) {
					return (num / 1000).toFixed(1) + 'k'; // 保留一位小数并加上'k'
				} else {
					return num.toString(); // 小于1000直接返回数字
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.topic-list {
		background-color: #FFFFFF;
		margin-top: 20rpx;
		border-radius: 10rpx;
		padding: 15rpx 10rpx;

		image {
			width: 150rpx;
			height: 150rpx;
			border-radius: 10rpx;
			margin-right: 20rpx;
		}
	}

	.digest {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		/* 定义显示的行数 */
		overflow: hidden;
		text-overflow: ellipsis;
		padding-right: 20rpx;
	}

	.asset_name {
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		padding-right: 20rpx;
	}

	.operation {
		// border: solid 1px red;
		display: flex;
		align-items: center;
		justify-content: space-between;
		color: #9CA3AF;
		font-size: 26rpx;
		padding: 0 20rpx 0 0;

		.download {
			display: flex;
			align-items: center;
		}
	}
</style>