<template>
	<view>
		<!-- <view class="taking-pictures" @click="getPic">点击拍照</view> -->
		<view class="wrap">
			<view class="new-plate-number">
				<view class="message-input-wrap" @click="messageInputClick">
					<u-message-input :maxlength="8" width="70" font-size="50" :disabled-keyboard="true" v-model="newPlateNumber"></u-message-input>
				</view>				
				<u-keyboard ref="uKeyboard" mode="car" @change="keyboardChange" @backspace="backspace" v-model="keyboardshow"></u-keyboard>
			</view>
			<view class="f-padding">
				<u-button class="btn" type="primary" @click="submit">确认</u-button>
				<view class="tip">
					通过输入车牌号查询车主的停车记录
				</view>
			</view>
		</view>
		
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	//#ifdef APP-PLUS
	let ocr = uni.requireNativePlugin("OcrPlug");
	//#endif
	export default{
		data(){
			return{
				keyboardshow:false,
				newPlateNumber:'',
				spaceId:'',
				vehicleClor:''
			}
		},
		onLoad(page){
			this.spaceId = page.spaceId;
			
		},
		methods:{
			getPic(){
				let that = this;
				ocr.ocrVehicleNo((ret) => {
					if (ret.success){
						that.confirmData.vehicleNo = ret.vehicleNo;
						//that.vehicleImage =  'data:image/png;base64,' + ret.imageBase64;
						// speak('成功识别车牌' + ret.vehicleNo);
					}else {
						plus.nativeUI.toast('识别失败');
					}
				});	
			},
			messageInputClick(){
				this.keyboardshow = true;
			},
			// 按键被点击(点击退格键不会触发此事件)
			keyboardChange(val) {
				// 将每次按键的值拼接到value变量中，注意+=写法
				this.newPlateNumber += val;
				console.log(this.newPlateNumber);
			},
			// 退格键被点击
			backspace() {
				// 删除value的最后一个字符
				if(this.newPlateNumber.length) this.newPlateNumber = this.newPlateNumber.substr(0, this.newPlateNumber.length - 1);
				console.log(this.newPlateNumber);
			},
			submit(){
				this.$u.route({
					url: 'pages/ownersQuery/queryList/queryList',
					params: {
						vehicleNo: this.newPlateNumber
					}
				});
				return
				let param ={
					spaceId:this.spaceId,
					vehicleNo:this.newPlateNumber,
					
				};
				this.$u.api.entrance(param)
				.then(res=>{
					this.$refs.uToast.show({
						title: res.msg,
						type: 'success',
						url:'pages/getout/getout'
					});
					console.log('entrance',res)
				}).catch(err=>{
					this.$refs.uToast.show({
						title: err.msg,
						type: 'error',
						url:'pages/parking/parking'
					});
					console.log('entrance ',err)
				});
			}
			
		}
	}
</script>

<style lang="scss">
	@import "./ownersQuery.scss";
</style>
