<template>
	<view class="mynews">
		<ul>
			<li v-for="(item, index) of newsArr" @click="isSHow(item.id)">
				<div :class="item.read == 0 ? 'active' : ''"></div>
				<div class="mid">
					<span>消息通知</span>
					<span>{{ item.ctime  }}</span>
					<span v-if="item.read == 0" class="biaoji" @click="isSHow(item.id)">标记已读</span>
					<span v-else class="biaoji_">&nbsp;&nbsp;&nbsp;&nbsp;</span>
				</div>
				<p @click="go(item)" style="line-height: 44rpx;">{{ item.title }}</p>
			</li>
		</ul>
		<u-empty margin-top="60" style="height: 0% !important;width: 100vw;" v-if="newsArr.length==0" text="暂无更多数据" mode="list"></u-empty>
	</view>
</template>

<script>
import mineApi from '@/api/mine/index.js';
export default {
	data() {
		return {
			primary:this.$theme.primary,
			newsArr: [],
			p: 1,
			name: '',
			settingFile:getApp().globalData.siteinfo
		};
	},
	onPullDownRefresh() {
		this.newsArr = [];
		this.p = 1;
		this.getMsg();
		setTimeout(() => {
			uni.stopPullDownRefresh();
		}, 600);
	},
	mounted() {
		this.getMsg(); //进入页面默认请求数据
	},
	methods: {
		go(e) {
			console.log(e)
			this.$u.route('pagesE/pages/mynews/news/news', {
				e: JSON.stringify(e)
			});
		},
		isSHow(id) {
			let that = this;
			let data = {
				id: id
			};
			mineApi.msgRead(data).then(res => {
				
				var showC = that.newsArr.filter(item => item.id == id);
				showC[0].read = 1;
			});
		},
		getMsg() {
			let that = this;
			let id = uni.getStorageSync('userInfo').id;
			let data = {
				id: id,
				p: this.p,
				pagesize: 10
			};
			mineApi.newsList(data).then(res => {
				that.newsArr = that.newsArr.concat(res.data);

			});
		}
	},
	onReachBottom() {
		this.p++;
		this.getMsg();
	}
};
</script>

<style lang="scss">
page {
	height: 100%;
	background: #f1f1f1;
}
.mynews {
	width: 100%;
	background: #f1f1f1;
	padding: 0rpx 0px 50rpx 0;
	position: relative;

	ul {
		width: calc(100% - 34rpx);

		margin: 0 auto;
	}

	li .mid {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 30rpx;
		color: #333;
		height: 50rpx;
		padding-bottom: 10rpx;
		border-bottom: 2rpx solid #f2f2f2;
	}

	li > div > span:last-child {
		font-size: 26rpx;
		color: #999;
	}

	li {
		box-sizing: border-box;
		padding: 20rpx;
		background: #fff;
		border-radius: 8px;
		margin-top: 20rpx;
	}

	li > p {
		font-size: 28rpx;
		color: #666;
		margin-top: 16rpx;
	}

	.active {
		background: #ff435b !important;
	}

	li > div:first-child {
		width: 12rpx;
		height: 12rpx;
		border-radius: 50%;
		background: #fff;
	}

	li .mid .biaoji {
		color: #ff8870;
		font-size: 22rpx;
		width: 120rpx;
	}

	li .mid .biaoji_ {
		width: 120rpx;
	}

	footer {
		display: none;
	}
	.no-data {
		width: 160rpx;
		height: 160rpx;
		position: fixed;
		top: 35%;
		left: 50%;
		margin-left: -80rpx;
		image {
			width: 100%;
			height: 100%;
		}
	}
}
</style>
