<template>
	<view class="container">
		<view class="top">
			<view class="iconfont icon-youjiantou" @click="goBack()">
			</view>
			<view style="width: 55%;text-align: left;">
				公告列表
			</view>
			<!-- <view class="clear">
				<text class="iconfont icon-weibiaoti544"></text>
				<text>清除未读</text>	
			</view> -->
		</view>
		<view class="content">
			<view class="announcement_wrapper" v-for="(item,index) in announcementLists" :key="index">
				<text class="iconfont icon-zizhutuiguang"></text>
				<view class="announcement_content">
					<view class="announcement_title">
						<text class="title">{{matchReg(item.title).substring(0,8)}}...</text> 
						<text class="date">{{item.announcementAt}}</text>
						<!-- <text class="readed dot"></text>s -->
					</view>
					<view class="announcement_des">
						{{matchReg(item.content).substring(0,15)}}...
						<!-- <rich-text :nodes="item.content"></rich-text> -->
					</view>
				</view>
				<view class="to_detail" @click="goToDetail(item.id)">
					<view>查看详情</view>
					<view class="iconfont icon-youjiantou"></view>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	import api from '../../api/api';
	export default{
		data(){
			return{
				announcementLists:[],
			}
		},
		onLoad(){
			this.announcementQuery()
		},
		methods:{
			announcementQuery() {
			   api.announcementQuery({announcementTypeId:686}).then(res => {
			     if (res['success']) {
			       this.announcementLists = res['data']['announcementInfoList'];
			     }
			   });
			},
			matchReg(str){
			    let reg=/<\/?.+?\/?>/g;
			    return str.replace(reg,'');
			},
			goToDetail(id){
				uni.navigateTo({
					url:`../announcement/announcement_detail?id=${id}`
				})
			},
			goBack(){
				uni.navigateTo({
					url:'../index/index'
				})
			}
		}
	}
	
</script>

<style lang="scss">
	.top{
		display: flex;
		height: 100rpx;
		justify-content: space-between;
		align-items: center;
		position: relative;
		background: #fff;
		padding-right: 20rpx;
		.icon-youjiantou{
			display: inline-block;
			transform: rotate(180deg);
			font-size: 30rpx;
			width: 50rpx;
			height: 50rpx;
			z-index: 1;
		}
		.clear{
			display: flex;
			align-items: center;
			.icon-weibiaoti544{
				color: #5359cd;
				font-size: 50rpx;
			}
			text:nth-child(2){
				color: #999999;
				font-size: 20rpx;
			}
		}
		
	}
	.content{
		padding: 20rpx;
		.announcement_wrapper{
			display: flex;
			margin-bottom: 20rpx;
			background: #fff;
			align-items: center;
			flex-wrap: wrap;
			padding: 20rpx 10rpx;
			.icon-zizhutuiguang{
				color: #5359cd;
				background: #eff3ff;
				font-size: 40rpx;
				width: 70rpx;
				height:70rpx ;
				line-height: 70rpx;
				text-align: center;
				border-radius: 50%;
				margin-right: 30rpx;
			}
			.announcement_content{
				width:85%;
				.announcement_title{
					display: flex;
					justify-content: space-between;
					margin-bottom: 20rpx;
					padding-top: 20rpx;
					.title{
						font-size: 40rpx;
					}
					.date{
						color: #999999;
						font-size: 28rpx;
					}
					.readed{
						width: 20rpx;
						height: 20rpx;
						border-radius: 50%;
						background: #EF6C40;
					}
				}
				.announcement_des{
					margin: 20rpx 0;
					color: #666666;
					font-size: 32rpx;
				}
			}
			.to_detail{
				display: flex;
				align-items: center;
				justify-content: space-between;
				color: #666666;
				font-size: 20rpx;
				margin-left: 100rpx;
				width: 100%;
				padding: 20rpx 0;
				border-top: 2rpx #F2F2F2 solid;
			}
		}
		
	}
</style>