<template>
	<view class="container">
		<view class="list-box">
			<view class="list-item-box" v-for="item in list" :key="item.id" @click="onDynamicClick(item)">
				<view class="main-box">
					<view class="icon-box">
						<cover-image class="icon" :src="`/static/notice/22.png`"></cover-image>
					</view>
					<view class="content-box">
						<view class="title">
							{{item.title}}
						</view>
						<view class="text">
							{{item.content}}
						</view>
					</view>
					<view class="other-box">
						<view class="date">
							{{item.time}}
						</view>
					</view>
				</view>
				<view class="line-box"></view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'
	
	const uToast = ref()
	
	const searchInputStyle = {
		backgroundColor: '#E5E5E5'
	}
	const searchForm = ref({
		keyword: ''
	})
	const list = ref([
		  {
		    "id": "1",
		    "title": "参观科技博览会",
		    "content": "20名协会成员于10月15日参加了全国科技博览会，收获颇丰。此次活动增进了大家对科技前沿的认识。",
		    "time": "2023-10-16"
		  },
		  {
		    "id": "2",
		    "title": "举办文化交流活动",
		    "content": "我们于10月22日成功举行了文化交流活动，各个文化团体分享了他们的传统和故事，气氛热烈。",
		    "time": "2023-10-23"
		  },
		  {
		    "id": "3",
		    "title": "秋季运动会开幕",
		    "content": "10月29日上午，协会在体育场举办了秋季运动会，吸引了众多会员参与，为大家提供了锻炼身体的机会。",
		    "time": "2023-10-30"
		  },
		  {
		    "id": "4",
		    "title": "爱心捐赠活动",
		    "content": "协会发起的爱心捐赠活动于11月1日正式启动，希望大家积极参与，共同为需要帮助的人贡献一份力量。",
		    "time": "2023-11-01"
		  },
		  {
		    "id": "5",
		    "title": "庆祝协会成立周年",
		    "content": "我们将于12月5日庆祝协会成立五周年，届时会举办庆祝晚会，欢迎所有成员莅临共庆佳节！",
		    "time": "2023-11-02"
		  }

	])
	function onDynamicClick(dynamic) {
		uni.navigateTo({
			url: `/pages/dynamic/dynamicDetail/dynamicDetail?id=${dynamic.id}&title=${dynamic.title}`
		})
	}
</script>

<style lang="scss" scoped>
	.container {
		height: 100vh;
		width: 100vw;
		background-color: $uni-bg-color;
		padding: 0 20rpx;
		
		.search-box {
			margin-bottom: 20rpx;
			::v-deep(.u-search) {
				background-color: #e5e5e5;
				border-radius: 50rpx;
				
				.u-action {
					width: 18%;
					background-color: $uni-color-primary;
					border-radius: 50rpx;
					color: $uni-text-color-inverse;
					margin-right: 8rpx;
					font-size: 28rpx;
					line-height: 50rpx;
					letter-spacing: 3rpx;
					text-align: center;
				}
			}
		}
	
		.list-box {
			padding: 0 20rpx;
			.list-item-box {
				.main-box {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 30rpx 0;
					
					&:active {
						background-color: $uni-bg-color-hover;
					}
					.icon-box {
						width: 15%;
						display: flex;
						justify-content: center;
						align-items: center;
						.icon {
							width: 70rpx;
							height: 70rpx;
						}
					}
					.content-box {
						width: 67%;
						display: flex;
						flex-direction: column;
						justify-content: space-around;
						gap: 10rpx;
						.title {
							height: calc(70% - 5rpx);
							font-size: $uni-title-font-size-2;
							font-weight: bold;
						}
						.text {
							height: calc(30% - 5rpx);
							font-size: $uni-font-size-3;
							color: $uni-text-color-grey;
							@include text-overflow();
						}
					}
					.other-box {
						width: 18%;
						display: flex;
						flex-direction: column;
						justify-content: space-around;
						align-items: center;
						gap: 10rpx;
						.date {
							font-size: $uni-font-size-3;
							color: $uni-text-color-grey;
						}
						.tag {
							font-size: $uni-font-size-3;
							width: 42rpx;
							background-color: $uni-color-error;
							color: $uni-text-color-inverse;
							border-radius: 20rpx;
							text-align: center;
						}
					}
				}
				.line-box {
					height: 1rpx;
					width: 80%;
					background-color: #E5E5E5;
					margin: 0 auto;
				}
			}
		}
	}
		
	
</style>
