<template>
	<view class="container">
		<view class="news">
			<view class="list" v-if="communityList.length">
				<view class="item" v-for="item in communityList" :key="item.id" @click="toDetails(item.id)">
					<image mode="aspectFill" :src="item.noticeImage" class="icon"></image>
					<view class="con">
						<view class="name">{{item.noticeTitle}}<view class="tag" v-if="item.urgentDegree === 'urgent'">非常紧急</view>
						</view>
						<view class="time">社区服务中心 {{item.releaseTime || ''}}</view>
					</view>
				</view>
			</view>
			<no-data :show="communityList.length === 0" text="暂无数据"></no-data>
		</view>
	</view>
</template>

<script>
	import {queryNoticePageApi} from '@/config/api.js'
	import serverConfig from '@/config/server_config.js';
	import noData from '@/components/no-data/no-data'
	export default {
		components: {noData},
		data() {
			return {
				pageNo: 1,
				communityList: []
			}
		},
		methods: {
			async getList() {
				let {result} = await queryNoticePageApi({
					pageNo: this.pageNo,
					source: 'councils'
				})
				let data = result.content.map(item=> {
					return {
						...item,
						noticeImage: serverConfig.baseURL + '/sys/common/static/' + item.noticeImg
					}
				})
				if(this.pageNo === 1) {
					this.communityList = data
				} else {
					this.communityList = this.communityList.concat(data)
				}
			},
			toDetails(id) {
				uni.navigateTo({
					url: `/pages/announcementDetails/index?id=${id}`
				});
			}
		},
		onShow() {
			this.getList()
		}
	}
</script>
<style>
	page {
		background-color: #F8F6F9;
	}
</style>
<style lang="scss" scoped>
	.page {
		padding: 30rpx 0 0;
	}

	.news {
		background-color: #ffffff;
		border-radius: 16rpx;

		.list {
			background-color: #F8F6F9;
			padding: 30rpx;

			.item {
				background-color: #ffffff;
				border-radius: 16rpx;
				display: flex;
				padding: 30rpx;
				margin-bottom: 30rpx;
				box-shadow: 0 0 25rpx 0 rgba(81,89,234,0.06);
				position: relative;
				&::after {
					content: " ";
					position: absolute;
					top: 30rpx;
					right: 30rpx;
					width: 14rpx;
					height: 14rpx;
					border-radius: 50%;
					z-index: 11;
				}
				&.noRead::after {
					background-color: #F6C864;;
				}

				.icon {
					flex: none;
					width: 186rpx;
					height: 140rpx;
					border-radius: 6rpx;
				}

				.con {
					margin-left: 30rpx;
					padding-right: 10rpx;

					.name {
						font-size: 30rpx;
						color: #373737;
						overflow : hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-line-clamp: 3;
						-webkit-box-orient: vertical;
						word-break: break-all; /* 追加这一行代码 */

						.tag {
							font-size: 22rpx;
							color: #F42E2E;
							border: 1px solid #F42E2E;
							padding: 4rpx 10rpx;
							border-radius: 30rpx;
							display: inline-block;
							margin-left: 20rpx;
						}
					}

					.time {
						font-size: 24rpx;
						color: #B6B6BA;
						height: 30rpx;
						line-height: 30rpx;
						margin-top: 30rpx;
					}

				}
			}
		}


	}
</style>