<template>
	<view class="content">
		<!-- #ifdef APP-PLUS -->
		<view class="status_bar"></view>
		<!-- #endif -->
		<view class="body-title">
			<view class="goback-box" @click="toBack">
				<image class="goback" src="../../static/icon/fanhui.png" mode=""></image>
			</view>
			<view class="header">消费专区</view>
		</view>
		<view class="top-bg flex">
			<image src="../../static/img/xf-mbg.png" mode=""></image>
		</view>
		<view class="bastgood-box">
			<view class="bg-bg"></view>
			<view v-for="(item, index) in list" :key="item.id" class="guess-item" @click.stop="navTo('/pages/product/product?id='+ item.id + '&is_xf=1&is_bk=0')">
				<image :src="item.image"></image>
				<view class="guess-box">
					<view class="title clamp2">{{item.store_name}}</view>
					<view class="info">
						<view class="price-box flex">
							<image src="../../static/icon/xfq.png" mode="widthFix"></image>
							<view class="jiang">可抵用消费券</view>
						</view>
						<view class="price">￥{{ item.price }}
							<view class="yuanprice">￥{{item.ot_price*1}}</view>
						</view>
					</view>

					<view class="btn" >
						立即购买</view>
				</view>
			</view>
			<uni-load-more :status="loadingType"></uni-load-more>
		</view>

	</view>
</template>

<script>
	import {
		getProducts
	} from '@/api/product.js'
	export default {
		data() {
			return {
				page: 1,
				limit: 10,
				list: [],
				loadingType: 'more'
			}
		},
		onLoad() {
			this.getProducts()
		},
		onShow() {

		},
		onReachBottom() {
			this.getProducts()
		},
		onReady() {

		},
		methods: {
			navTo(url) {
				uni.navigateTo({
					url
				})
			},
			toBack() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			},
			getProducts() {
				let obj = this
				if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
					return
				}
				obj.loadingType = 'loading'
				getProducts({
					sid: 4,
					page: obj.page,
					limit: obj.limit
				}).then(res => {
					console.log(res)
					obj.list = obj.list.concat(res.data)
					obj.page++
					if (obj.limit == res.data.length) {
						obj.loadingType = 'more'
					} else {
						obj.loadingType = 'noMore'
					}
				})
			}
		}
	}
</script>

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

	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
		background: #f32b09;
	}

	.top-bg {
		background: #f32b09;
		justify-content: center;
		align-items: center;
		padding: 30rpx 0;

		image {
			width: 700rpx;
			height: 350rpx;
			border-radius: 20rpx;

		}
	}

	.bastgood-box {
		background-color: #ffffff;
		position: relative;

		.bg-bg {
			position: absolute;
			height: 380rpx;
			width: 750rpx;
			top: 0;
			left: 0;
			background: linear-gradient(180deg, #f32b09, #fff);
		}

		.guess-item {
			display: flex;
			width: 710rpx;
			background: #ffffff;
			box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
			border-radius: 10rpx;
			padding: 15rpx;
			margin: 0rpx auto 20rpx;
			position: relative;

			image {
				width: 236rpx;
				height: 236rpx;
				border-radius: 10rpx;
			}

			.guess-box {
				padding: 12rpx 0 15rpx 24rpx;
				width: 436rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.title {
					font-size: 32rpx;
					padding-left: 4rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #333333;
					width: 368rpx;
					line-height: 36rpx;
				}

				.price-box {
					// margin-top: 76rpx;
					justify-content: flex-start;

					image {
						width: 28rpx;
					}

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

				.price {
					font-size: 36rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #ff1135;
					display: flex;
					align-items: center;

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

				.btn {
					width: 138rpx;
					height: 52rpx;
					background: #ff4c4c;
					border-radius: 26rpx;
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #ffffff;
					line-height: 52rpx;
					text-align: center;
					position: absolute;
					bottom: 25rpx;
					right: 25rpx;
				}
			}
		}
	}

	.body-title {
		height: 80rpx;
		text-align: center;
		font-size: 35rpx;
		background-color: #f32b09;
		position: relative;

		.header {
			position: absolute;
			left: 0;
			top: 0;
			width: 100%;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #fffeff;
			height: 80rpx;
			font-size: 36rpx;
			font-weight: 700;
			z-index: 9;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.goback-box {
			position: absolute;
			left: 18rpx;
			top: 0;
			height: 80rpx;
			display: flex;
			align-items: center;
		}

		.goback {
			z-index: 100;
			width: 34rpx;
			height: 34rpx;
		}
	}
</style>
