<template>
	<view class="conten">
		<block v-if="list.length > 0">
			<navigator class="list-item" v-for="(item, index) in list" :key="index" :url="'./noticeDetails?id=' + item.article_id">
				<view class="item-title">{{item.title}}</view>
				<view class="item-time"><text>{{item.categories[0].title}}</text>{{item.created_at}}</view>
				<uni-icons class="item-icon" type="forward" color="#ddd" size="20"></uni-icons>
			</navigator>
		</block>
		<block v-else>
			<view class="list-empty">
				<u-empty
					mode="data"
					icon="http://cdn.uviewui.com/uview/empty/data.png"
					text="暂无公告信息"
				>
				</u-empty>
			</view>
		</block>
	</view>
</template>

<script>
	import { list } from '@/apis/interfaces/notice.js'
	export default {
		data() {
			return {
				list: [],
				page: {}
			};
		},
		created() {
			list().then(res => {
				this.list = res.data
				this.page = res.page
			}).catch(err => {
				uni.showToast({
					title: res.message,
					icon : 'none'
				})
			})
		}
	}
</script>

<style lang="scss">
	.list-empty{
		height: 80vh;
		@extend .vertical;
	}
	.conten{
		min-height: 100vh;
		background: #F3F6FB;
		padding-top: 30rpx;
		box-sizing: border-box;
		.list-item{
			position: relative;
			margin: 0 30rpx 30rpx 30rpx;
			background: white;
			border-radius: 20rpx;
			padding: 30rpx 60rpx 30rpx 30rpx;
			.item-icon{
				position: absolute;
				right: 30rpx;
				top: 50%;
				margin-top: -10px;
			}
			.item-title{
				padding-bottom: 10rpx;
				font-size: 34rpx;
				font-weight: bold;
				color: #333;
				@extend .nowrap;
			}
			.item-time{
				font-size: 26rpx;
				color: gray;
				text{
					color: $main-color;
					margin-right: 20rpx;
				}
			}
		}
	}
</style>
