<style>
	.koraNewsList{
		display: flex;
		width:100%;
		padding:10px;
		border-bottom: 1px solid #F4F4F4;
		flex:1;
	}
	.newsLeft{
		width:153px;
		height:115px;
		flex-shrink:0;
		border-radius: 3px;
		overflow: hidden;
	}
	.newsLeft img{
		width:100%;
		height:100%;
	}
	.koranewRight{
		position: relative;
		width:100%;
		margin-left:12px;
	}
	.koraDate{
		position: absolute;
		color:#B9B9B9;
		bottom:0;
		font-size:12px;
	}
	.koraRName{
		color:#404040;
		font-size:14px;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 3;
		overflow: hidden;
	}
	.koraNewsSearch {
		display: flex;
		margin: 10px 10px 0 10px;
		width: 100%;
		justify-content: space-between;
	}
</style>
<template>
	<view class="koraNews">
		<view class="koraNewsSearch">
			<u-search action-text="搜索" :focus="true" :clearabled="true" style="width:95%" :show-action="true" radius="40" v-model="msg.Title"
			 @search="getList(1)" @custom="getList(1)"></u-search>
		</view>
		<u-empty v-if="dataList.length==0" text="暂无数据" mode="data"></u-empty>
		<scroll-view v-else :scroll-y="true" :enable-back-to-top="true" :enable-flex="true"
		 @scrolltolower="lower" :style="{ 'height': `calc(100%)`}">
			<view>
				<view class="koraNewsList" v-for="(item,index) in dataList" :key="index" @click="goNewsDetail(item)">
					<view class="newsLeft">
						<img :src="item.CoverImg" alt=""/>
					</view>
					<view class="koranewRight">
						<view class="koraRName">{{item.Title}}</view>
						<view class="koraDate">{{item.PublishTimeStr}}</view>
					</view>
				</view>
			</view>
			<view style="padding:10px 0;">
				<u-loadmore :status="status" :load-text="loadText" :font-size="24" :margin-top="0" :margin-bottom="0" />
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageTitle: "新闻",
				msg:{
					pageIndex: 1,
					pageSize: 10,
					Title:'',
					Type:1
				},
				pageCount: 1,
				dataList:[],
				loadText: {
					loadmore: "轻轻上拉，加载更多",
					loading: "努力加载中",
					nomore: "没有更多了",
				},
				status:'',
			}
		},
		mounted(){
			uni.setNavigationBarTitle({
				title: this.pageTitle,
			});
			this.getList(1);
		},
		methods: {
			//获取数据
			getList(num) {
				if (num == 1) {
					this.dataList = [];
				}
				uni.showLoading({
					title: '加载中'
				});
				this.request2({
						url: "/api/AppletTrade/GetNewsPage",
						data: this.msg,
					},
					(res) => {
						uni.hideLoading();
						if (res.resultCode == 1) {
							this.dataList = this.dataList.concat(res.data.pageData);
							this.pageCount = res.data.pageCount;
						}
					}
				);
			},
			//滚动加载
			lower(e) {
				if (this.msg.pageIndex < this.pageCount) {
					this.msg.pageIndex++;
					this.status = "loading";
					this.getList();
				} else {
					this.status = "nomore";
				}
			},
			//跳转至新闻详情
			goNewsDetail(item){
				uni.navigateTo({
					url: '/pages/kotra/newsInDetail?Id=' + item.Id
				});
			}
		}
	}
</script>
