<template>
	<view>
		<u-navbar
		 title="车主信息" 
		 title-color="#fff" 
		 :custom-back="customBack" 
		 :border-bottom="false" 
		 back-icon-color="#CCE8FF" 
		 :background="{background: 'linear-gradient(145deg, #41AFF9 0%, #2D8CFB 100%)' }"></u-navbar>
		 
		 <!-- <u-empty class="u-m-t-50" text="很棒!没有欠费订单!" mode="list" v-if="listEmpty"></u-empty> -->
		 <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" >
		 <view class="owelist">
		 	<view class="owelist-item" v-for="(item,index) in owelist" :key="item.id">
		 		<view class="item-header u-flex u-row-between">
		 			<view class="vehicle-no">{{item.vehicleNo}}</view>
					<view class="space-name">{{item.spaceName}}</view>
		 		</view>
				<view class="road-name u-flex">
					<u-icon name="map-fill" color="#3397FA" size="36"></u-icon>
					{{item.roadName}}
				</view>
				<view class="info-item">进场时间：{{item.inTime}}</view>
				<view class="info-item">出场时间：{{item.outTime}}</view>
				<view class="info-item">停车时长：{{item.duration}}</view>
				<view class="info-item">收费员：{{item.payeeName}}</view>
				<view class="info-item">支付金额：<span class="amount">{{item.payAmount}}元</span></view>
				<view class="info-item">订单状态：{{item.orderStatus|filterOrderStatus}}</view>
		 	</view>
		 </view>
		 </mescroll-body>
		 <u-toast ref="uToast" />
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default{
		mixins: [MescrollMixin], // 使用mixin
		data(){
			return{
				vehicleNo:'',
				listEmpty:false,
				owelist:[],
				pagination:Object.assign({}, {pageNo: 1,pageSize: 10}),
			}
		},
		onLoad(page){
			this.vehicleNo = page.vehicleNo;
			console.log('this.vehicleNo',this.vehicleNo)
		},
		onShow(){
			// this.owelist = [];
		},
		onReachBottom() {
			// this.getData();
		},
		methods:{
			customBack(){
				this.$u.route({
					// type:'switchTab',
					url: 'pages/index/index'
				});
			},
			downCallback(){
				this.mescroll.resetUpScroll();
			},
			upCallback(page){
				console.log('upCallback ',page);
				let pageNum = page.num; // 页码, 默认从1开始
				let pageSize = page.size; // 页长, 默认每页10条
				this.$u.api.vehicleList({vehicleNo:this.vehicleNo,pageNum:pageNum,pageSize:pageSize})
				.then(res=>{
					// uni.hideLoading();
					// this.$refs.uToast.show({
					// 	title: res.msg,
					// 	type: 'success',
					// });
					//设置列表数据
					let curPageData = res.data.rows; 
					// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
					let curPageLen = curPageData.length; 
					let totalPage = res.data.pages; 
					
					if(page.num == 1) this.owelist = []; //如果是第一页需手动置空列表
					this.owelist = this.owelist.concat(curPageData); //追加新数据
					
					// 请求成功,隐藏加载状态
					//后台接口有返回列表的总页数 totalPage
					this.mescroll.endByPage(curPageLen, totalPage);
					
					this.leaveDetail = res.data;
					for (let item of res.data.rows) {
						this.owelist.push(item)
					}
					if(this.owelist.length<=0){this.listEmpty = true};
				
					console.log('vehicleList',res)
				}).catch(err=>{
					// uni.hideLoading();
					this.$refs.uToast.show({
						title: err.msg,
						type: 'error',
					});
					console.log('vehicleList ',err)
				});
				
			}
			
		}
	}
</script>

<style lang="scss">
	@import  './ownersinfo.scss'
</style>
