<template>
	<view>
		<u-navbar  :title="title" :is-back="0" ></u-navbar>
		<view class="main">
			<view class="list">
				<view class="line"  v-for="(item,i) in list" :key="i"
				  @click="gotoUrl('/pages/deviceTab/deviceList?parkingId='+item.id)" >
					<view class="body">
						<view class="imgclass">
							<image class="img" src="@/assets/img/deviceTab/index1-1.svg" mode=""></image>
						</view>
						<view class="item">
							<view class="name">
								{{item.name}}
							</view>
							<view class="value"  >
								<!-- 占用{{item.useNum}}<span>/</span>
								空闲{{item.idleNum}}<span>/</span>
								错误{{item.errorNum}}<span>/</span>
								共{{item.lockNum}}台 -->
								<span>{{item.contacts}}</span>
								<span>{{item.openStatusN}}</span>
							</view>
						</view>
					</view>
					<view class="goto">
						<u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon>
					</view>
				</view>
				
				
				
			</view>
		</view>
		<u-divider  :isnone="list.length==0" nonetext="没有找到相关内容" border-color="#CFD2D5">已经到底了</u-divider>
		
		<tabbar :current="1"></tabbar>
	</view>
</template>

<script>
	import * as API from '@/apis/pagejs/deviceTab.js'
	
	import Tabbar from '@/components/Tabbar.vue'
	export default {
		components: {
			Tabbar
		},
		data() {
			return {
				title:"场站列表",
				list:[],
				listForm:{
					pageIndex: 1,
					pageSize: 20,
					recordsTotal: 1,
				},
			};
		},
		onLoad() {
			this.getList()
		},
		onReachBottom() {
			if (this.list.length < this.listForm.recordsTotal) {
				this.myLoadmore();
			}
		},
		methods: {
			
			myLoadmore(){
				this.listForm.pageIndex += 1;
				this.getList()
			},
			getList() {
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
							 
				API.parkingList(this.listForm).then((res) => {
					
					var list=this.list 
					
					if (this.listForm.pageIndex == 1) {
						list = res.data.parkingInfoList;
					} else {
						list = [
							...list,
							...res.data.parkingInfoList
						];
					}
					this.list=list
					uni.hideLoading();
				
				}).catch(error => {
				
					uni.hideLoading();
					uni.showToast({
						title: error,
						icon: "none"
					})
				})
			},
			
		}
	}
</script>

<style scoped lang="scss">
	.main{
		background-color: #fff;
		.line{
			    display: flex;
			    justify-content: space-between;
				    align-items: center;
					padding: 32rpx;
					border-bottom: 1px solid rgba(245,245,245,1);
					
				.body{
					 display: flex;
					     align-items: center;
						 
						 .imgclass{
						 							     display: flex;
						 							     align-items: center;
						 							     justify-content: center;
						 							width: 72rpx;
						 							height: 72rpx;
						 							     border-radius: 4px;
						 							     background-color: rgba(219,234,255,1);
						 }
						 .item{
						 							    margin-left: 16rpx;
						 								
						 								 .name{
						 									 color: rgba(51,51,51,1);
						 									 font-size: 28rpx;
						 								 }
						 								 .value{
						 								 	color: rgba(119,119,119,1);
						 								 	font-size: 24rpx;
						 											 span{
						 												  margin-right: 16rpx;
						 											 }
						 								 }
						 }
						
				}
		}
		.img{
			width: 48rpx;
			height: 48rpx;
		}
	}
</style>
