<template>
	<view>
		<u-navbar title="充电">
			<view class="slot-wrap">
				<view class="navbar-left"></view>				
				<view class="navbar-right"><u-icon name="iconfontscan" custom-prefix="custom-icon" color="#1677ff" size="40"></u-icon></view>
			</view>
		</u-navbar>
		<view class="charge">
			<view class="chargeInfo">
				<view class="chargeInfo-row">
					<view class="u-flex"><p>桩号：</p><h4>8978789</h4></view>
					<view class="u-flex">
						<span>切换充电桩</span>
						<u-icon name="arrow-right" color="#999" size="24"></u-icon>
					</view>
				</view>
				<view class="chargeInfo-row">
					<view class="u-flex"><p>桩名：</p><h4>阿斯顿阿斯顿阿三的安舒打赏</h4></view>
					<view class="u-flex"></view>
				</view>
				<view class="chargeInfo-row">
					<view class="u-flex"><p>模式：</p><h4>0.25元(0-200W)1小时0.33元</h4></view>
					<view class="u-flex">
						<span>费用说明</span>
						<u-icon name="error-circle" color="#1677ff" size="32" @click="showTips()"></u-icon>
					</view>
				</view>
			</view>
			<view class="chargeMain">
				<template v-for="(item,i) in list">
					
					<view :key="i" class="chargeMain-item "
					@click="selectItem(item)"
					:class="{
						'active':item.id==submitForm.detailItem,
						'occupy':item.status==2,
						'fault':item.status==3,
					}"
					
					><p>{{i+1}}</p>
					<p v-if="item.status==1">空闲</p>
					<p v-else-if="item.status==2">占用</p>
					<p v-else-if="item.status==3">故障</p>
					</view>
					
				</template>
				 
			</view>
		</view>
		<view class="charge">
			<view class="chargeTime">
				
				<view v-for="(item,i) in timelist" 
					class="chargeTime-item " :key="i"
					@click="submitForm.selectTime=item.id"
					:class="{
						'chargeTime-active':submitForm.selectTime==item.id,
						
						'chargeTime-first':i==0
					}"
					>
					<template v-if="i==0">
						<p>充满</p><p>自停</p>
					</template>
						<template v-else>
							{{item.name}}
						</template>
				</view>
					
			</view>
			<view class="chargeTime-text">
				<p>充电时长</p>
				<span>{{timelist[submitForm.selectTime].name}}</span>
			</view>
		</view>
		<view class="charge">
			<view class="chargeRadio">
				<view class="u-flex">
					<u-icon name="rmb-circle-fill" color="#ff9502" size="90"></u-icon>
					<view class="chargeRadio-text">
						<p>余额支付</p>
						<p>现有余额￥4.00</p>
					</view>
				</view>
				<u-radio-group>
					<u-radio></u-radio>
				</u-radio-group>
			</view>
		</view>
		<view class="foot-btn">
			<u-button type="primary" :custom-style="customStyle" 
				@click="submit"
			shape="square">开始充电</u-button>
		</view>
		<u-modal v-model="showmodel" title="title" >
			<h1>111</h1>
			
		</u-modal>

	</view>
</template>

<script>
	import * as API_common from '@/apis/common.js'
	
	export default {
		data() {
			return {
				showmodel:false,
				//充电桩信息
				detail:{
					money:4.00,
				},
				//充电位子list
				list:[
					{
						id:'1',
						status:'1',
					},
					{
						id:'2',
						status:'2',
					},{
						id:'3',
						status:'3',
					},{
						id:'4',
						status:'1',
					},
					{
						id:'5',
						status:'1',
					},
				],
				timelist:[
					{
						id:'0',
						name:'充满自停'
					},
					{
						id:'1',
						name:'1小时'
					},
					{
						id:'2',
						name:'2小时'
					},
					{
						id:'3',
						name:'3小时'
					},
					{
						id:'4',
						name:'4小时'
					},
					{
						id:'5',
						name:'5小时'
					},
					{
						id:'6',
						name:'6小时'
					},
					{
						id:'7',
						name:'7小时'
					},
					{
						id:'8',
						name:'8小时'
					},
				],
				//提交信息
				submitForm:{
					detailNo:'',
					detailItem:'',
					selectTime:'0',
					paytype:'YE',
				},
				customStyle: {
					background: '#1677ff'
				}
			}
		},
		methods: {
			selectItem(row){
				if(row.status==1){
					this.submitForm.detailItem=row.id
				}else{
					
					uni.showToast({
						title:'当前设备不可选'
					})
				}
			},
			submit(){
				if(true){
					this.showmodel=true;
				}else{
					uni.showModal({
					    title: '订单信息',
					    content: '<h1>111</h1>',
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
				}
				
			},
			showTips(){
				uni.showModal({
				    title: '提示',
					showCancel:true,
				    content: '这是一个模态弹窗',
				    success: function (res) {
				        if (res.confirm) {
				            console.log('用户点击确定');
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			}
		}
	}
</script>
<style>
	page{
		background-color: #f7f7f7;
	}
</style>
<style lang="scss" scoped>
	.slot-wrap {
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex: 1;
	}
	.navbar-right {
		display: flex;
		margin-right: 20rpx;
		align-items: center;
	}
	.charge{
		padding: 15px;
		background-color: #fff;
		margin-bottom: 10px;
	}
	.chargeRadio{
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		.chargeRadio-text{
			margin-left: 5px;
		}
	}
	.chargeTime{
		display: flex;
		overflow: scroll;
		padding-bottom: 15px;
	
		.chargeTime-item{
			border: 1px solid #1677ff;
			border-radius: 50%;
			min-width: 56px;
			height: 56px;
			text-align: center;
			line-height: 56px;
			margin-right: 20px;
		}
		.chargeTime-first{
			line-height: 20px !important;
			
			padding-top: 6px;
			margin-right: 20px;
		}
		.chargeTime-active{
			color:#fff;
			background-color: #1677ff;
		}
	}
	.chargeTime-text{
		border-top: 1px solid #f7f7f7;
		padding-top: 15px;
		display: flex;
		align-items: center;
		span{
			margin-left: 20px;
			color:#1677ff;
		}
	}
	.chargeInfo{
		.chargeInfo-row{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-bottom: 10px;
			p{
				color:#999;
			}
			h4{
				font-weight: normal;
			}
			span{
				color:#1677ff;
				margin-right: 5px;
			}
		}
	}
	.chargeMain{
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		margin-top: 20px;
		.chargeMain-item{
			width: 18%;
			text-align: center;
			padding: 10px;
			border: 1px solid #1677ff;
			margin-bottom: 10px;
			border-radius: 10px;
			color:#1677ff;
		}
		.active{
			background-color:#1677ff;
			color:#fff;
		}
		.fault{
			background-color:#e1e1e1;
			color:#666;
			border: 1px solid #ccc;
		}
		.occupy{
			color:#FF4F3F;
			border: 1px solid #FF4F3F;
		}
	}
	.foot-btn{
		padding: 10px;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: #fff;
	}
</style>
