<template>
	<view>
		<!-- 活动列表 -->
		<view class="content">
			<view class="item" v-for="(item,index) in list" :key="index" @click="$url('/pages/goodsDetail/index?goods_id='+item.id)">
				<view class="cover">
					<image :src="item.product.picture" class="lf-w-100 lf-h-100" mode="aspectFill"></image>
				</view>
				<view style="width: 420rpx;">
					<view class="lf-font-28 lf-color-333 lf-m-b-20 lf-line-2" style="height: 78rpx;">{{item.product.title}}</view>
					<view class="lf-font-24 lf-color-gray">本套票只包含两个成人不可带小孩</view>
					<view class="lf-flex lf-m-t-25">
						<lf-price :price="item.price"></lf-price>
						<text class="lf-font-24 lf-color-gray lf-line-through lf-m-l-15">¥{{item.original_price}}</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 加载 -->
		<view class="loading-more">
			<text v-if="list.length" :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
			<lf-nocontent v-else></lf-nocontent>
		</view>
		<!-- 回到顶部 -->
		<u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				list: [],
				loadingClass: false,
				loadingText: '已加载全部数据~',
				page: 1,
				isPage: true,
				pageSize: 20,
			}
		},
		onLoad(e){
			this.getActivityList();
		},
		methods: {
			getActivityList(){
				this.$http(this.API.API_HOTLIST,{page:this.page}).then(res => {
					let isPage = res.data.next_page_url == null?false:true;
					this.isPage = isPage;
					let list = res.data.data;
					if(!isPage){
						this.loadingClass = false;
						this.loadingText = '已加载全部数据~';
					}
					if(this.page == 1){
						this.list = list;
					}else{
						this.list.push(...list);
					}
					
					console.log(list)
				})
			},
			// 进入商品详情页
			enterDetail(index){
				let goods_id = this.list[index].goods_id;
				this.$url('/pages/goodsDetail/index?goods_id='+ goods_id);
			}
		},
		onReachBottom(){
			if(this.isPage){
				this.page = this.page + 1;
				this.getActivityList();
			}
		},
		onPullDownRefresh(){
			this.page = 1;
			this.isPage = true;
			this.loadingClass = true;
			this.loadingText = '正在加载中';
			this.getActivityList();
			uni.stopPullDownRefresh();
		}
	}
</script>

<style lang="scss" scoped="scoped">
	.content{
		padding: 0 32rpx;
		box-sizing: border-box;
		width: 750rpx;
		height: max-content;
		.item{
			width: 100%;
			height: auto;
			border-bottom: 1rpx solid #E5E5E5;
			padding: 30rpx 0;
			display: flex;
			&:last-child{
				border-bottom: none;
			}
			.cover{
				width: 250rpx;
				height: 210rpx;
				border-radius: 20rpx;
				overflow: hidden;
				margin-right: 15rpx;
			}
		}
	}
</style>
