<template>
	<view class="produce-list">
		<view class="produce-item"
		v-for="(item,index) in list"
		:key="index"
		@click="goProduct(item)"
		>
			<view class="">
				<image
				mode="aspectFill"
				:src="item.image ? item.image.split(',')[0] : ''"
				alt="" class="img"/>
			</view>
			<view class="title">
				{{ item.title }}
			</view>
			<view>
				<text class="price">{{ item.price }}</text>
				<text class="oldPrice" v-if="item.oldPrice">{{ item.oldPrice }}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"productList",
		props : {
			list : {
				default : [],
			}
		},
		data() {
			return {
				
			};
		},
		methods : {
			goProduct(e){
				uni.navigateTo({
					url: '/pages/productDetail/productDetail?id=' + e.id
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
.produce-list{
	display: flex;
    flex-wrap: wrap;
	margin: 5px;
	.produce-item{
		width: calc(50% - 10px);
		height: calc(50% - 10px);
		box-shadow: 1px 1px 1px 1px #00000005;
		margin: 5px;
		box-sizing: border-box;
		background-color: #fff;
		padding: 20px;
		border-radius: 20rpx;
		.img{
			width: 100%;
			height: 360rpx;
		}
		.title{
			font-size: 23rpx;
			line-height: 2em;
			text-overflow: ellipsis;
			display: -webkit-box; 
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 1; 
			overflow: hidden;
		}
		.price{
			font-size: 29rpx;
			padding-right: 8px;
			color: #E01717;
		}
		.oldPrice{
			font-size: 20rpx;
			text-decoration: line-through;
			color: #B8B8B8;
		}
	}
}
</style>