<template>
	<view class="container">
		<uni-list border-full v-for="(item,index) in noticeList" :key="index">
			<uni-list-item showArrow clickable :title="item.title"
				:note="item.createTime" :thumb="item.img" thumb-size="lg" @click="targetToDetail(item.id)"/>
		</uni-list>
	</view>
</template>

<script>
	import {
		getNoticeList
	} from '@/api/userInfo.js'
	export default {
		data() {
			return {
				noticeList: [],
				pageSize: 10,
				pageNum: 1
			}
		},
		// 下拉刷新
		onPullDownRefresh() {
			uni.stopPullDownRefresh()
		},
		created() {
			const params = {
				pageSize: this.pageSize,
				pageNum: this.pageNum,
			}
			this.getNoticeList(params);
		},
		methods: {
			
			// 获取公告分页
			async getNoticeList(params) {
				const res = await getNoticeList(params)
				console.log('res', res)
				if (res.data.code === 200) {
					this.noticeList = res.data.rows
					console.log('noticeList', this.noticeList) 
				} else {
					uni.showModal({
						content: '公告列表加载失败！',
						showCancel: false
					});
				}
			},
			
			targetToDetail(id) {
				console.log('id', id)
				if (id) {
					uni.navigateTo({
						url: 'noticeDetail?id=' + id
					})
				}
			}
		},
	}
</script>

<style lang="scss">
</style>
