<template>
	<view class="car" :style="'padding-top:'+patop+'px;'">
		<view class="cartop">
			<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 class="tips">车位总计<text class="co01">365个</text>，当前空闲地下车位<text class="cofe">27个</text>，地面车位<text class="co28">18个</text></view>
			<view class="tablst flexc">
				<view class="tabs" :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">
			<car-list :datainfo="list" :wtdt="wtdt" type='carku'></car-list>
		</view>
		<loading></loading>
	</view>
</template>

<script>
	import config from '@/config'
	const baseUrl = config.baseUrl
	import carList from "@/car/components/car/list.vue"
	import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
	export default{
		components:{carList},
		data(){
			return{
				reset:require('@/car/static/car/reset.png'),
				up:require('@/car/static/car/up.png'),
				car:require('@/car/static/car/car.png'),
				cara:require('@/car/static/car/cara.png'),
				carb:require('@/car/static/car/carb.png'),
				search:require('@/car/static/car/search.png'),
				list:[{tit:'皖A IC520',type:1}],
				pageSize: 10,
				pageNum: 1,
				reachflag: true,
				wtdt:'',
				tabval:'tcw',
				tabval:'0',
				patop:'144',
				tablist:[{tit:'停车位',val:'tcw'},{tit:'充电桩位',val:'cdz'}],
				tablist:[{tit:'地下车位',val:0},{tit:'地面车位',val:1}]
			}
		},
		onLoad: function() {
		},
		mounted() {
			var that=this;
			setTimeout(function(){
				that.getHeightFn()
			},200)
		},
		// 上拉触底加载更多触发事件
		onReachBottom() {
			if (this.reachflag) {
				this.pageNum++
				this.getDataFn()
			}
		},
		methods:{
			checkPermi, checkRole,
			getHeightFn(){
				let query = uni.createSelectorQuery().in(this);
				var that=this;
				//需要给黄色区域设置一个id标识，在这里是demo
				query.select('.cartop').boundingClientRect(data => {
					var height=data.height;
					that.patop=Number(height)
				}).exec();
			},
			getTabFn(val){
				this.tabval=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 = '到底了~';
							}
						}
						if (this.pageNum == 1) {
							this.list = res.rows;
						} else {
							this.list = this.list.concat(res.rows)
						}
					}else{
						this.$toast(res.msg)
					}
				})
				
			},
		}
	}
</script>
<style>
	page{background: #F3F3F0;}
</style>
<style lang="scss" scoped>
.car{}
.cartop{position: fixed;left: 0;right: 0;top: 0;background-color: #ffffff;z-index: 2;
	.tabtop{padding-bottom: 44rpx;padding-top: 40rpx;
		.tabt{font-weight: 500;font-size: 32rpx;color: #666666;position: relative;line-height: 60rpx;padding: 0 40rpx;margin-right: 6rpx;
			&.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;}
			}
		}
	}
	.tips{font-weight: 500;font-size: 24rpx;color: #666666;
		padding: 0 36rpx 16rpx;
	}
	.tablst{background: #F3F3F0;padding:24rpx 14rpx 24rpx 46rpx;overflow: auto;
		.tabs{height: 48rpx;background: #DADADA;border-radius: 24rpx;margin-right: 34rpx;font-weight: 500;display: flex;align-items: center;justify-content: center;padding: 0 24rpx;
font-size: 26rpx;box-sizing: border-box;flex: 0 0 auto;color: #666666;
			&.act{border: 2rpx solid #0256FD;background: #FFFFFF;color: #0256FD;}
		}
	}
}
.carlists{padding: 0 18rpx;}
</style>