<template>
	<view class="main">
		<view class="list-box-h">
			<empty v-if="loaded === true && list.length == 0"></empty>
			<view v-for="(item, index) in list" :key="index" class="guess-item" @click="navToDetailPage(item)">
				<image :src="item.image"></image>
				<view class="guess-box">
					<view class="title clamp2">{{ item.store_name }}</view>
					<view class="flex itemContent">
						<view>
							<view class="price-box flex">
								<view class="yuanprice">{{ item.ot_price }}</view>
								<!-- <image src="../../static/img/jiantou.png" mode=""></image> -->
								<!-- <view class="jiang">直降{{ (item.ot_price - item.price).toFixed(2) }}元</view> -->
							</view>
							<view class="price" >￥{{ item.price }}</view>
						</view>
						<view class="btn">立即购买</view>
					</view>
				</view>
			</view>
		</view>
		<uni-load-more :status="loadingType"></uni-load-more>
	</view>
</template>

<script>
	import empty from '@/components/empty';
	import {
		getProducts
	} from '@/api/product.js';
	export default {
		components: {
			empty
		},
		data() {
			return {
				list: [],
				page: 1,
				limit: 10,
				loadingType: 'more',
				loaded: false
			}
		},
		onLoad(opt) {
			this.getArticleList()
		},
		methods: {
			navToDetailPage(item) {
				uni.navigateTo({
					url: '/pages/product/product?id=' + item.id
				});
			},
			getArticleList() {
				let obj = this
				if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
					return
				}
				obj.loadingType = 'loading'
				getProducts({
					page: obj.page,
					limit: obj.limit,
					// is_gp:1 ,//设置是否vip商品
					// sid:obj.sid
					cid:6
					
					
				}).then(({
					data
				}) => {
					
					obj.list = obj.list.concat(data)
					obj.page++
					if (data.length == obj.limit) {
						obj.loadingType = 'more'
					} else {
						obj.loadingType = 'noMore'
					}
					obj.loaded = true
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #fff;
		min-height: 100%;
	}

	.list-box-h {
		padding: 20rpx;
	}

	.guess-item {
		padding: 10rpx;
		display: flex;
		min-width: 100%;
		width: 0;
		margin-bottom: 20rpx;
		background: #ffffff;
		border-radius: 10rpx;
		box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);

		image {
			width: 200rpx;
			height: 200rpx;
			border-radius: 10rpx;
			flex-shrink: 0;
		}

		.guess-box {
			width: 100%;
			padding: 5px;
			position: relative;
			.itemContent {
				position: absolute ;
				width: 100%;
				padding: 20rpx 10rpx;
				bottom: 0;
				right: 0;
			}
			.title {
				font-size: 30rpx;
				font-weight: bold;
				color: #333333;
				height: 2.5em;
				line-height: 1.25em;
			}

			.price-box {
				justify-content: flex-start;

				.yuanprice {
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 500;
					text-decoration: line-through;
					color: #999999;
					padding-right: 6rpx;
				}

				image {
					width: 14rpx;
					height: 16rpx;
				}

				.jiang {
					padding-left: 2rpx;
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #b59467;
				}
			}

			.price {
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #FF6F0F;
			}

			.btn {
				background: #16cc9f;
				border-radius: 28rpx;
				font-size: 28rpx;
				font-weight: 500;
				color: #ffffff;
				float: right;
				padding: 10rpx 20rpx;
			}
		}
	}
</style>
