<template>
	<view class="hot-item">
		<!-- Rank -->
		<view class="rank-col">
			<image v-if="rank === 1" src="/pages-sell/static/hot/icon-first.png" class="rank-icon" mode="widthFix"></image>
			<image v-else-if="rank === 2" src="/pages-sell/static/hot/icon-second.png" class="rank-icon" mode="widthFix"></image>
			<image v-else-if="rank === 3" src="/pages-sell/static/hot/icon-third.png" class="rank-icon" mode="widthFix"></image>
			<text v-else class="rank-text">{{ rank < 10 ? '0' + rank : rank }}</text>
		</view>

		<!-- Book Info -->
		<view class="book-info">
			<image :src="item.cover" class="book-cover" mode="aspectFill"></image>
			
			<view class="info-right">
				<text class="title">{{ item.name || '-' }}</text>
				<text class="author">{{ item.author }}</text>
				
				<view class="bottom-row">
					<view class="price-box">
						<text class="currency">¥</text>
						<text class="price">{{ item.productPrice }}</text>
						<text class="original">¥{{ item.price }}</text>
					</view>
					
					<view class="cart-btn">
						<text>加入购物车</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'HotSellItem',
	props: {
		rank: {
			type: Number,
			required: true
		},
		item: {
			type: Object,
			required: true
		}
	}
}
</script>

<style lang="scss" scoped>
.hot-item {
	display: flex;
	align-items: center;
	padding: 30rpx 0;
	border-bottom: 1rpx solid #f6f7f8;

	.rank-col {
		width: 80rpx;
		display: flex;
		justify-content: center;
		margin-right: 10rpx;

		.rank-icon {
			width: 60rpx;
			height: 60rpx;
		}

		.rank-text {
			font-family: Arial-BoldItalicMT;
			font-size: 36rpx;
			color: #706F6D;
			font-style: italic;
			font-weight: bold;
		}
	}

	.book-info {
		flex: 1;
		display: flex;
		align-items: center;

		.book-cover {
			width: 140rpx;
			height: 180rpx;
			border-radius: 4rpx;
			background-color: #f5f5f5;
			margin-right: 24rpx;
			flex-shrink: 0;
		}

		.info-right {
			flex: 1;
			height: 190rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			padding: 10rpx 0;

			.title {
				font-size: 36rpx;
				color: #303030;
				font-weight: bold;
				line-height: 1.2;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 2;
				-webkit-box-orient: vertical;
			}

			.author {
				font-size: 24rpx;
				color: #999999;
			}

			.bottom-row {
				display: flex;
				justify-content: space-between;
				align-items: flex-end;

				.price-box {
					display: flex;
					align-items: baseline;

					.currency {
						font-size: 36rpx;
						color: #D81A00;
						font-weight: bold;
						margin-right: 6rpx;
					}

					.price {
						font-size: 36rpx;
						color: #D81A00;
						font-weight: bold;
						margin-right: 12rpx;
					}

					.original {
						font-size: 24rpx;
						color: #999999;
						text-decoration: line-through;
					}
				}

				.cart-btn {
					width: 160rpx;
					height: 56rpx;
					background: linear-gradient(90deg, #4ED964 0%, #38C248 100%);
					border-radius: 28rpx;
					display: flex;
					align-items: center;
					justify-content: center;

					text {
						font-size: 24rpx;
						color: #fff;
						font-weight: 500;
					}
				}
			}
		}
	}
}
</style>
