<template>
	<view class="content">
		<view class="hot-list">
			<view class="hotgoods-item" v-if="list.length > 0" v-for="jfitem in list" :key="jfitem.id"
				@click="navto('/pages/product/product?id=' + jfitem.id)">
				<view class="image-wrapper">
					<image class="image" :src="jfitem.image" mode="scaleToFill"></image>
				</view>
				<view class="flex"
					style="flex-direction: column;justify-content: space-between;align-items: flex-start;">
					<view class="title clamp">{{jfitem.store_name}}</view>
					<view class="hot-price">
						<view class="price">
							<image src="../../static/icon/jf.png" mode=""></image>
							<text>{{ jfitem.max_integral * 1 }} + {{(jfitem.price*1 - jfitem.max_integral * 1).toFixed(2)}}</text>
							<!-- <text class="ot-pirce">¥{{jfitem.ot_price}}</text> -->
						</view>
					</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getProducts
	} from '@/api/product.js';
	export default {
		data() {
			return {
				list: [],
				page: 1,
				limit: 5,
				loadingType: 'more',
				loaded: false
			}
		},
		onLoad() {
			this.getList()
		},
		onShow() {
			
		},
		onReachBottom() {
			this.getList()
		},
		onReady() {
			
		},
		methods: {
			navto(url) {
				uni.navigateTo({
					url,
					fail() {
						uni.switchTab({
							url
						})
					}
				})
			},
 			getList() {
				let that = this
				if(that.loadingType == 'noMore' || that.loadingType == 'loading') {
					return
				}
				that.loadingType = 'loading'
				getProducts({
					page: that.page,
					limit: that.limit,
					is_integral: 1
				}).then(res => {
					let arr = res.data
					that.list = that.list.concat(arr)
					if(arr.length == that.limit) {
						that.loadingType = 'more'
					}else {
						that.loadingType = 'noMore'
					}
					that.loaded = true
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.hot-list {
		// 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;
			padding-bottom:20rpx;
	
			.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 10rpx;
				font-size: 32rpx;
				font-weight: 500;
				color: #333333;
				width: 345rpx;
			}
	
			.hot-price {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				width: 100%;
				padding: 0 10rpx;
				// 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: 36rpx;
					color: #ff6b2e;
					font-weight: 500;
					display: flex;
					width: 100%;
					justify-content: flex-start;
					align-items: center;
					image {
						width: 24rpx;
						height: 26rpx;
					}
					.jf {
						font-size: 20rpx;
					}
	
					.give-jf {
						display: inline-block;
						padding: 8rpx;
	
						background: linear-gradient(90deg, #FF834D, #FF2600);
						border-radius: 12rpx 0px 12rpx 0px;
	
						font-size: 22rpx;
						font-weight: 500;
						color: #FFFFFF;
						margin-left: 22rpx;
					}
	
					.ot-pirce {
						margin-left: 7rpx;
						font-size: 26rpx;
						font-weight: 500;
						text-decoration: line-through;
						color: #999999;
						align-self: flex-end;
					}
	
				}
	
				.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>