<template>
	<view class="block">
		<view class="goods" :data-num="num">
			<view class="pic">
				<image :src="item.img" mode="aspectFit" />
			</view>
			<text class="price">{{item.price}}</text>
			<text class="name">{{item.name}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			num: {
				type: Number,
				default: 0
			},
			item: {
				type: Object,
				required: true
			}
		}
	}
</script>

<style lang="scss" scoped>
	.block {
		display: inline-block;

		.goods {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			width: 160rpx;
			position: relative;

			&::after {
				content: attr(data-num);
				position: absolute;
				width: 40rpx;
				height: 40rpx;
				line-height: 40rpx;
				top: 0rpx;
				right: 0rpx;
				text-align: center;
				font-size: $uni-font-size-sm;
				color: $uni-text-color-inverse;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			.pic {
				width: 160rpx;
				height: 160rpx;
				background-image: url(../../static/images/goods-bg.png);
				background-size: 160rpx 160rpx;
				display: flex;
				align-items: center;
				justify-content: center;

				image {
					width: 60%;
					height: 60%;
					margin-right: 20rpx;
					background-color: $uni-bg-color;
				}
			}

			.price {
				color: $uni-color-error;
				font-size: $uni-font-size-base;
				font-weight: bold;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			.name {
				color: $uni-text-color;
				font-size: $uni-font-size-base;
				font-weight: bold;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}
		}
	}
</style>
