<template>
	<view class="car">
		<view class="cartop">
			<!-- <view class="toptit">
				<image :src="djtop"></image>本社区党员共<text>367</text>人
			</view> -->
			<view class="tabtop flexc">
				<view class="tabt" :class="tabval==ite.val?'act':''" v-for="(ite,idx) in tablist" :key="idx" @click="getTabFn(ite.val)">{{ite.tit}}</view>
			</view>
		</view>
		<!-- 列表 -->
		<view class="carlists">
			<box-list :datainfo="list" :wtdt="wtdt" type='delivery' @getDetail="getDetail"></box-list>
		</view>
		<loading></loading>
	</view>
</template>

<script>
	import config from '@/config'
	const baseUrl = config.baseUrl
	import boxList from "@/mine/components/box/list.vue"
	import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
	export default{
		components:{boxList},
		data(){
			return{
				cxrq:"",
				text:'',
				list:[{tit:'皖A IC520',type:1,right:0},{tit:'晋E KD783',type:2,right:0},],
				pageSize: 10,
				pageNum: 1,
				reachflag: true,
				wtdt:'',
				tabval:'0',
				tablist:[{tit:'在途快递',val:0},{tit:'最近签收',val:1}]
			}
		},
		onLoad: function() {
		
		},
		// 上拉触底加载更多触发事件
		onReachBottom() {
			if (this.reachflag) {
				this.pageNum++
				this.getDataFn()
			}
		},
		methods:{
			checkPermi, checkRole,
			getDetail(){
				this.$tab.navigateTo("/mine/pages/delivery/detail")
			},
			getTabFn(val){
				this.tabval=val
			},
			getrefreshData(){
				this.pageNum=1;
				this.list=[];
				this.reachflag=true;
				this.getDataFn()
			},
			bindDateChangea(e){
				var val=e.detail.value;
				this.cxrq=val;
			},
			getDataFn(){
				var params={
					pageSize:this.pageSize,
					pageNum: this.pageNum,
				}
				params.noticeType=this.tabidx
				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 = '到底了~';
							}
						}
						var newArr=JSON.parse(JSON.stringify(res.rows))
						newArr.forEach(ite=>{
							ite.right=0;
						})
						// console.log(newArr,555)
						if (this.pageNum == 1) {
							this.list = newArr;
						} else {
							this.list = this.list.concat(newArr)
						}
					}else{
						this.$toast(res.msg)
					}
				})
				
			},
		}
	}
</script>
<style>
	page{background: #F3F3F0;}
</style>
<style lang="scss" scoped>
.car{padding: 134rpx 0 10rpx;}
.cartop{position: fixed;left: 0;right: 0;top: 0;background-color: #ffffff;z-index: 2;
	.toptit{display: flex;justify-content: center;font-weight: 500;font-size: 26rpx;color: #8592AA;height: 70rpx;align-items: center;
background: #E4EDFF;
		text{font-size: 32rpx;color: #0156FE;padding: 0 10rpx;}
		image{width: 28rpx;height: 26rpx;flex: 0 0 auto;margin-right: 12rpx;}
	}
	.tabtop{padding-bottom: 40rpx;padding-top: 14rpx;
		.tabt{font-weight: 500;font-size: 32rpx;color: #666666;position: relative;line-height: 56rpx;padding: 0 40rpx;
			&.act{font-weight: bold;font-size: 32rpx;color: #272727;
			&::after{content: '';width: 40rpx;height: 10rpx;background: #0156FE;border-radius: 6rpx;position: absolute;left: 50%;margin-left: -20rpx;bottom: -10rpx;}
			}
		}
	}
}
.carlists{padding: 0 18rpx;}
</style>