<template>
	<view class="page-color">
		<view class="padding-lr lf-p-t-30" v-if="article_list.length">
			<view class="card-discover lf-m-b-30" v-for="(item,index) of article_list" :key="index">
				<view class="lf-h-100 lf-w-100 lf-flex" @click="$url('/pages/notice/article?article_id='+item.big.id)" v-if="item.big">
					<image :src="item.big.image" mode="aspectFill" style="width: 686rpx;height: 300rpx;border-radius: 20rpx 20rpx 0 0;"></image>
				</view>
				<view class="flex-direction bg-white discover-radius" v-if="item.children">
					<view class="flex align-center text-center lf-p-30 solid-bottom" v-for="(i,index) of item.children" :key="index" @click="$url('/pages/notice/article?article_id='+i.id)">
						<view>
							<image :src="i.image" mode="aspectFill" style="width: 100rpx;height: 100rpx;"></image>
						</view>
						<view class="lf-line-2 lf-color-333 lf-font-28  lf-text-left lf-m-l-20" style="line-height: 44rpx;">
							{{i.title}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 加载 -->
		<view class="loading-more lf-p-b-40">
			<text v-if="article_list.length && loadingClass==false" :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
			<lf-nocontent v-if="!article_list.length && loadingClass==false"></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 {
				page: 1,
				article_list: [],
				loadingClass: true,
				loadingText: '正在加载中',
				isPage: false
			}
		},
		methods: {
			getArticle() {
				this.$http(this.API.API_FINDARTICLE,{page: this.page}).then(res => {
					let isPage = res.data.next_page_url == null?false:true;
					this.isPage = isPage;
					if(!isPage){
						this.loadingClass = false;
						this.loadingText = '没有更多数据啦~';
					}
					if(this.page == 1){
						this.article_list = res.data.data;
					}else{
						this.article_list.push(...res.data.data);
					}
					console.log(res)
				}).catch(err => {
					
				})
			},
		},
		onLoad() {
			this.getArticle()
		},
		onReachBottom(){
			if(this.isPage){
				this.page = this.page + 1;
				this.getArticle();
			}
		},
		onPullDownRefresh(){
			this.page = 1;
			this.isPage = true;
			this.loadingClass = true;
			this.loadingText = '正在加载中';
			this.getArticle();
			uni.stopPullDownRefresh();
		}
	}
</script>

<style>
	page{
		background-color: #F6F6F6;
	}
</style>

<style scoped>
	.page-color {
		width: 100%;
		height: 100%;
		background-color: #F6F6F6;
	}
	.card-discover {
		border-radius: 20rpx;
	}
	.discover-radius {
		border-radius: 0 0 20rpx 20rpx;
	}
</style>
