<template>
	<view class="recommend_content">
		<view class="line">
			<image class="image" src="../../static/imgs/public/img_line.png" mode="aspectFill"></image>
		</view>
		<view class="top">
			<view class="top__title">同类推荐</view>
			<view class="top__change" @click="clickChangeBook()">
				<image class="image" src="../../static/imgs/public/img_change.png" mode="aspectFill"></image>
			</view>
		</view>
		<view class="book-content">
			<view class="book-content__box" v-for="(item,index) in book_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>
		</view>
	</view>
</template>

<script setup lang="ts">
    import { book_item_data } from '../../data/data';
    import { tools } from '../../framework/tools';
	defineProps({
		book_list: Array,
	})
	const emits = defineEmits(['clickChangeBook'])
	
	function clickChangeBook() {
		emits('clickChangeBook')
	}
	
	function clickBook(data:book_item_data) {
		tools.gotoBookdetails(data.book_id)
	}
	
</script>

<style lang="scss">
	.recommend_content{
		display: flex;
		flex-direction: column;
		padding: 0 20rpx;
		margin-top: 40rpx;
		
		.line{
			flex-shrink: 0;
			width: 670rpx;
			height: 17rpx;
			.image{
				width: 100%;
				height: 100%;
			}
		}
		
		.top{
			margin-top: 40rpx;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			&__title {
				font-size: 20px;
			}
			&__change {
				flex-shrink: 0;
				width: 220rpx;
				height: 80rpx;
				.image {
					width: 100%;
					height: 100%;
				}
			}
		}
		
		.book-content{
			display: flex;
			flex: 1;
			box-sizing: border-box;
			flex-direction: row;
			flex-wrap: wrap;
			text-align: center;
			// background-color: red;
			
			&__box{
				width: 33.3%;
				justify-content: center;
				margin-bottom: 20rpx;
				overflow: hidden;
				// background-color: greenyellow;
								
				&__book-cover{
					flex-shrink: 0;
					display: flex;
					box-sizing: border-box;
					margin: 20rpx;
					height: 260rpx;
					.image{
						width: 100%;
						height: 100%;
					}
				}
				&__book-name {
					font-size: 16px;
					margin: 0px 20rpx;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					overflow: hidden;
					text-overflow: ellipsis;
					text-align: left;
				}
			}
		}
	}
</style>