<template>
	<view class="container">
<!-- 		<view class="search-box">
			<u-search
				v-model="searchForm.keyword"
				:clearabled="true"
				bg-color="#E5E5E5"
				:input-style="searchInputStyle"
				placeholder="请输入搜索内容"
			></u-search>
		</view> -->
		<view class="list-box">
			<view class="list-item-box" v-for="item in list" :key="item.id" @click="onNoticeClick(item)">
				<view class="main-box">
					<view class="icon-box">
						<view class="iconfont icon-a-tongzhigonggao"></view>
						<!-- <cover-image class="icon" :src="`${FILE_URL}/notice/icon-2.jpg`"></cover-image> -->
					</view>
					<view class="content-box">
						<view class="title">
							{{item.title}}
						</view>
						<!-- <view class="text">
							{{item.desc}}
						</view> -->
					</view>
					<view class="other-box">
						<view class="date">
							{{item.date}}
						</view>
					</view>
				</view>
				<view class="line-box"></view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'
	import { getNoticeList } from '@/api/notice.js'
	import configService from '@/utils/baseurl.js'
	const FILE_URL = configService.FILE_URL;
	const uToast = ref()
	
	const searchInputStyle = {
		backgroundColor: '#E5E5E5'
	}
	const searchForm = ref({
		keyword: ''
	})
	const list = ref([
		{
			id: '1',
			title: '2023年度团队建设活动',
			desc: '为了增强团队凝聚力，定于10月30日举行年度团队建设活动。请全员准时参加，期待大家的积极参与！',
			date: '2024-10-20'
		},
		{
			id: '2',
			title: "新员工入职培训",
			date: "2024-10-18",
			desc: "欢迎新加入的同事们！我们将于10月25日举办入职培训，届时会介绍公司的文化及各部门职能。"
		},
		{
			id: '3',
			title: "系统维护通知",
			date: "2023-10-15",
			desc: "为提升系统性能，我们将在10月22日进行系统维护，期间系统可能无法访问，请提前做好相关准备。"
		},
		{
			id: '4',
			title: "年度业绩总结会议",
			date: "2023-11-01",
			desc: "请各部门准备年度业绩总结报告，并按时参加11月10日的总结会议，共同探讨未来发展计划。"
		},
		{
			id: '5',
			title: "义务植树活动",
			date: "2023-10-12",
			desc: "我们将在10月28日组织义务植树活动，希望大家积极报名参加，一起为环境保护贡献一份力量。"
		}
	])
	function init() {
		getNoticeList().then(res=>{
			if(res?.data){
				list.value = res.data
			}
		})
	}
	function onNoticeClick(notice) {
		uni.navigateTo({
			url: `/pages/notice/noticeDetail/noticeDetail?id=${notice.id}&title=${notice.title}`
		})
	}
	onLoad(()=>{
		init();
	})
</script>

<style lang="scss" scoped>
	.container {
		// height: 100vh;
		width: 100vw;
		background-color: #FFFFFF;
		padding: 0 20rpx env(safe-area-inset-bottom, 0);
		
		.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;
						}
						.iconfont{
							font-size: 60rpx;
							color: #0069f6;
						}
					}
					.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>
