<template>
	<view>
		<view class="list">
			<view class="news_item" v-for="(item, index) in list" :key="index" @click="detail(item)">
				<image src="../../static/news.jpg" mode="aspectFill" class="img"></image>
				<view class="con">
					<view class="title ellip">广西边境口岸城市年中经济新观察边贸旺 旅游热 产业稳广西边境口岸城市年中经济新观察边贸旺 旅游热 产业稳</view>
					<view class="date">
						<text class="icon">&#xe65c;</text>
						<text>{{ item.readCount }}</text>
					</view>
					<text class="releaseTime">{{ item.releaseTime }}</text>
				</view>
				<view class="clear"></view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			list: [],
			param: { pageNum: 1, pageSize: 10, orderByColumn: 'createTime', isAsc: 'desc' },
			loadMore: true
		};
	},
	onLoad(e) {
		this.getData();
	},
	methods: {
		getData() {
			this.http.request({
				url: '/level-one-server/app/TbPortNews/getPortNewsList',
				data: this.param,
				loading: 'false',
				success: res => {
					this.list.push(...res.data.data);
				}
			});
		},
		detail(item) {
			uni.navigateTo({
				url: '/pages/news/detail?id=' + item.id
			});
		},
		//刷新数据
		refresh() {
			this.loadMore = true;
			this.param.pageNum = 1;
			this.list = [];
			this.getData();
		}
	},
	//下拉刷新
	onPullDownRefresh() {
		setTimeout(() => {
			this.refresh();
			uni.stopPullDownRefresh();
		}, 1000);
	},
	//上拉加载
	onReachBottom() {
		if (this.loadMore) {
			this.param.pageNum++;
			this.getData();
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: #f5f5f5;
}
.list {
	padding: 12px;
}
</style>
