<template>
	<view class="home">
		<view class="home-list">

			<view v-for="(item,index) in tableList" :key="item._id" :item="item">
				<view @click="open">
					<!-- 基础卡片 -->
					<view v-if="item.mode==='base'" class="listcard">
						<view class="listcard-image">
							<image :src="item.cover[0]" mode="aspectFill"></image>
						</view>
						<view class="listcard-content">
							<view class="listcard-content_title">
								<text>{{item.title}}</text>
								<likes :types="types" :item="item"></likes>
							</view>
							<view class="listcard-content_des">
								<view class="listcard-content_des-label">
									<view class="listcard-content_des-label-item">{{item.classify}}</view>
								</view>
								<view class="listcard-content_des-browe">{{item.browse_count}}浏览</view>
							</view>
						</view>
					</view>

					<!-- 多图模式 -->
					<view v-if="item.mode==='column'" class="listcard  mode-column">
						<view class="listcard-content">
							<view class="listcard-content_title">
								<text>{{item.title}}</text>
								<likes :types="types" :item="item"></likes>
							</view>
							<view class="listcard-image">
								<view v-if="index<3" v-for="(item,index) in item.cover" :key="index"
									class="listcard-image_item">
									<image :src="item" mode="aspectFill"></image>
								</view>
							</view>
							<view class="listcard-content_des">
								<view class="listcard-content_des-label">
									<view class="listcard-content_des-label-item">{{item.classify}}</view>
								</view>
								<view class="listcard-content_des-browe">{{item.browse_count}}浏览</view>
							</view>
						</view>
					</view>

					<!-- 大图模式 -->
					<view v-if="item.mode==='image'" class="listcard  mode-image">
						<view class="listcard-image">
							<image :src="item.cover[0]" mode="aspectFill"></image>
						</view>
						<view class="listcard-content">
							<view class="listcard-content_title">
								<text>{{item.title}}</text>
								<likes :types="types" :item="item"></likes>
							</view>

							<view class="listcard-content_des">
								<view class="listcard-content_des-label">
									<view class="listcard-content_des-label-item">{{item.classify}}</view>
								</view>
								<view class="listcard-content_des-browe">{{item.browse_count}}浏览</view>
							</view>
						</view>
					</view>

				</view>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				types:"",
				tableList: [{
						_id: 1,
						title: "出租2015年东方红LX954轮式拖拉机",
						mode: 'base',
						cover: [
							"https://tse4-mm.cn.bing.net/th/id/OIP-C.oXIOhfs0Tp6ePMdc6d7YUAHaJ3?w=132&h=180&c=7&r=0&o=5&pid=1.7"
						],
						classify: "面议",
						browse_count: 111
					},
					{
						_id: 2,
						title: "出租2015年雷沃GE60小麦收割机",
						mode: 'column',
						cover: [
							"https://b.img.s105.cn/wxappup/202008/11172406_4943.jpg!w600h400.jpg",
							"https://tse4-mm.cn.bing.net/th/id/OIP-C.yNPwdLsNcAWkFqmNGjUQYAHaJ4?w=142&h=190&c=7&r=0&o=5&pid=1.7",
							"https://tse1-mm.cn.bing.net/th/id/OIP-C.-VK9NHoU9KzavFK7fAsyLAHaNK?w=115&h=190&c=7&r=0&o=5&pid=1.7"
						],
						classify: "￥15263.11",
						browse_count: 222
					},
					{
						_id: 3,
						title: "出租久保田888半喂入联合收割机",
						mode: 'image',
						cover: [
							"https://b.img.s105.cn/wxappup/201908/21084758_8856.jpg?x-oss-process=image/resize,m_fill,h_343,w_410,limit_0"
						],
						classify: "￥110012.00",
						browse_count: 333
					},
				],
			};
		},
		methods: {
			open() {

			}

		}
	};
</script>

<style lang="scss">
	page {
		height: 100%;
		display: flex;
	}

	.home {
		display: flex;
		flex-direction: column;
		flex: 1;
		overflow: hidden;

		.home-list {
			flex: 1;
			box-sizing: border-box;
		}
	}
	.listcard {
		display: flex;
		padding: 15px;
		margin: 20px;
		border-radius: 5px;
		box-shadow: 0 0 5px 1px rgba($color:#000000, $alpha:0.1);
		box-sizing: border-box;
	
		.listcard-image {
			flex-shrink: 0;
			width: 80px;
			height: 80px;
			border-radius: 8px;
			overflow: hidden;
	
			image {
				width: 100%;
				height: 100%;
			}
	
		}
	
		.listcard-content {
			display: flex;
			flex-direction: column;
			padding-left: 10px;
			width: 100%;
			justify-content: space-between;
	
			.listcard-content_title {
				padding-right: 30px;
				font-size: 14px;
				color: #333;
				font-weight: 400;
				line-height: 1.2;
				position: relative;
	
				text {
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
				}
	
				
			}
	
			.listcard-content_des {
				display: flex;
				justify-content: space-between;
				font-size: 12px;
	
				.listcard-content_des-label {
					display: flex;
	
					.listcard-content_des-label-item {
						padding: 0 5px;
						margin-right: 5px;
						border-radius: 15px;
						color: #f00;
						border: 1px  #f00 solid;
					}
				}
	
				.listcard-content_des-browe {
					color: #999;
					line-height: 1.5;
				}
			}
		}
	
		&.mode-column {
			.list-content {
				width: 100%;
				padding-left: 0;
			}
	
			.listcard-image {
				display: flex;
				margin-top: 10px;
				width: 100%;
				height: 80px;
	
				.listcard-image_item {
					margin-left: 10px;
					width: 100%;
					border-radius: 5px;
					overflow: hidden;
	
					&:first-child {
						margin-left: 0;
					}
	
					image {
						width: 100%;
						height: 100%;
					}
	
				}
			}
	
			.listcard-content_des {
				margin-top: 10px;
			}
		}
	
		&.mode-image {
			flex-direction: column;
	
			.listcard-image {
				width: 100%;
				height: 100px;
			}
	
			.listcard-content {
				padding-left: 0;
				margin-top: 10px;
	
				.listcard-content_des {
					display: flex;
					align-items: center;
					margin-top: 10px;
				}
			}
		}
	}
</style>
