<template>
	<view class="container">
		<view class="goodsList-box">
			<view class="goodsList-item flex" :key="ind" v-for="(ls, ind) in list">
				<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="money">
								<text class="font-size-sm">￥</text>
								{{ ls.price }}
							</view>
							<!-- <view class="otMoney-box">
								<text class="otMoney">￥{{ ls.ot_price }}</text>
								<text class="sales">已售{{ ls.sales }}件</text>
							</view> -->
						</view>
						<view @click="navTo(ls)" class="cart iconfont iconcart"></view>
					</view>
				</view>
			</view>

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

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import {
		groomList,
		getProducts
	} from '@/api/product.js';
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				list: [],
				loadingType: 'more',
				page: 1,
				limit: 10,
			};
		},
		onLoad(option) {
			// 获取查询对象
			this.type = option.type;
			// 加载基础数据
			this.loadData();
		},
		methods: {
			navTo: function(ls) {
				uni.navigateTo({
					url: '/pages/product/product?id=' + ls.id
				});
			},
			// 请求载入数据
			async loadData() {
				let obj = this
				if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
					return
				}
				obj.loadingType = 'loading'

				getProducts({
					is_up_level: obj.type
				}).then(({
					data
				}) => {
					console.log(data)
					obj.list = obj.list.concat(data)
					obj.page++
					if (data.length == obj.limit) {
						obj.loadingType = 'more'
					} else {
						obj.loadingType = 'noMore'
					}
				})

			}
		}
	};
</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 {
						.money {
							font-size: $font-lg;
							color: $color-red;
							font-weight: bold;
						}

						.otMoney-box {
							font-size: $font-sm;

							.otMoney {
								color: $font-color-dark;
								padding-right: 20rpx;
							}

							.sales {
								color: $font-color-light;
							}
						}
					}

					.cart {
						border: 1px solid $color-red;
						color: $color-red;
						font-size: $font-base;
						font-weight: bold;
						border-radius: 99px;
						width: 55rpx;
						height: 55rpx;
						display: flex;
						justify-content: center;
						align-items: center;
					}
				}
			}
		}
	}
</style>
