<template>
	<view class="container">
		<cc-pullScroolView class="pullScrollView" ref="pullScroll" :pullDown="pullDown" :isDownLoading="true">
			<view class="notice" v-for="(item,index) in list" :key="index">
				<view class="justify-content" @click="goDetails(item)">
					<view class="font-forty">
						{{item.noticeTitle}}
					</view>
					<view class="font-twenty-eight gray">
						{{item.createTime}}
					</view>
				</view>


			</view>
		</cc-pullScroolView>
		<!-- 

		<view v-if="isLoadMore">
			<uni-load-more :status="loadStatus"></uni-load-more>
		</view>
	</view>
	</view> -->
	</view>
</template>

<script>
	// import {
	// 	onPullDownRefresh
	// } from '@dcloudio/uni-app' // 下拉刷新
	import CCBProjectList from '../../uni_modules/cc-pullScroolView/components/cc-pullScroolView/cc-pullScroolView.vue';
	import {
		getNoticeList,
	} from '@/api/common'


	export default {
		components: {

			CCBProjectList,

		},
		data() {
			return {
				list: [],
				pageSize: 10, // 条数
				totalNum: '',
				pageNum: 1, // 页数
			}
		},
		onLoad() {

			this.getList()

		},


		// 上拉加载
		onReachBottom() {
			// 数据全部加载完

			if (this.pageNum * 10 >= this.totalNum) {

			} else {
				// 显示加载中
				this.$refs.pullScroll.showUpLoading();
				this.pageNum++;
				this.requestData();
			}

		},
		methods: {
			goDetails(item) {
				uni.navigateTo({
					url: '/pages/notice/noticeDetail?params=' + encodeURIComponent(JSON.stringify(
						item))
				})
			},

			// 下拉刷新
			pullDown(pullScroll) {

				this.pageNum = 1;
				setTimeout(() => {
					this.requestData(pullScroll);
				}, 1000);

			},
			getList() {
				let myThis = this;
				this.$nextTick(() => {

					myThis.$refs.pullScroll.refresh();

				});
			},
			requestData() {

				uni.showLoading()
				getNoticeList('1', this.pageNum, this.pageSize).then(res => {

					this.totalNum = res.total

					if (res.code == '200') {
						uni.hideLoading()
						if (res.rows.length !== 0) {
							//首次加载10条数据，后进行拼接
							if (this.pageNum == 1) {
								this.list = [];
								this.list = res.rows
							} else {
								this.list = this.list.concat(res.rows)
							}

							// 如果是最后一页
							if (this.pageNum * 10 >= this.totalNum) {
								this.$refs.pullScroll.finish();

							} else {

								// 不是最后一页
								this.$refs.pullScroll.success();
							}

						} else {
							this.$modal.msg("暂无数据")
						}
					} else {
						this.$modal.msg(res.msg + "")
					}

				})

			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		display: flex;
		margin-left: 10px;
		margin-top: 10px;
		margin-right: 10px;
		align-items: flex-start;
		justify-content: space-between;
	}

	.notice {
		margin: 20rpx;
		width: 100%;
		padding: 20rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 8rpx 17rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 10rpx;
	}

	.text {
		border-left: 15rpx solid #3857F3;
		padding-left: 20rpx;
	}
</style>