<template>
	<view class="carbox">
		<view class="flex1 cartop">
			<box-list :datainfo="list" type="mycar"></box-list>
			<view class="cartips flexc mt16 mb16" @click="getChargeFn">
				<view class="tit flex1">当前有车辆<text class="co025">充电中…</text></view>
				<image :src="rimg"></image>
			</view>
		</view>
		<view class="plr12 flex0">
			<view class="rhbtn" @click="getAddFn">添加车辆</view>
		</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{
				rimg: require('@/mine/static/house/rimg.png'),
				list:[{tit:'123',type:1},{tit:'123',type:2},],
				pageSize: 10,
				pageNum: 1,
				reachflag: true,
				wtdt:'',
			}
		},
		onLoad: function() {
		
		},
		// 上拉触底加载更多触发事件
		onReachBottom() {
			if (this.reachflag) {
				this.pageNum++
				this.getDataFn()
			}
		},
		methods:{
			checkPermi, checkRole,
			getAddFn(){
				this.$tab.navigateTo("/mine/pages/car/addcar")
			},
			getChargeFn(){
				this.$tab.navigateTo("/mine/pages/car/charge")
			},
			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>
.carbox{display: flex;flex-direction: column;min-height: 100vh;padding: 22rpx 18rpx 100rpx;
	.cartop{overflow: auto;}
	.cartips{background: #FFFFFF;border-radius: 20rpx;height: 98rpx;padding: 0 24rpx;
		image{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;}
		.tit{font-weight: bold;font-size: 26rpx;color: #272727;}
	}
}
</style>