<template>
	<view class="book-List-content">
		<view class="title-content">
			<view class="title-content__image">
				<image class="image" src="../../../static/imgs/bookstore/img_cainixihuan.png" mode="aspectFit"></image>
			</view>
		</view>
		<view class="book-content">
			<view class="book-content__box" v-for="(item,index) in templateData.list" :key="index" @click="clickBook(item)">
				<view class="book-content__box__book-cover">
					<image class="image" :src="item.book_cover" mode="aspectFill"></image>
				</view>
				<view class="book-content__box__book-name">{{item.book_name}}</view>
				<view class="book-content__box__book-brief">{{item.book_brief}}</view>
				<view class="book-content__box__book-info" >
					<view class="book-content__box__book-info__category-name">
						{{item.category_name}}
					</view>
					<view class="book-content__box__book-info__score">
						{{item.book_score}}分
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { book_item_data } from '../../../data/data';
	defineProps({
		templateData: Object,
	})
	const emits = defineEmits(['clickBook'])
	
	function clickBook(data:book_item_data) {
		emits('clickBook',data)
	}
</script>

<style lang="scss">
	.book-List-content{
		display: flex;
		flex-direction: column;
		margin: 0px 20rpx;
		margin-bottom: 30rpx;
		
		.title-content {
			display: flex;
			box-sizing: border-box;
			justify-content: center;
			margin: 30rpx;
			
			&__image {
				flex-shrink: 0;
				width: 680rpx;
				height: 40rpx;
				.image {
					width: 100%;
					height: 100%;
				}
			}
		}
		
		.book-content{
			display: flex;
			flex: 1;
			flex-direction: row;
			flex-wrap: wrap;
			padding: 20rpx 0;
			
			&__box{
				width: 46%;
				margin: 0 2%;
				justify-content: center;
				margin-bottom: 30rpx;
				overflow: hidden;
				border-radius: 20rpx;
				box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.1);
				background-color: #ffffff;
				
				&__book-cover{
					flex-shrink: 0;
					display: flex;
					box-sizing: border-box;
					margin: 20rpx;
					height: 420rpx;
					.image{
						width: 100%;
						height: 100%;
						border-radius: 20rpx;
						// background-color: orange;
					}
				}
				&__book-name{
					text-align: left;
					font-size: 18px;
					color: #000000;
					margin: 0 20rpx;
					margin-bottom: 20rpx;
					// height: 96rpx;
					// background-color: red;
					display: -webkit-box;
					-webkit-line-clamp: 1;
					-webkit-box-orient: vertical;
					overflow: hidden;
					text-overflow: ellipsis;
				}
				&__book-brief{
					text-align: left;
					font-size: 14px;
					color: #6F6F6F;
					margin: 0px 20rpx;
					margin-bottom: 20rpx;
					height: 70rpx;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					overflow: hidden;
					text-overflow: ellipsis;
				}
				&__book-info{
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					align-items: center;
					padding: 0 20rpx;
					margin-bottom: 20rpx;
					&__category-name {
						color: #6F6F6F;
					}
					&__score{
						color: #F12626;
					}
				}
			}
			
		}
	}
	
</style>