<template>
	<view>
			<view class='notice-wrap' v-for='item in noticeList'>
				<view class="flex justify-space-between">
					<view style='width:100px;margin:10rpx 0;' class='flex justify-space-between'>
						<u--image :showLoading="true" src="/static/image/enter/news.png" width="52rpx" height="52rpx"></u--image>
						<view>{{item.newsTitle}}</view>
					</view>
					
					<view class='date'>{{parseTime(item.gmtCreate)}}</view>
				</view>
				<view class='content'>{{item.newsContent}}</view>
			</view>
		<!-- </mescroll-body> -->
		<u-toast ref="uToast"></u-toast>
		<u-tabbar
			:value="tabbarCheck"
			@change="tabbarChange"
			activeColor="#5F7DE9"
		>
			<u-tabbar-item name="team" text="加入">
				<image
					class="u-page__item__slot-icon"
					slot="active-icon"
					src="@/static/image/nav-icon/antOutline-team Copy.png"
				></image>
				<image
					class="u-page__item__slot-icon"
					slot="inactive-icon"
					src="@/static/image/nav-icon/antOutline-team.png"
				></image>
			</u-tabbar-item>
			<u-tabbar-item name="notification" text="通知">
				<image
					class="u-page__item__slot-icon"
					slot="active-icon"
					src="@/static/image/nav-icon/md-notifications_none Copy.png"
				></image>
				<image
					class="u-page__item__slot-icon"
					slot="inactive-icon"
					src="@/static/image/nav-icon/md-notifications_none.png"
				></image>
			</u-tabbar-item>
			<u-tabbar-item name="user" text="我的">
				<image
					class="u-page__item__slot-icon"
					slot="active-icon"
					src="@/static/image/nav-icon/antOutline-user1 Copy.png"
				></image>
				<image
					class="u-page__item__slot-icon"
					slot="inactive-icon"
					src="@/static/image/nav-icon/antOutline-user1.png"
				></image>
			</u-tabbar-item>
		</u-tabbar>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				tabbarCheck:'notification',
				noticeList:[],
				unreadList:[]
			};
		},
		onShow() {
			this.getList()
		},
		
		methods:{
			tabbarChange(e){
				console.log(e)
				if(e=='team'){
					uni.navigateTo({
						url:'/pageA/enter/enter'
					})
				}else if(e=='user'){
					uni.navigateTo({
						url:'/pageA/my/my'
					})
				}
				// name => tabbarCheck = name
			},
			getList(){
				var that = this
				uni.showLoading({
						title: '数据加载中'
					})
				this.$request.baseRequest('admin.tourism.noticeMessageInfo', 'list',{
					receiveId:uni.getStorageSync("userInfo").id,
				}, failres => {
					uni.showToast({
						icon:"none",
						title: failres.errmsg,
						duration: 3000
					});
					uni.hideLoading()
				}).then(res => {
					let curPageLen = res.data.items.length;
					let totalPage = res.data.total;
					this.noticeList=res.data.items
					if(this.noticeList.length>0){
						var data=this.noticeList.filter((item)=>{return item.newsFlag==0})
						this.unreadList=data
						if(this.unreadList.length>0){
							for(var i=0;i<this.unreadList.length;i++){
								if(this.unreadList[i].newsFlag==0){
									this.unreadList[i].newsFlag=1
									this.$request.baseRequest('admin.tourism.noticeMessageInfo', 'update',{
										noticeMessageInfo:JSON.stringify(this.unreadList[i]),
									}, failres => {
										uni.showToast({
											icon:"none",
											title: failres.errmsg,
											duration: 3000
										});
										uni.hideLoading()
									}).then(res => {})
								}
								
							}
							
						}
					}
					
					uni.hideLoading()
				})
			},
		}
		
	}
</script>

<style lang="scss" scoped>
.notice-wrap{
	background:#fff;
	padding:20rpx;
	margin:10rpx;
	border-radius:20rpx;
}
.date{
	color:#CCCCCC;
}
.content{
	font-size:26rpx;
	color:#666;
}
</style>