<template>
	<view class="goods-item">
		<u-lazy-load img-mode="scaleToFill" :height="imgHeight" :image="data.src" :loading-img="loadingImg" :error-img="errorImg"></u-lazy-load>
		<view class="name">{{data.name}}</view>
		<view class="price">
			<view><text>{{data.price}}</text>乐豆</view>
			<view><u-image width="48rpx" height="48rpx" src="/static/add-cart.png"></u-image></view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			imgHeight: {
				type: Number,
				default: 250
			},
			data:{
				type: Object,
				default: function(){
					return {}
				}
			}
		},
		data() {
			return {
				loadingImg: '/static/loading.gif',
				errorImg: '/static/imgError.png'
			}
		}
	}
</script>

<style lang="scss">
.goods-item{
	background: #FFFFFF;
	box-shadow: 1px 1px 3px #eee;
	width: 48%;
	margin-bottom: 35upx;
	.name{
		padding: 10upx 20upx 0;
	}
	.price{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 15upx 20upx;
		text{
			color: red;
			font-size: 36upx;
			margin-right: 6upx;
		}
		>view{
			&:first-child{
				font-size: 22upx;
			}
		}
	}
}
</style>
