<template>
	<view class="mesg">
		<view v-if="noticelist.length">
			<uni-card spacing='0' padding='34rpx' margin='24rpx' shadow='0px 0px 0px 0px rgba(0, 0, 0, 0.08)' v-for="(ite,idx) in noticelist" :key="idx">
				<template v-slot:title>
					<view class="mestop">
						<view class="cirmes flex0" :class="noticeType==1?'co1':'co2'"></view>
						<!-- <view class="f15 fw c34 flex1">{{noticeType==1?'系统通知':'待办通知'}}</view> -->
						<view class="f15 fw c34 flex1">{{noticeType==1?'系统通知':'待办通知'}}</view>
						<view class="f15 c500 fa flex0">{{ite.createTime}}</view>
					</view>
				</template>
				<view class="uni-body f15">
					<view>{{ite.noticeTitle}}</view>
					<view>{{ite.noticeContent}} </view>
					<view class="mt6">祝您生活愉快！</view>
				</view>
			</uni-card>
			<view class="shax">{{wtdt}}</view>
		</view>
		<block v-else>
			<no-data ></no-data>
		</block>
	</view>
</template>

<script>
	import {getNoticelist} from "@/api/work/index.js"
	import noData from "@/components/nodata/nodata.vue"
	export default{
		data(){
			return{
				extra:'2023-02-21 18:32',
				pageSize: 10,
				pageNum: 1,
				reachflag:true,
				noticelist:[],
				wtdt:'',
				deptId:this.$store.state.user.deptId,
			}
		},
		components:{noData},
		onLoad() {
			this.getDataFn()
		},
		onReachBottom() {
			if (this.reachflag) {
				this.pageNum++
				this.getDataFn()
			}
		},
		methods:{
			getDataFn(){
				var params={
					pageSize:this.pageSize,
					pageNum: this.pageNum
				}
				getNoticelist(params).then(res=>{
					if(res.code==200){
						if (res.rows.length < this.pageSize) {
							this.reachflag = false
							this.wtdt = '到底了~';
						} else {
							var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -	1)
							if (num < res.total) {
								this.reachflag = true
								this.wtdt = '上拉加载更多'
							} else {
								this.reachflag = false
								this.wtdt = '到底了~';
							}
						}
						if (this.pageNum == 1) {
							this.noticelist = res.rows;
						} else {
							this.noticelist = this.noticelist.concat(res.rows)
						}
					}else{
						this.$toast(res.msg)
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
.mesg{padding: 4rpx 0 4rpx;}
.mestop{display: flex;align-items: center;border-bottom: 2rpx solid #E5E5E5;min-height: 88rpx;padding: 0 34rpx;}
.cirmes{
	width: 20rpx;height: 20rpx;border-radius: 10rpx;margin-right: 20rpx;
&.co1{background: #1FB9F7;}
&.co2{background:#FA5F03;}

}
</style>