<template>
	<view class="container">
		<view class="goodsList-box">
			<view class="goodsList-item flex" :key="ind" v-for="(ls, ind) in firstList" @click="navTo(ls)">
				<image :src="ls.image" mode=" scaleToFill"></image>
				<view class="goodsList-content">
					<view class="title clamp2">
						<text>{{ ls.store_name }}</text>
					</view>
					<view class="goods-money flex">
						<view class="money-box">
							<view class="old-price" v-if="ls.ot_price * 1 > ls.price * 1">
								<text class="old-left">¥{{ ls.ot_price }}</text>
								<image src="../../static/icon/down.png" mode="widthFix"></image>
								<text class="old-right">直降{{ ls.ot_price * 1 - ls.price * 1 }}元</text>
							</view>
							<view class="otMoney-box flex">
								<view class="otMoney">￥{{ ls.price }}</view>
								<view class="goodsList-btn">
									立即购买
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		groomList
	} from '@/api/product.js';
	export default {
		data() {
			return {
				list: [],
				bannerImg: []
			};
		},
		onLoad(option) {
			// 获取查询对象
			this.type = option.type;
			// 加载基础数据
			this.loadData();
		},
		methods: {
			navTo: function(ls) {
				uni.navigateTo({
					url: '/pages/product/product?id=' + ls.id + '&isvip=1'
				});
			},
			// 请求载入数据
			async loadData() {
				groomList({}, this.type)
					.then(({
						data
					}) => {
						// 保存轮播图
						this.bannerImg = data.banner;
						// 保存商品信息
						this.list = data.list;
					})
					.catch(e => {
						console.log(e);
					});
			},
			// 轮播图跳转
			bannerNavToUrl(item) {
				// #ifdef H5
				if (item.wap_link.indexOf('http') > 0) {
					window.location.href = item.wap_link;
				}
				// #endif
				if (item.wap_link) {
					uni.navigateTo({
						url: item.wap_link
					});
				}
			}
		}
	};
</script>

<style lang="scss">
	page {
		background: $page-color-base;
	}

	.carousel-section {
		padding: 0;

		.titleNview-placing {
			padding-top: 0;
			height: 0;
		}

		.swiper-dots {
			left: 45rpx;
			bottom: 40rpx;
		}

		.carousel {
			width: 100%;
			height: 360rpx;

			.carousel-item {
				width: 100%;
				height: 100%;
				overflow: hidden;
			}

			image {
				width: 100%;
				height: 100%;
			}
		}
	}

	// 中间标题样式
	.type-title-box {
		padding: 40rpx;

		.title-content {
			height: 100%;
			width: 200rpx;
			text-align: center;
			font-size: $font-lg;
			font-weight: 500;
			color: $font-color-dark;
		}

		.title-border {
			width: 250rpx;
			height: 2rpx;
			background-color: #e9e9e9;
		}
	}

	// 商品列表
	.goodsList-box {
		.goodsList-item {
			margin-bottom: 40rpx;
			background-color: #ffffff;
			padding: 30rpx;

			image {
				flex-shrink: 0;
				border-radius: $border-radius-sm;
				height: 180rpx;
				width: 180rpx;
			}

			.goodsList-content {
				margin-left: 20rpx;
				flex-grow: 1;
				height: 180rpx;
				position: relative;

				.title {
					font-size: $font-base;
					color: $font-color-dark;
					font-weight: 500;
				}

				.goods-money {
					position: absolute;
					left: 0;
					bottom: 0;
					width: 100%;

					.money-box {
						image {
							width: 14rpx;
							margin: 0 6rpx 0 10rpx;
						}

						.old-price {
							.old-left {
								font-size: 26rpx;
								font-weight: 500;
								text-decoration: line-through;
								color: #999999;
							}

							.old-right {
								font-size: 24rpx;
								font-weight: bold;
								color: #b59467;
							}
						}

						.otMoney-box {
							display: flex;
							align-items: center;

							.otMoney {
								font-size: 36rpx;
								color: $color-red;
								padding-right: 20rpx;
							}


						}
					}

					.goodsList-btn {
						position: absolute;
						bottom: 0;
						right: 0;
						width: 137rpx;
						height: 52rpx;
						background: #9c0b18;
						border-radius: 26rpx;
						display: flex;
						justify-content: center;
						align-items: center;
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #FFFFFF;
					}
				}
			}
		}
	}
</style>