<template>
	<view class="main">
		<view class="list_item flex justify-between align-center" @click="toNewsInfo(item.id)"
			v-for="(item,index) in list" :key="index">
			<view class="">
				<view class="news_title">
					{{item.title}}
				</view>
				<view class="news_time">
					丹棱检察·{{$u.timeFrom(parseInt(item.created_at), 'yyyy年mm月dd日')}}
				</view>
			</view>
			<view class="" v-if="item.show_img!=''">
				<u-image width="224rpx" height="168rpx" :src="item.show_img"></u-image>
			</view>
		</view>
		<uni-load-more :loadingType="loadingType" :contentText="contentText" />
		<!-- <view class="cu-tabbar-height"></view> -->
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				callUrl: '',
				loadingType: 0,
				contentText: {
					contentdown: '上拉显示更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				indexPage: 1,
				list: [],
				type: null
			}
		},
		onLoad(op) {
			this.type = op.type
			if (op.title !== undefined) {
				uni.setNavigationBarTitle({
					title: op.title
				})
			}
			if (this.type != 4) {
				this.callUrl = '/home/news_list'
				this.getNewsList()
			}
		},
		methods: {
			toNewsInfo(id) {
				uni.navigateTo({
					url: "./newsInfo?id=" + id + '&type=' + this.type
				})
			},
			async getNewsList() {
				let res = await this.$u.get(this.callUrl, {
					page: this.indexPage,
					type: this.type
				})
				this.list = this.list.concat(res.data)
				this.indexPage++
				if (res.current_page == res.last_page) {
					this.loadingType = 2;
				} else {
					this.loadingType = 0;
				}
			}
		}
	}
</script>

<style>
	.list_item {
		padding: 30rpx 28rpx;
		background: #fff;
		margin: 20rpx 0;
	}

	.news_time {
		font-size: 22rpx;
		font-family: PingFang-SC-Medium, PingFang-SC;
		font-weight: 500;
		color: #999999;
		margin-top: 46rpx;
	}

	.news_title {
		font-size: 28rpx;
		font-family: PingFang-SC-Medium, PingFang-SC;
		font-weight: bold;
		color: #333;
		width: 100%;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}
</style>
