<template>
	<view class="content">
	  <homenav :iStatusBarHeight="iStatusBarHeight" :title="'选择保养项目'"></homenav>
	  <view class="box">
		  <view class="historyLine" >
			  <view class="historyLogoBox">
			  	<image :src="optdata.logo" mode="" class="historylinecarImg"></image>
			  </view>
			  <view>
			  	<view class="historylinecar">{{optdata.value}}</view>
			  	<view class="historyLineVin" v-if="optdata.isVin==1">
			  		<view class="vinms">VIN</view>
			  		<view class="vinNum">{{optdata.vin}}</view>
			  	</view>
			  </view>
			
		  </view>
		 
	  </view>
	  
	  <view class="title">机油推荐</view>
	  
	  <view class="lineBox flex">
	  	<view class="line" @click="goEngineOil">
			<view class="lineTitle">机油</view>
			<view class="lineEnglish">Engine Oil</view>
			<view class="lineImgbox">
				<image src="../../static/img/icon_jiyou.png" mode="" class="lineImg1"></image>
			</view>
		</view>
		<view class="line" @click="goGearboxOil">
			<view class="lineTitle">变速箱油</view>
			<view class="lineEnglish">Gearbox Oil</view>
			<view class="lineImgbox">
				<image src="../../static/img/icon_biansuxiang.png" mode="" class="lineImg2"></image>
			</view>
		</view>
	  </view>
	  <view class="lineBox flex" style="margin-top: 20rpx;">
	  	<view class="line" @click="godifferential">
	  			<view class="lineTitle">分动箱差速器</view>
	  			<view class="lineEnglish">Transfer case differential </view>
	  			<view class="lineImgbox">
	  				<image src="../../static/img/icon_jiyou.png" mode="" class="lineImg1"></image>
	  			</view>
	  		</view>
	  		
	  </view>
	   <!-- <picker-view v-if="visible" :indicator-style="indicatorStyle"  @change="bindChange" class="picker-view">
		  <picker-view-column>
			  <view class="item" v-for="(item,index) in engineList" :key="index">{{item.engineModel}}</view>
		  </picker-view-column>
		  
	  </picker-view> -->
	  <uni-popup ref="popup" type="bottom" background-color="#fff">
		  <view class="popupTitle">请选择发动机</view>
		  <view style="popupLineBox">
			   <view @click="ckengin(item)" class="popupLine" v-for="(item,index) in engineList">{{item.engineModel}}</view>
			 
		  </view>
	  
	  </uni-popup>
	</view>
</template>

<script>
	import homenav from "../../components/homenav/nav.vue"
	export default {
		components: {
			homenav
		},
		data() {
			return {
				optdata:'',
				isVin:'',
				vin:'',
				scarid:'',
				iStatusBarHeight:'',
				engineList:'',
				visible:false,
				indicatorStyle: `height: 50px;`
			}
		},
		onLoad(opt) {
		   console.log(opt);
		   this.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight;
           this.optdata=opt;
		   if(opt.scarid){
			   this.scarid=opt.scarid;
			   this.queryCarModelGroupInfo()
		   }else{
			   if(opt.isVin==1){
				   this.isVin=1;
				   this.vin=opt.vin
			   }
			   		 
			   this.saveQueryHistory()
		   }
		   this.queryEnginemodel()
		   
		},
		methods: {
			bindChange(){
				
			},
		   queryEnginemodel(){
			   this.$http('matchingByOpen/queryEnginemodel', {
			     ids:this.optdata.id,
			    
			    },'POST').then(res => {
			   		this.engineList=res.data
			   })
		   },
		   queryCarModelGroupInfo(){
			   uni.showLoading({ title: '加载中'});
			   this.$http('matchingByOpen/queryCarModelGroupInfo', {
			     id:this.scarid,
			    
			    },'POST').then(res => {
					uni.hideLoading();
			   		var data={
						value:res.data.value,
						id:res.data.id,
						nLevelID:res.data.carModelInfo.nLevelID,
						logo:res.data.carModelInfo.logo,
					}
					 this.optdata=data;
			   		this.saveQueryHistory()
			   })
		   },
		   saveQueryHistory(){
			   this.$http2('saveQueryHistory', {
			     nLevelID:this.optdata.nLevelID,
				 logo:this.optdata.logo,
				 title:this.optdata.value,
				 groupId:this.optdata.id,
				 isVin:this.isVin,
				 vin:this.vin
			    },'POST').then(res => {
			   				
			   		
			   })
		   },
		   ckengin(item){
			   console.log(item)
			   uni.navigateTo({
			   	url:'/pages/index/engineOil?nLevelID='+this.optdata.nLevelID+'&logo='+this.optdata.logo+'&value='+this.optdata.value+'&id='+item.ids+'&isVin='+this.optdata.isVin+'&vin='+this.optdata.vin
			   })
		   },
           goEngineOil(){
			   if(this.engineList.length>1){
				  this.$refs.popup.open()
			   }else{
				   uni.navigateTo({
				   	url:'/pages/index/engineOil?nLevelID='+this.optdata.nLevelID+'&logo='+this.optdata.logo+'&value='+this.optdata.value+'&id='+this.optdata.id+'&isVin='+this.optdata.isVin+'&vin='+this.optdata.vin
				   })
			   }
			   
		   },
		   goGearboxOil(){
			   uni.navigateTo({
			   	url:'/pages/index/gearboxOil?nLevelID='+this.optdata.nLevelID+'&logo='+this.optdata.logo+'&value='+this.optdata.value+'&id='+this.optdata.id+'&isVin='+this.optdata.isVin+'&vin='+this.optdata.vin
			   })
		   },
		   godifferential(){
			   uni.navigateTo({
			   	url:'/pages/index/differential?nLevelID='+this.optdata.nLevelID+'&logo='+this.optdata.logo+'&value='+this.optdata.value+'&id='+this.optdata.id+'&isVin='+this.optdata.isVin+'&vin='+this.optdata.vin
			   })
		   }
		}
	}
</script>

<style scoped>
.content{
	min-height: 100vh;
	background: #F4F5F7;
}
.box{
	padding: 0 24rpx;
	background: #ffffff;
}
.historylinecarImg{
	width: 54rpx;
	height: 54rpx;
}
.historyLogoBox{
		display: flex;align-items: center;
		padding-right: 14rpx;
	}
.historylinecar{
	font-weight: 500;font-size: 26rpx;
	color: #1A1A1A;
	line-height: 46rpx;width: 636rpx;
}
.historyLine{
	display: flex;
	padding: 30rpx 0;
}
.title{
	font-weight: 500;font-size: 28rpx;
	color: #1A1A1A;padding: 30rpx 24rpx;
	line-height: 40rpx;
}
.lineBox{
padding: 0 24rpx;	
}
.line{
	width: 332rpx;
	height: 206rpx;
	background: #FFFFFF;
	border-radius: 16rpx;
}
.lineTitle{
	font-weight: 500;font-size: 28rpx;padding-top: 32rpx;
	color: #1A1A1A;padding-left: 30rpx;
	line-height: 40rpx;
}
.lineEnglish{
	font-weight: 400;font-size: 24rpx;
	color: #999999;padding-left: 30rpx;
	line-height: 34rpx;padding-top: 10rpx;
}
.lineImg1{
	width: 82rpx;height: 92rpx;
}
.lineImgbox{
	text-align: right;
}
.lineImg2{
	width: 106rpx;height: 82rpx;    margin-top: 10rpx;
}
.historyLineVin{
	display: flex;background: #ffffff;
}
.historyLineCar{
	display: flex;justify-content: space-between;
}
.vinNum{
	font-weight: 400;font-size: 22rpx;padding-left: 10rpx;
	color: #999999;line-height: 30rpx;
}
.vinms{
	width: 38rpx;
	height: 26rpx;
	background: linear-gradient(224deg, #FFDA28 0%, #FFBF35 100%);
	border-radius: 4rpx;
	text-align: center;
	line-height: 26rpx;
	font-weight: 600;
	color: #FFFFFF;
	font-size: 18rpx;
	margin-top: 2rpx;
}
.picker-view {
		width: 750rpx;
		height: 600rpx;
		margin-top: 20rpx;
	}
	.popupLine {
		line-height: 100rpx;
		text-align: center;
		font-size: 28rpx;
	    display: block;
	}
	.popupLineBox{
		 padding-bottom: env(safe-area-inset-bottom);
	}
	.popupTitle{
		line-height: 100rpx;
		text-align: center;
		font-size: 30rpx;
		color: #999999;
	}
</style>
