<template>
	<view class="bg">
		
		<view class="title">请输入车牌号码</view>
		<view style="font-weight: 500;font-size: 25rpx;color: #333333;padding:20rpx 25rpx 0;">车牌信息仅用于进出停车场，我们会严格保护您的信息</view>
		<input class="arm-input" v-model="carNo">
		<view class="btn" @click="confirmCarNo">确定</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				carNo: '',
				park_code: '',
				arm_code: '',
				gate_type: '',
			}
		},
		onLoad(options){
			this.park_code = options.park_code
			this.arm_code = options.arm_code
		},
		onShow() {
			if (!this.gate_type) {
				this.getCarNo()
			}
			
		},
		methods: {
			getCarNo () {
				this.Post({
					park_code: this.park_code,
					arm_code: this.arm_code
				},'/api/parking/getArmPassInfo').then(res => {
					if (res && res.data && res.data.gate_type) {
						this.carNo = res.data.vpl
						this.gate_type = res.data.gate_type
					}
				})
			},
			confirmCarNo () {
				if (this.carNo && this.carNo.trim()) {
						// 进站 读过协议 直接抬干
						if (this.gate_type == 'in') {
							this.Post({park_code:this.park_code},'/api/parking/isAgree').then(res => {
								if (res.data.is_agree) {
									this.Post({
										park_code: this.park_code,
										arm_code: this.arm_code,
										agree_status: 1,
									}, "/api/parking/raiseCar").then(res=>{
											uni.showToast({
												title: res.msg
											})
									})
								} else {
									uni.navigateTo({
										url: `/subPackages/service/gate?park_code=${this.park_code}&arm_code=${this.arm_code}&carNo=${this.carNo}&gate_type=${this.gate_type}`
									})
								}
							})
						} else {
							uni.navigateTo({
								url: `/subPackages/service/gate?park_code=${this.park_code}&arm_code=${this.arm_code}&carNo=${this.carNo}&gate_type=${this.gate_type}`
							})
						}
				} else {
					uni.showToast({
						title: '请输入车牌号',
						icon: 'none'
					})
				}
			},
		}
	}
</script>

<style lang="scss">
	.bg{
		height: 100vh;
		background: linear-gradient(180deg, #E0F4E4, #F7F7F7);
	}
	.title{
		padding: 120rpx 25rpx 0;
		font-weight: bold;
		font-size: 40rpx;
		color: #333333;
	}
	.arm-input{
		width: 697rpx;
		font-weight: 500;
		font-size: 35rpx;
		color: #000000;
		height: 100rpx;
		background: white;
		margin: 50rpx auto;
		padding: 0 20rpx;
		box-sizing: border-box;
	}
	.btn{
		width: 697rpx;
		height: 73rpx;
		background: linear-gradient(270deg, #9EE4FE, #7FD491);
		border-radius: 37rpx;
		margin: 0 auto;
		line-height: 73rpx;
		text-align: center;
		font-weight: 500;
		font-size: 35rpx;
		color: #000000;
	}
</style>
