<template>
	<view class="container">
		<view v-if="news.length > 0">
		<!-- @click="details(item)" -->
			<view class="details"  v-for="(item,i) in news" :key="i" >
				<view class="detail_header">
					<text class="blueSign"></text>
					<text class="font-tilte">【{{item.type}}】</text>
					<!-- <text :class="item.status1 == 11 ? 'statusgr':'statusred'">{{item.status1}}</text> -->
				</view>
				<view class="detail_msg">
					<view class="info-content">
						<text class="infoSpan">{{item.content}}</text>
					</view>
					<view class="info-item">
						<text class="infoSpan">{{item.creator}}</text>
					</view>
					<view class="info-item-time">
						<text class="infoSpan">{{item.gmtCreated}}</text>
					</view>
				</view>
			</view>
		</view>
		
		<content-none v-else :padTop="32"></content-none>
		<load-more :loadingType="loadingType" :contentText="contentText"></load-more>
	</view>
</template>

<script>
	import {
		queryNewsInfo,
	} from '@/common/api.js';
	import {
		callbackRequest,
		getStorage,
		alertTip,
		formatDate
	} from '@/common/util.js';
	import loadMore from '@/components/loadMore.vue';
	import contentNone from '@/components/contentNone.vue';
	export default {
		components: {
			loadMore,
			contentNone
		},
		data() {
			return {
				formatDate:formatDate,
				//分页
				page: 1,
				pageSize: 10,
				loadingType: 0, //0-loading前；1-loading中；2-没有更多了
				contentText: {
					contentdown: "上拉加载更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多数据了"
				},
				userInfo:getStorage("userInfo"),
				news: [],
				fixList: [{
						title: "信息资讯",
						more: ""
					},
					{
						title: "通知通告",
						more: ""
					},
					{
						title: "服务指南",
						more: ""
					},
					{
						title: "物业维护公告",
						more: ""
					},
					{
						title: "温馨提示",
						more: ""
					},
				],
			}
		},
		onShow() {
			this.page = 1;
			this.loadData();
		},
		methods: {
			details: function(item) {
				uni.navigateTo({
					url: 'hqfb-details?item=' + encodeURIComponent(JSON.stringify(item)),
				})
			},
			loadData() {
				let cur = this;
				let params = {
					"method": queryNewsInfo,
					"data": {
						userId: this.userInfo.id,
						pageNum: this.page,
						pageSize: this.pageSize
					}
				};
				callbackRequest(params).then(res => {
					res = res.data;
					console.log(res);
					if (res.returnCode == "1") {
						if (cur.page == 1) {
							cur.news = res.returnData || [];
						} else {
							if (res.returnData.length > 0) {
								cur.news = cur.news.concat(res.returnData);
								// console.log(cur.repair);
								this.loadingType = 0;
							} else {
								this.loadingType = 2;
							}
						}
					}
				})
			}
		},
		onReachBottom() {
			if (this.loadingType !== 0) {
				return;
			}
			this.loadingType = 1;
			this.page = this.page + 1;
			this.loadData();
		},
	}
</script>

<style lang="scss">
	@import '@/static/css/common.scss';
	.con {
		float: right;
		width: 88%;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
	}
	.nolist {
		font-size: 30upx;
		color: #797979;
		text-align: center;
		padding-top: 20upx;
	}

	.container {
		min-height: 100vh;
		background: #f8f8f8;
		font-size: 28upx;

		.details {
			// height: 400upx;
			background: white;
			margin: 15upx;
			border-radius: 15upx;

			.detail_header {
				border-bottom: #f8f8f8 5upx solid;
				height: 90upx;
				line-height: 90upx;
				margin: 15upx;
				border-radius: 10upx;

				.blueSign {
					height: 28upx;
					width: 5upx;
					background: #00c277;
					display: inline-block;
					margin-left: 20upx;
					vertical-align: middle;
				}

				.font-tilte {
					font-weight: bold;
					margin-left: 20upx;
					vertical-align: middle;
				}
			}

			.statusgr {
				float: right;
				margin-right: 30upx;
				color: #00c277;
			}

			.statusred {
				float: right;
				margin-right: 30upx;
				color: red;
			}

			.detail_msg {
				margin-left: 20upx;
				border-radius: 10upx;
				padding-right: 20upx;
				view {
					line-height: 60upx;
				}
				.info-content{
					text-indent:2em;
				}
				.info-item{
					height: 60upx;
					.infoSpan{
						float: right;
						padding-right: 10%;
					}
				}
				.info-item-time{
					height: 60upx;
					.infoSpan{
						float: right;
						padding-right: 20upx;
					}
				}
			}
		}
	}
</style>
