<template>
	<view class="box">
		<view class="title">选择车型</view>
		<view class="cont">
			<view class="line" @click="goCarModel">
				<view class="lineTxt">手动选择车型</view>
				<view class="lineRgiht">
					<view class="lineRtxt">请选择</view>
					<image src="../../static/img2/jt1.png" mode="" class="jtIcon"></image>
				</view>
			</view>
			<view class="line" @click="scVinIMg">
				<view class="lineTxt">扫描VIN码</view>
				<view class="lineRgiht">
					<image src="../../static/img2/sm.png" mode="" class="smIcon"></image>
				</view>
			</view>
		</view>
		
		
	</view>
</template>

<script>
	
	export default {
		components: {
			
		},
		data() {
			return {
				
			}
		},
		onLoad(opt) {
           
		},
		onShow() {
			
		},
		methods: {
			goCarModel(){
				uni.redirectTo({
					url:'../user/addCar/carModel'
				})
			},
			scVinIMg(){
				var that = this;
				uni.chooseImage({
					sourceType: ['album','camera'],
					count:1, 
					success: (chooseImageRes) => {
						const tempFilePaths = chooseImageRes.tempFilePaths;
						that.file=tempFilePaths[0]
						 uni.uploadFile({
					            url: that.$request.baseUrl+'accompany/SuperCheckSheet/uploadFile', //仅为示例，非真实的接口地址
					            filePath: tempFilePaths[0],
					            name: 'file',
					            formData: {
					                'user': 'test'
					            },
					            success: (uploadFileRes) => {
					                console.log(JSON.parse(uploadFileRes.data).data );
									//that.imgArr=that.imgArr.concat(JSON.parse(uploadFileRes.data).data) ;
									that.vinImg=JSON.parse(uploadFileRes.data).data[0];
									that.vinScanner()
					            }
					        });
				
						/* that.$http('accompany/SuperCheckSheet/uploadFile', tempFilePaths[0], 'POST').then(res => {
							
						}) */
					}
				});
			},
			vinScanner(){
				uni.showLoading({
					title:'正在识别中'
				});
				/* 
				this.$http('miniAppMyBMemberCar/vinScanner', {
				  photo:this.file,
				
				 },'POST').then(res => {
					uni.hideLoading();
					//this.carGroupList=res.data.carGroupList
				}) */
				var that=this;
				uni.uploadFile({
				       url: that.$request.baseUrl+'miniAppMyBMemberCar/vinScanner', 
				       filePath: that.file,
				       name: 'photo',
				       formData: {
				           'user': 'test'
				       },
				       success: (uploadFileRes) => {
						   uni.hideLoading();
				           console.log(JSON.parse(uploadFileRes.data) );
						   if(JSON.parse(uploadFileRes.data).code==0){
							   	that.vin = JSON.parse(uploadFileRes.data).data;
								that.queryCarModelGroupByVin()
						   }else{
							   uni.showToast({
							   	title: JSON.parse(uploadFileRes.data).msg,
							   	icon: 'none',
							   	duration: 2000,
							   });
						   }
						   	
				       }
				   });
			},
			queryCarModelGroupByVin(){
				uni.showLoading({ });
				this.$http('miniAppMyBMemberCar/queryCarModelGroupByVin', {
				  vin:this.vin,
				
				 },'GET').then(res => {
					uni.hideLoading();
					if(res.code!=0){
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000,
						});
					}else{
						/* this.vinboxtwoShow=true
						this.vinSbList=res.data;
						this.vincarModelInfo=this.vinSbList[0] */
					}
					
				})
				
			},
		

		},
		
	}
</script>

<style scoped>
	.box {
		min-height: 100vh;
		background: #F4F5F7;
	}
.title{
	font-weight: 400;
	font-size: 22rpx;
	color: #000000;
	padding-top: 40rpx;
	padding-left: 24rpx;
	padding-bottom: 28rpx;
}
.cont{
	padding: 0 24rpx;
}
.line{
	background: #FFFFFF;
	border-radius: 10rpx;
	padding: 30rpx;
	line-height: 40rpx;
	margin-bottom: 20rpx;
	display: flex;justify-content: space-between;
}
.lineTxt{
	font-weight: 500;
	font-size: 28rpx;
	color: #000000;
	line-height: 40rpx;
}
.lineRtxt{
	font-weight: 400;line-height: 40rpx;
	font-size: 22rpx;
	color: #646464;
	padding-right: 10rpx;
}
.jtIcon{
	width: 10rpx;height: 20rpx;margin-top: 10rpx;
}
.smIcon{
  width: 36rpx;height: 36rpx;margin-top: 2rpx;	
}
.lineRgiht{
	display: flex;
}
</style>
