<template>
	<view class="content">
		<view class="hotgoods">
			<view class="hotgoods-item" v-for="item in firstList" :key="item.id" @click="navToDetailPage(item)">
				<view class="image-wrapper">

					<image class="image" :src="item.image" mode="scaleToFill"></image>
				</view>
				<view class="hotgoods-box">
					<view class="title clamp2">{{ item.store_name }}</view>
					<!-- <view class="titlee">{{ item.store_name }}</view> -->
				</view>
				<view class="hot-price">
					<view class="price">
						<text class="font-size-sm">￥</text>
						{{ item.price * 1 }}
					</view>
					<view class="yuanPrice">原价{{ item.price }}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		loadIndexs,
	} from '@/api/index.js';
	export default {
		data() {
			return {
				firstList: []
			}
		},
		onLoad() {

		},
		onShow() {
			this.loadData()
		},
		onReachBottom() {

		},
		onReady() {

		},
		methods: {
			async loadData() {
				loadIndexs({})
					.then(({
						data
					}) => {
						let goods = data.info;


						data.info.firstList.forEach(e => {
							e.isVip = e.store_type ? "3" : "0"
						})
						this.firstList = data.info.firstList //首页商品
					})
					.catch(e => {
					});

			},
			//详情页
			navToDetailPage(item) {
				let id = item.id;
				uni.navigateTo({
					url: '/pages/product/product?id=' + id + '&isVip=' + 0
				});
			},
		}
	}
</script>

<style lang="scss">
	.hotgoods {
		margin-top: 38rpx;
		width: 100%;
		display: flex;
		flex-wrap: wrap;
		padding: 0 0 30rpx;

		.hotgoods-item {
			width: 44%;
			background: #FFFFFF;
			margin: 20rpx;
			box-shadow: 0px 0px 20px 0px rgba(50, 50, 52, 0.06);
			border-radius: 10px;

			.image-wrapper {
				width: 100%;
				height: 330rpx;
				border-radius: 3px;
				overflow: hidden;
				position: relative;

				.image-bg {
					position: absolute;
					top: 0;
					left: 0;
					right: 0;
					bottom: 0;
					width: 100%;
					height: 100%;
					opacity: 1;
					border-radius: 12rpx 12rpx 0 0;
					z-index: 2;
				}

				.image {
					width: 100%;
					height: 100%;
					opacity: 1;
					border-radius: 12rpx 12rpx 0 0;
				}
			}

			.title {
				margin-top: 20rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
			}

			.hotgoods-box {
				height: 75rpx;
			}

			.titlee {
				margin-left: 15rpx;
				font-size: 26rpx;
				font-weight: 500;
				color: #666666;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;

			}

			.hot-price {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				padding: 14rpx 0 30rpx;

				.hotPrice-box {
					width: 70rpx;
					height: 28rpx;
					background: linear-gradient(90deg, #c79a4c, #f9df7f);
					border-radius: 5rpx;
					text-align: center;
					line-height: 28rpx;
					font-size: 20rpx;
					font-weight: 400;
					color: #ffffff;
				}

				.price {
					margin-left: 10rpx;
					font-size: 36rpx;
					color: #ff0000;
					font-weight: 500;
				}

				.yuanPrice {
					margin-left: 10rpx;
					font-size: 20rpx;
					font-family: PingFang SC;
					font-weight: 500;
					text-decoration: line-through;
					color: #999999;
				}

				.cart-icon {
					image {
						width: 44rpx;
						height: 44rpx;
					}
				}
			}
		}
	}
</style>