<template>
	<view >
		<ujp-navbar title="适用站点"></ujp-navbar>
	
		<view class="carNone" v-if="list.length == 0">
			<img src="@/assets/static/img/暂无数据-缺省页.png" alt="">
			<p class="oldTextjp2" oldstyle="font-size: 18px;">加载中</p>
		</view>
		
		<view class="charing-slow" v-for="(item,index) in list" 
		@click="gotoUrl('pages/searchPile/stationAndPile/stationDetails?id='+item.id)"
		
		:key="item.id" >
	
 <text class="trickle-charge" v-if="item.type == '1'" :style="elderStatus ? 'font-size: 14px;background-color: #9D9FFF;' : 'background-color: #9D9FFF;'">快充</text>
 <text class="trickle-charge" v-if="item.type == '2'" :style="elderStatus ? 'font-size: 14px;background-color: #00B962;' : 'background-color: #00B962;'">慢充</text>
 <text class="trickle-charge" v-if="item.type == '1,2'" :style="elderStatus ? 'font-size: 14px;background-color: #00BAC8;' : 'background-color: #00BAC8;'">快/慢</text>
 
 
 <text class="station-items oldTextjp" oldstyle="font-size: 20px;">{{item.name}}</text>
			
			<view class="address oldTextjp2" oldstyle="font-size: 14px;">
				{{item.address}}
			</view>
			<view class="price">
				<view class="num">{{item.costPrice.toFixed(2)}}</view>
				<view class="unit oldTextjp2" oldstyle="font-size: 16px;">
					 元/度 起
				</view>
			</view>
		<!-- 	<view class="park">
				<text class="park-p">p</text>
				<text class="park-text">以实际费用为准</text>
			</view> -->
			<view class="free">
				<view class="free-num oldTextjp2" oldstyle="font-size: 18px;">
					<text style="color:#009143;">空闲{{item.availableNum}}</text>/总数{{item.totalNum}}
				</view>
				<!-- <view class="distance">
					<text class="iconfont distance-font">&#xe615;</text>
				</view> -->
			</view>
		</view>
		<u-divider  v-if="list.length == recordsTotal && recordsTotal != 0" style="margin-top: 10px;background-color: #F2F4F4;">已经到底了</u-divider>
		
		
<!-- 		<u-divider margin-top="20" bg-color="#F2F4F4">已经到底了</u-divider>
 -->	</view>
</template>

<script>
	import * as API from '@/apis/site.js';
	
	export default {
		data() {
			return {
				tabbarList: [{
						iconPath: "home-3-line",
						selectedIconPath: "home-3-fill",
						text: '主页 ',
						count: 0,
						isDot: true,
						customIcon: true,
					},
					{
						iconPath: "road-map-line",
						selectedIconPath: "road-map-fill",
						text: '找桩',
						midButton: true,
						customIcon: true,
					},
					{
						iconPath: "user-5-line",
						selectedIconPath: "user-5-fill",
						text: '我的',
						count: 0,
						isDot: false,
						customIcon: true,

					}
				],
				current: 0,
				monthlyRentCardId:null,
				
				pageIndex: 1,
				recordsTotal: 0,
				list: [],
				elderStatus: false,
			}
		},onLoad(op){
			this.monthlyRentCardId=op.cardId
			this.getInfo()
		},
		onReachBottom() {
			if (this.chargeList.length < this.recordsTotal) {			
				this.myLoadmore();
			}
		},
		onReady() {
			if(this.carhelp.get("getElderModeClass") == "长辈模式") {
				this.elderStatus = true;
			} else {
				this.elderStatus = false;
			}
		},
		methods: {
			myLoadmore() {
				this.pageIndex += 1;
				this.getInfo()
			},
			getInfo(){
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				var data={
					monthlyRentCardId:this.monthlyRentCardId,
					online:0
				}
				if (this.carhelp.getPersonInfo()) {
						data.openId=this.carhelp.getOpenId()
				}
				
				API.getChargingStationData(data).then((response) => {
					console.log(response)
					this.list = [
						...this.list,
						...response.data.data
					];
					this.recordsTotal = response.data.recordsTotal;
					//this.detail=response.data.monthlyRentCard
					uni.hideLoading()
				}).catch(error => {
					uni.showToast({
						title: error
					})
				})
			}
		}
		
	}
</script>

<style lang="scss" scoped>
	.carNone{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		img{
			width: 100%;
			height: 100%;
		}
		p{
			margin-top: -60px;
		}
	}

	.top-box {
		width: 100%;
		height: 88px;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 999;
	}
	
	.top {
		display: flex;
		justify-content: space-between;
		width: 100%;
		height: 44px;
		color: #666666;
		background-color: rgba(255, 255, 255, 100);
		padding: 12px 16px;
	
	
		.u-search[data-v-1a326067] {
			flex: 0.9;
		}
	
		.list {
			margin-left: 2px;
	
		}
	}
	
	.condition {
		width: 100%;
		height: 44px;
		line-height: 20px;
		padding: 12px 16px;
		display: flex;
	
		background-color: #fff;
	
		.condition-type {
			margin-left: 36px;
		}
	
		.condition-screen {
			margin-left: 159px;
		}
	}
	

	
	.charing-slow {
		background-color: #fff;
		margin: 0 12px;
		border-radius: 8px;
		padding: 10px 12px 0px;
		margin-top: 12px;
		.trickle-charge {
			display: inline-block;
			width: 44px;
			height: 20px;
			line-height: 20px;
			border-radius: 50px;
			background-color: rgba(0, 185, 98, 100);
			color: rgba(255, 255, 255, 100);
			font-size: 12px;
			text-align: center;
		}

		.fast-charge {
			display: inline-block;
			width: 44px;
			height: 20px;
			line-height: 20px;
			border-radius: 50px;
			background-color: #9d9fff;
			color: rgba(255, 255, 255, 100);
			font-size: 12px;
			text-align: center;
		}
		.fast-slow{
			display: inline-block;
			width: 44px;
			height: 20px;
			line-height: 20px;
			border-radius: 50px;
			background-color: #00bac8;
			color: rgba(255, 255, 255, 100);
			font-size: 12px;
			text-align: center;
		}

		.station-items {
			display: inline-block;
			height: 16px;
			line-height: 16px;
			font-size: 16px;
			margin-left: 4px;
			color: #101010;


		}

		.address {
			margin-top: 8px;
			line-height: 16px;
			font-size: 11px;
			color: rgba(119, 119, 119, 100);
		}

		.price {
			display: flex;
			height: 20px;
			margin-top: 8px;

			.num {
				height: 20px;
				color: rgba(255, 98, 0, 100);
				font-size: 20px;
				text-align: left;
				font-family: Roboto-medium;
			}

			.unit {
				height: 14px;
				line-height: 14px;
				color: rgba(102, 102, 102, 100);
				font-size: 14px;
				text-align: left;
				font-family: AlibabaPuHui-regular;
				margin-top: 6px;
				margin-left: 4px;
			}
		}

		.park {
			margin-top: 10px;
			display: flex;

			.park-p {
				display: inline-block;
				width: 20px;
				height: 18px;
				line-height: 12px;
				text-align: center;
				background-color: rgba(125, 177, 255, 100);
				color: #fff;
			}

			.park-text {
				display: inline-block;
				width: 300px;
				height: 17px;
				color: rgba(102, 102, 102, 100);
				font-size: 12px;
				text-align: left;
				margin-left: 4px;
				margin-top: 2px;
			}
		}

		.free {
			display: flex;
			justify-content: space-between;
			height: 52px;
			border-top: 1px solid rgba(238, 242, 240, 100);
			margin-top: 10px;

			.free-num {
				line-height: 52px;
				font-size: 14px
			}

			.distance {
				width: 130px;
				height: 28px;
				line-height: 28px;
				color: rgba(255, 255, 255, 100);
				font-size: 14px;
				background-color: #00b962;
				border-radius: 50px;
				margin: 12px;
				text-align: center;

				.distance-font {
					font-size: 16px
				}

			}
		}
	}
</style>
