<template>
	<view class="top">
		<text class="iconfont icon-youjiantou zuojiantou" @click="goBack()"></text>
		<text>公告列表</text>
	</view>
	<view class="container">
		<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.navigateBack({
					delta:1
				})
			}
		}
	}
	
</script>

<style lang="scss">
	.top{
		display: flex;
		height: 80rpx;
		justify-content: space-between;
		align-items: center;
		position: relative;
		width: 100%;
		margin: 0 auto;
		background: #fff;
		.zuojiantou{
			display: inline-block;
			transform: rotate(180deg);
			font-size: 30rpx;
			z-index: 1;
			position: absolute;
			top: 30rpx;
			left: 20rpx;
		}
		text:nth-child(2){
			width: 100%;
			text-align: center;
			position: absolute;
		}
	}
	.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>