<template>
	<view class="center">
		<view class="hotgoods">
			<view class="hotgoods-item" v-for="item in list" :key="item.id"
				@click="navto('/pages/product/product?id=' + item.id + '&isfg=1')" style="height: 520rpx;">
				<view class="image-wrapper">
					<image class="image" :src="item.image" mode="scaleToFill"></image>
				</view>
				<view class="flex"
					style="flex-direction: column;justify-content: space-between;align-items: flex-start;height: 170rpx;">
					<view class="title clamp2">{{item.store_name}}</view>
					<view class="hot-price">
						<view class="price">
							<text class="font-size-sm"></text>
							¥{{ item.price * 1 }}
						</view>
						<view class="yuanPrice" v-if="item.ot_price*1 > item.price*1">¥{{ item.ot_price*1 }}</view>
					</view>
				</view>

			</view>
		</view>
		<uni-load-more :status="loadingType"></uni-load-more>
	</view>
</template>

<script>
	import {
		loadIndexs,
		groom1
	} from '@/api/index.js';
	export default {
		data() {
			return {
				id: '',
				list: [],
				page: 1,
				limit: 10,
				loadingType: 'more'
			};
		},
		onLoad() {
			this.loadData();
		},
		methods: {
			loadData() {
				this.loadingType = 'loading'
				groom1().then(res => {
					this.list = res.data.list
					this.loadingType = 'noMore'
				})
			},
			navto(url, type = 0) {
				if (type == 1) {
					if (!this.hasLogin) {
						// 保存地址
						saveUrl();
						// 登录拦截
						interceptor();
					} else {
						uni.navigateTo({
							url,
							fail() {
								uni.switchTab({
									url
								})
							}
						})
					}
				} else {
					uni.navigateTo({
						url,
						fail() {
							uni.switchTab({
								url
							})
						}
					})
				}
			
			},
		}
	};
</script>

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

		.hotgoods-item {
			width: 345rpx;
			background-color: #ffffff;
			border-radius: 12rpx;
			box-shadow: 0 0 15rpx rgba(0, 0, 0, 0.2);
			margin-bottom: 15rpx;

			.image-wrapper {
				width: 345rpx;
				height: 345rpx;
				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: 24rpx;
				padding: 0 20rpx;
				font-size: 32rpx;
				font-weight: 500;
				color: #333333;
			}

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

				.hotPrice-box {
					padding: 2rpx 6rpx;

					background: linear-gradient(90deg, #c79a4c, #f9df7f);
					border-radius: 5rpx;
					text-align: center;
					line-height: 28rpx;
					font-size: 20rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #ffffff;
				}

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

					.jf {
						font-size: 20rpx;
					}
				}

				.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>