<template>
	<view :style="getHeight" style="background-color: #F5F5F5;">
		<!-- 公共组件-每个页面必须引入 -->
		<public-module></public-module>
		<!-- 头部 -->
		<view class="carInfo w-100 px-3 box-sizing">
			<view class="d-flex">
				<view class="icon iconfont icon-tree-round-car flex-shrink topLeft"></view>
				<view class="topRight d-flex flex-1 p-3 flex-column" style="color: #FFFFFF;">
					<view class="d-flex flex-1">
						<view class="font-lg d-flex a-center">{{this.carInfo.licenseNo}}
							<view class="icon iconfont icon-bianji1 ml-2" @tap="toCarInfo"></view>
						</view>
					</view>
					<view class="brandName">{{this.carInfo.brandName}}</view>
				</view>
			</view>
			<view class="other d-flex j-sb px-3">
				<view class="d-flex flex-1 a-center">
					<view class="privilege d-flex a-center j-center flex-shrink px-2">特权</view>
					<view class="content">每月自动查违章，无违章领奖励</view>
				</view>
				<view class="flex-shrink icon iconfont icon-youjiantou d-flex a-center font-sm"></view>
			</view>
		</view>
		<!-- 报价方案 -->
		<view class="pageContent">
			<view class="quotePlan mx-3">
				<view class="header j-sb d-flex a-center px-3">
					<view class="title font-md">报价方案</view>
					<view class="adjustPlan main-text-color" @tap="toInsureItems">调整方案</view>
				</view>
				<view class="body">
					<view class="insurance">
						<template v-if="CIStartDate!=''">
							<view class="row j-sb  d-flex a-center">
								<view>交强险</view>
								<view>投保</view>
							</view>
						</template>
						<template v-if="BIStartDate!=''">
							<block v-for="(item,index) in insureList" :key="index">
								<template v-if="item.amount!=0">
									<view class="row j-sb  d-flex a-center">
										<view>{{item.kindName}}</view>
										<block v-for="(item2,index2) in item.amtList" :key="index2">
											<template v-if="item2.value == item.amount">
												<view>{{item2.label}}</view>
											</template>
										</block>
									</view>
								</template>
							</block>
						</template>
						<view class="d-flex">
							<view>起保日期：</view>
							<view>
								<picker ref="jqTimePicker" :value="jqTimeIndex" :range="timeArray"
									@change="jqTimePickerChange" @cancel="jqTimePickerCancel"></picker>
								<p class="date d-flex a-center font-md" style="color: #FFFFFF;"
									v-if="this.CIStartDate!=''">交强险 {{this.CIStartDate}}
									<!-- <checkbox :checked="jqjishi" @tap="jqjishichange" style="transform:scale(0.5)"/>即时 -->
								</p>
								<picker ref="syTimePicker" :value="syTimeIndex" :range="timeArray"
									@change="syTimePickerChange" @cancel="syTimePickerCancel"></picker>
								<p class="date  d-flex a-center font-md" style="color: #FFFFFF;"
									v-if="this.BIStartDate!=''">商业险 {{this.BIStartDate}}
									<!-- <checkbox :checked="syjishi" @tap="syjishichange"  style="transform:scale(0.5)"/>即时 -->
								</p>
							</view>
						</view>
					</view>
					<view class="addedServices" v-if="this.BIStartDate!=''">
						<view class="row j-sb  d-flex a-center">
							<view>增值服务</view>
							<view>赠送</view>
						</view>
						<view style="padding: 15upx;color: #A6A6A6;font-size: 24upx;background-color: #F8FAFC;">
							注：包含道路救援/安全检测/代为驾驶/代为送检，投保以上商业主险免费赠送，各家保司各个地区旅游差异，具体以保单信息为准</view>
					</view>
				</view>
			</view>
			<!-- 	<view class="d-flex a-center j-center" v-if="totalCompanyList[0].quoteCode !== '200'" >
				还有 <view style="margin: 10upx; color: #007AFF;"> {{totalCompanyList.length - quoteCompanyCount}} </view>
				家保险公司正在报价
			</view> -->
			<!-- {{msg}} -->
			<view class="quoteCompany">
				<!-- <ls-loading text="掌柜正在为您报价，请稍等......" :animation="animation" v-if="show1" fontSize="28" /> -->
				<view class="header j-sb  d-flex a-center">
					<view class="title  d-flex">精选保险公司<view class="icon iconfont icon-Group-"></view>
					</view>
				</view>
				<block v-for="(totalitem,totalindex) in totalCompanyList" :key="index">
					<template>
						<view class="quoteCompanyItem">
							<view class="top dis  f-c" v-show="true">
								<view class="companyIcon d-flex ">
									<u-checkbox
										@change="event=>checkboxChange(event,totalitem.id,totalitem.cnName, totalindex)"
										v-model="totalitem.checked" active-color="rgb(250, 53, 52)"></u-checkbox>
									<image :src="totalitem.logo"></image>
									<view class="companyName">{{totalitem.namesimple}}</view>
									<view class="totalMoney">￥{{totalitem.result.sumPermium}}</view>
								</view>
							</view>
							<view class="body d-flex main-text-color">
								<view>
									<view class="icon iconfont icon-exchange"></view>2次代步车服务
								</view>
								<view>
									<view class="icon iconfont icon-exchange"></view>2次代步车服务
								</view>
								<view>
									<view class="icon iconfont icon-exchange"></view>2次代步车服务2次代步车服务2次代步车服务
								</view>
							</view>
							<view>
								<button class="btn main-bg-color"
									@tap="toQuoteDetail(totalitem.result.orderno)">查看详情</button>
							</view>

							<u-alert-tips style="margin-top: 10px;padding:4px;"
								v-if="(totalitem.quoteCode == '200') && (totalitem.name =='中煤财险')" type="warning"
								:show-icon="true" :description="totalitem.msg"></u-alert-tips>
						</view>
					</template>
				</block>
			</view>
		</view>
		<wyb-popup ref="carTypePopup" type="center" :scrollY="true" mode="size-fixed" :maskClickClose="false"
			height="640" width="690" radius="6">
			<view class="popupBody">
				<block v-for="(item,index) in carTypeList" :key="index">
					<view class="carTypeItem d-flex " @tap="chooseCarType(item)">
						<view class="nav d-flex flex-1 flex-column">
							<view class="carseriesName">{{item.carseriesname}}</view>
							<view class="modelName">{{item.modelname}}</view>
							<view class="nav_box d-flex">
								<span class="zid">{{item.transmissiontype}}</span>
								<p class=" d-flex a-center">
									{{item.caryear}}{{item.caryear==""?"":"款 | "}}{{item.seatmax}}座
								</p>
							</view>
						</view>
						<view class="price d-flex a-center j-center">￥{{item.purchaseprice}}</view>
					</view>
				</block>
			</view>
		</wyb-popup>
		<view class="infoBottom d-flex a-center j-center j-sb">
			<button type="default" class="d-flex a-center j-center" @tap="toNext">保费计算</button>
		</view>
	</view>
</template>
<script>
	import {
		mapState
	} from "vuex"
	import wybPopup from '@/components/common/wyb-popup/wyb-popup.vue'
	import lsLoading from '@/components/common/ls-loading/ls-loading.vue';
	export default {
		components: {
			wybPopup,
			lsLoading
		},
		computed: {
			...mapState(['userInfo']),
			getHeight() {
				let height = uni.getSystemInfoSync().windowHeight;
				return `minHeight: ${height}px;`;
			}
		},
		// 监听导航栏的按钮
		onNavigationBarButtonTap(e) {
			if (e.index == 0) {
				this.navigate({
					url: '/pages/index/index'
				}, "switchTab", true);
			}
		},
		data() {
			return {
				show1: true, //华农
				animation: 'twinkle', //动画类型
				jqjishi: false,
				syjishi: false,
				timeArray: [],
				jqTimeIndex: 0,
				syTimeIndex: 0,
				time1: "",
				time2: "",
				carTypeList: [], //车辆品牌型号列表
				msg: "",
				quoteno: "", //报价编号
				hasKindCodeA: false, //是否含有车损险
				carInfo: {}, //车辆信息
				carInfo1: {}, //车辆信息
				ownerInfo: {}, //车主信息
				policyHolderInfo: {}, //投保人信息
				insuredPersonInfo: {}, //被保人信息
				riskList: [], //险种大类信息
				kindList: [], //商业险险别
				showCarInfo: false, //控制车辆信息显示
				showInsureDate: true, //控制险种时间显示
				CIStartDate: "", //交强险日期
				BIStartDate: "", //商业险日期
				insureList: [{
						amount: "0",
						amtList: [{
							"label": "投保",
							"value": "1"
						}],
						kindCode: "A",
						isMainRisk: true,
						kindName: "机动车损失险"
					},
					{
						amount: "0",
						amtList: [{
							"label": "10万",
							"value": "100000"
						}, {
							"label": "15万",
							"value": "150000"
						}, {
							"label": "20万",
							"value": "200000"
						}, {
							"label": "30万",
							"value": "300000"
						}, {
							"label": "50万",
							"value": "500000"
						}, {
							"label": "100万",
							"value": "1000000"
						}, {
							"label": "150万",
							"value": "1500000"
						}, {
							"label": "200万",
							"value": "2000000"
						}, {
							"label": "250万",
							"value": "2500000"
						}, {
							"label": "300万",
							"value": "3000000"
						}, {
							"label": "500万",
							"value": "5000000"
						}, {
							"label": "1000万",
							"value": "10000000"
						}],
						kindCode: "B",
						isMainRisk: true,
						kindName: "第三者责任险"
					},
					{
						amount: "0",
						amtList: [{
							"label": "1万",
							"value": "10000"
						}, {
							"label": "2万",
							"value": "20000"
						}, {
							"label": "5万",
							"value": "50000"
						}, {
							"label": "10万",
							"value": "100000"
						}, {
							"label": "15万",
							"value": "150000"
						}, {
							"label": "20万",
							"value": "200000"
						}],
						kindCode: "D3",
						isMainRisk: true,
						kindName: "司机责任险"
					},
					{
						amount: "0",
						amtList: [{
							"label": "1万",
							"value": "10000"
						}, {
							"label": "2万",
							"value": "20000"
						}, {
							"label": "5万",
							"value": "50000"
						}, {
							"label": "10万",
							"value": "100000"
						}, {
							"label": "15万",
							"value": "150000"
						}, {
							"label": "20万",
							"value": "200000"
						}],
						kindCode: "D4",
						isMainRisk: true,
						kindName: "乘客责任险"
					},
					{
						amount: "0",
						amtList: [{
							"label": "2000",
							"value": "2000"
						}, {
							"label": "5000",
							"value": "5000"
						}, {
							"label": "1万",
							"value": "10000"
						}],
						isMainRisk: false,
						kindCode: "L",
						kindName: "车身划痕险",
						mainRiskCodeList: "A"
					},
					{
						amount: "0",
						amtList: [{
							"label": "5%",
							"value": "5"
						}, {
							"label": "10%",
							"value": "10"
						}, {
							"label": "15%",
							"value": "15"
						}, {
							"label": "20%",
							"value": "20"
						}],
						isMainRisk: false,
						kindCode: "MJ1",
						kindName: "绝对免赔率特约险（车损）",
						mainRiskCodeList: "A"
					},
					{
						amount: "0",
						amtList: [{
							"label": "5%",
							"value": "5"
						}, {
							"label": "10%",
							"value": "10"
						}, {
							"label": "15%",
							"value": "15"
						}, {
							"label": "20%",
							"value": "20"
						}],
						isMainRisk: false,
						kindCode: "MJ2",
						kindName: "绝对免赔率特约险（三者）",
						mainRiskCodeList: "B"
					},
					{
						amount: "0",
						amtList: [{
							"label": "5%",
							"value": "5"
						}, {
							"label": "10%",
							"value": "10"
						}, {
							"label": "15%",
							"value": "15"
						}, {
							"label": "20%",
							"value": "20"
						}],
						isMainRisk: false,
						kindCode: "MJ3",
						kindName: "绝对免赔率特约险（司机）",
						mainRiskCodeList: "D3"
					},
					{
						amount: "0",
						amtList: [{
							"label": "5%",
							"value": "5"
						}, {
							"label": "10%",
							"value": "10"
						}, {
							"label": "15%",
							"value": "15"
						}, {
							"label": "20%",
							"value": "20"
						}],
						isMainRisk: false,
						kindCode: "MJ4",
						kindName: "绝对免赔率特约险（乘客）",
						mainRiskCodeList: "D4"
					},
					{
						amount: "0",
						amtList: [{
							"label": "投保",
							"value": "1"
						}],
						isMainRisk: false,
						kindCode: "BD",
						kindName: "法定节假日限额翻倍险",
						mainRiskCodeList: "B"
					}
				],

				totalCompanyList: [], //保险公司列表
				notStartedQuote: true, //未开始报价(true表示未开始报价，false表示已经报价结束)
				quoteCompanyCount: 0,
			}
		},
		async onLoad() {
			const eventChannel = this.getOpenerEventChannel()
			// 监听acceptData事件，获取上一页面通过eventChannel传送到当前页面的数据
			eventChannel.on('acceptData', async (data) => {
				console.log(data)
				// this.quoteno = new Date().getTime(); //报价号
				let getquote = await this.$http.get('/ins/tool/getQuoteNo');
				this.quoteno = getquote.data;
				//读取上一个页面传过来数据（车辆信息，人员信息，险种信息）
				this.carInfo = data.carInfo; //车辆信息
				this.carInfo1 = data.carInfo; //车辆信息
				this.ownerInfo = data.ownerInfo; //车主信息
				this.policyHolderInfo = data.policyHolderInfo; //投保人信息
				this.insuredPersonInfo = data.insuredPersonInfo; //被保人信息
				this.riskList = data.riskList; //险种大类
				this.kindList = data.kindList; //商业险险别
				this.CIStartDate = '';
				this.BIStartDate = '';
				var dateTime = new Date();
				dateTime.setTime(dateTime.getTime() + 24 * 60 * 60 * 1000);
				var tomorrow = dateTime.getFullYear() + "-" + (((dateTime.getMonth() + 1) < 10) ? ("0" + (
						dateTime.getMonth() +
						1)) : (dateTime.getMonth() + 1)) + "-" + ((dateTime.getDate() < 10) ? ("0" +
						dateTime
						.getDate()) : dateTime.getDate()) +
					" 00:00";

				if (this.riskList.length > 0) {
					for (let i = 0; i < this.riskList.length; i++) {
						if (this.riskList[i].riskCode == '0507') {

							this.CIStartDate = this.riskList[i].startDate;
							// if ((new Date(tomorrow).getTime()) > (new Date(this.CIStartDate).getTime())) {
							// 	this.CIStartDate = tomorrow;
							// 	this.riskList[i].startDate = tomorrow;
							// 	this.riskList[i].endDate = this.oneYearPast1(tomorrow);
							// }
						}
						if (this.riskList[i].riskCode == '0510') {
							this.BIStartDate = this.riskList[i].startDate;
							// if (new Date(tomorrow).getTime() > new Date(this.BIStartDate).getTime()) {
							// 	this.BIStartDate = tomorrow;
							// 	this.riskList[i].startDate = tomorrow;
							// 	this.riskList[i].endDate = this.oneYearPast1(tomorrow);
							// }
							for (let j = 0; j < this.kindList.length; j++) {
								if (this.kindList[j].kindCode == 'A') {
									this.hasKindCodeA = true;
								}
								for (let m = 0; m < this.insureList.length; m++) {
									if (this.kindList[j].kindCode == this.insureList[m].kindCode) {
										if (this.kindList[j].kindCode == 'B') {
											this.insureList[9].amtList[0].value = this.kindList[j].amount;
										}
										if (this.insureList[m].kindCode == 'D4') {
											this.insureList[m].amount = this.kindList[j].unitAmount;
										} else if (this.insureList[m].isMainRisk || (this.insureList[m]
												.kindCode == 'BD') || (this.insureList[m].kindCode ==
												'L')) {
											this.insureList[m].amount = this.kindList[j].amount;
										} else {
											this.insureList[m].amount = this.kindList[j].deductibleRate;
										}
									}
								}
							}
						}
					}
				}
			})
			this.commpanyList(); //获取保险公司列表

		},
		methods: {
			async commpanyList() {
				let commpanykad = await this.$http.get('/esmInsCompany/gainAllowQuoteList');
				commpanykad.data.map(ele => {
					ele["result"] = {};
					ele["quoteCode"] = 0;
					ele["checked"] = false;
					ele["msg"] = "";
				})
				this.totalCompanyList = commpanykad.data;
			},
			jqTimePickerCancel() {
				this.jqjishi = !this.jqjishi;
				var dateTime = new Date();
				dateTime.setTime(dateTime.getTime() + 24 * 60 * 60 * 1000);
				var tomorrow = dateTime.getFullYear() + "-" + (((dateTime.getMonth() + 1) < 10) ? ("0" + (dateTime
						.getMonth() + 1)) :
					(dateTime.getMonth() + 1)) + "-" + ((dateTime.getDate() < 10) ? ("0" + dateTime.getDate()) :
					dateTime.getDate()) + " 00:00";
				this.CIStartDate = tomorrow;
			},
			syTimePickerCancel() {
				this.syjishi = !this.syjishi;
				var dateTime = new Date();
				dateTime.setTime(dateTime.getTime() + 24 * 60 * 60 * 1000);
				var tomorrow = dateTime.getFullYear() + "-" + (((dateTime.getMonth() + 1) < 10) ? ("0" + (dateTime
						.getMonth() + 1)) :
					(dateTime.getMonth() + 1)) + "-" + ((dateTime.getDate() < 10) ? ("0" + dateTime.getDate()) :
					dateTime.getDate()) + " 00:00";
				this.BIStartDate = tomorrow;
			},
			jqTimePickerChange(e) {
				var dateTime = new Date();
				var tomorrow = dateTime.getFullYear() + "-" + (((dateTime.getMonth() + 1) < 10) ? ("0" + (dateTime
						.getMonth() + 1)) :
					(dateTime.getMonth() + 1)) + "-" + ((dateTime.getDate() < 10) ? ("0" + dateTime.getDate()) :
					dateTime.getDate()) + " " + this.timeArray[e.detail.value];
				this.CIStartDate = tomorrow;
			},
			syTimePickerChange(e) {
				var dateTime = new Date();
				var tomorrow = dateTime.getFullYear() + "-" + (((dateTime.getMonth() + 1) < 10) ? ("0" + (dateTime
						.getMonth() + 1)) :
					(dateTime.getMonth() + 1)) + "-" + ((dateTime.getDate() < 10) ? ("0" + dateTime.getDate()) :
					dateTime.getDate()) + " " + this.timeArray[e.detail.value];
				this.BIStartDate = tomorrow;
			},

			jqjishichange() {
				this.jqjishi = !this.jqjishi;
				if (this.jqjishi) {
					var hours = new Date().getHours() + 1;
					this.timeArray = [];
					for (let i = hours; i < 24; i++) {
						let m = i;
						if (m < 10) {
							m = '0' + m
						}
						this.timeArray.push(m + ':00')
					}
					this.$refs.jqTimePicker.$el.click();
				} else {
					var dateTime = new Date();
					dateTime.setTime(dateTime.getTime() + 24 * 60 * 60 * 1000);
					var tomorrow = dateTime.getFullYear() + "-" + (((dateTime.getMonth() + 1) < 10) ? ("0" + (dateTime
							.getMonth() + 1)) :
						(dateTime.getMonth() + 1)) + "-" + ((dateTime.getDate() < 10) ? ("0" + dateTime.getDate()) :
						dateTime.getDate()) + " 00:00";
					this.CIStartDate = tomorrow;
				}
			},
			syjishichange() {
				this.syjishi = !this.syjishi;
				if (this.syjishi) {
					var hours = new Date().getHours() + 1;
					this.timeArray = [];
					for (let i = hours; i < 24; i++) {
						let m = i;
						if (m < 10) {
							m = '0' + m
						}
						this.timeArray.push(m + ':00')
					}
					this.$refs.syTimePicker.$el.click();
				} else {
					var dateTime = new Date();
					dateTime.setTime(dateTime.getTime() + 24 * 60 * 60 * 1000);
					var tomorrow = dateTime.getFullYear() + "-" + (((dateTime.getMonth() + 1) < 10) ? ("0" + (dateTime
							.getMonth() + 1)) :
						(dateTime.getMonth() + 1)) + "-" + ((dateTime.getDate() < 10) ? ("0" + dateTime.getDate()) :
						dateTime.getDate()) + " 00:00";
					this.BIStartDate = tomorrow;
				}
			},
			/**
			 * 选择保险公司方法
			 * @param {String} event  change选中事件
			 * @param {String} code 保险公司ID
			 * @param {String} name 保险公司主体全拼
			 * @param {String} index 选中下标
			 */
			checkboxChange(event, code, name, index) {
				this.totalCompanyList[index].checked = event.value;

			},
			// 重新选择车型
			toCarInfo() {
				this.navigate({
					url: '/pages/carInsure1/carInfo1',
					success: (res) => {
						res.eventChannel.emit("acceptData", {
							carInfo: this.carInfo,
							ownerInfo: this.ownerInfo,
							policyHolderInfo: this.policyHolderInfo,
							insuredPersonInfo: this.insuredPersonInfo,
							riskList: this.riskList,
							kindList: this.kindList
						})
					}
				}, "navigateTo", true);
			},
			// 重新选择方案
			toInsureItems() {
				this.navigate({
					url: '/pages/carInsure1/insureItems1',
					success: (res) => {
						res.eventChannel.emit("acceptData", {
							carInfo: this.carInfo,
							ownerInfo: this.ownerInfo,
							policyHolderInfo: this.policyHolderInfo,
							insuredPersonInfo: this.insuredPersonInfo,
							riskList: this.riskList,
							kindList: this.kindList,
							vehicleModel: this.vehicleModel,
						})
					}
				}, "navigateTo", true);
			},
			toQuoteDetail(orderno) {
				this.navigate({
					url: "/pages/carInsure1/quoteDetail1?orderno=" + orderno
				}, "navigateTo", true);
			},

			// 显示信息
			showErrorMsg(msg) {
				if ((msg != "") || (msg != "成功")) {
					uni.showModal({
						title: '提示',
						content: msg,
						showCancel: false,
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
							}
						}
					});
				}
			},
			//恒邦车辆实际价值
			async hengbangActualValue() {
				let kinds = [];
				Object.assign(kinds, this.kindList);
				let res = await this.$http.post('/api/hengbang/actualValue', this.carInfo, {
					timeout: 30000,
					load: false
				})
				for (let j = 0; j < kinds.length; j++) {
					if (kinds[j].kindCode == 'A') {
						kinds[j].amount = res.data;
					}
				}
				return kinds;
			},

			//恒邦车辆实际价值
			async hengbangCarType() {
				let car = {};
				Object.assign(car, this.carInfo);
				let param = {
					"modelName": this.carInfo.brandName,
					"modelCode": this.carInfo.ciModelCode
				}
				let res = await this.$http.post('/zm/ModelsQuery', param, {
					timeout: 30000,
					load: false
				});
				let resList = [];
				if (res.data.length > 0) {
					car.modelCode = res.data[0].modelCode
				}
				return car;
			},

			/* 恒邦 */
			async hengbangquote(num) {
				this.totalCompanyList[num].msg = "";
				let res = await this.$http.post('/ins/hengbang/quote', {
					userId: this.userInfo.sysUser.id,
					quoteno: this.quoteno,
					carInfo: this.carInfo,
					ownerInfo: this.ownerInfo,
					policyHolderInfo: this.policyHolderInfo,
					insuredPersonInfo: this.insuredPersonInfo,
					riskList: this.riskList,
					kindList: this.kindList,
				});
				this.totalCompanyList[num].msg = res.msg;
				if (!!res.msg && (res.msg.indexOf("不存在有效协议") >= 0)) {
					this.totalCompanyList[num].quoteCode = '4'
					this.totalCompanyList[num].msg = res.msg;
					return;
				} else if ((res.data == null) && (res.msg.indexOf('交强险平台返回') > -1) && (res.msg.indexOf(';终保日期') > -
						1)) {
					this.CIStartDate = res.msg.substr(res.msg.indexOf(';终保日期 ') + 6, 16);
					if (this.riskList.length > 0) {
						for (let i = 0; i < this.riskList.length; i++) {
							if (this.riskList[i].riskCode == '0507') {
								this.riskList[i].startDate = this.CIStartDate;
								this.riskList[i].endDate = this.oneYearPast1(this.CIStartDate);
							}
						}
					}
					return this.hengbangquote(num);
				} else if (!!res.data) {
					this.totalCompanyList[num].quoteCode = 200;
					return res.data;
				} else {
					this.totalCompanyList[num].quoteCode = '3'
					this.totalCompanyList[num].msg = res.msg;
					return;
				}
			},
			/* 中煤 */
			async zhongmeiquote(num) {
				this.totalCompanyList[num].msg = "";
				let res = await this.$http.post('/insZhongmei/quote', {
					userId: this.userInfo.sysUser.id,
					quoteno: this.quoteno,
					carInfo: this.carInfo,
					ownerInfo: this.ownerInfo,
					policyHolderInfo: this.policyHolderInfo,
					insuredPersonInfo: this.insuredPersonInfo,
					riskList: this.riskList,
					kindList: this.kindList,
				});
				this.totalCompanyList[num].msg = res.msg;
				if (!!res.msg && (res.msg.indexOf("不存在有效协议") >= 0)) {
					this.totalCompanyList[num].quoteCode = '4'
					this.totalCompanyList[num].msg = res.msg;
					return;
				} else if ((res.data == null) && (res.msg.indexOf('交强险平台返回') > -1) && (res.msg.indexOf(';终保日期') > -
						1)) {
					this.CIStartDate = res.msg.substr(res.msg.indexOf(';终保日期 ') + 6, 16);
					if (this.riskList.length > 0) {
						for (let i = 0; i < this.riskList.length; i++) {
							if (this.riskList[i].riskCode == '0507') {
								this.riskList[i].startDate = this.CIStartDate;
								this.riskList[i].endDate = this.oneYearPast1(this.CIStartDate);
							}
						}
					}
					return this.zhongmeiquote(num);
				} else if (!!res.data) {
					this.totalCompanyList[num].quoteCode = 200;
					this.totalCompanyList[num].msg = res.msg;
					return res.data;
				} else {
					this.totalCompanyList[num].quoteCode = '3'
					this.totalCompanyList[num].msg = res.msg;
					return;
				}
			},
			/* 永诚 */
			async yongchengquote(num) {
				this.totalCompanyList[num].msg = "";
				let res = await this.$http.post('/ins/yongcheng/quote', {
					userId: this.userInfo.sysUser.id,
					quoteno: this.quoteno,
					carInfo: this.carInfo,
					ownerInfo: this.ownerInfo,
					policyHolderInfo: this.policyHolderInfo,
					insuredPersonInfo: this.insuredPersonInfo,
					riskList: this.riskList,
					kindList: this.kindList,
				});
				this.totalCompanyList[num].msg = res.msg;
				if (!!res.msg && (res.msg.indexOf("不存在有效协议") >= 0)) {
					this.totalCompanyList[num].quoteCode = '4'
					this.totalCompanyList[num].msg = res.msg;
					return;
				} else if ((res.data == null) && (res.msg.indexOf('车险平台返回') > -1) && (res.msg.indexOf(';终保日期') > -
						1)) {
					this.CIStartDate = res.msg.substr(res.msg.indexOf(';终保日期 ') + 6, 16);
					if (this.riskList.length > 0) {
						for (let i = 0; i < this.riskList.length; i++) {
							if (this.riskList[i].riskCode == '0507') {
								this.riskList[i].startDate = this.CIStartDate;
								this.riskList[i].endDate = this.oneYearPast1(this.CIStartDate);
							}
						}
					}
					return this.yongchengquote(num);
				} else if (!!res.data) {
					this.totalCompanyList[num].quoteCode = 200;
					this.totalCompanyList[num].msg = res.msg;
					return res.data;
				} else {
					this.totalCompanyList[num].quoteCode = '3'
					this.totalCompanyList[num].msg = res.msg;
					return;
				}
			},
			/* 永安 */
			async yonganquote(num) {
				this.totalCompanyList[num].msg = "";
				let res = await this.$http.post('/api/yongan/quote', {
					userId: this.userInfo.sysUser.id,
					quoteno: this.quoteno,
					carInfo: this.carInfo,
					ownerInfo: this.ownerInfo,
					policyHolderInfo: this.policyHolderInfo,
					insuredPersonInfo: this.insuredPersonInfo,
					riskList: this.riskList,
					kindList: this.kindList,
				});
				this.totalCompanyList[num].msg = res.msg;
				if (res.msg == '重复投保' && res.code == '501') {
					if (!!res.data.jqStartDate && !res.data.syStartDate) {
						// this.totalCompanyList[num].quoteCode = '3'
						// var MsgTitle = "重复投保，新保单交强险起保时间为：" + res.data.jqStartDate + "; 终保时间为：" + res.data.jqEndDate;
						// this.totalCompanyList[num].msg = MsgTitle;
						this.CIStartDate = res.data.jqStartDate.slice(0, -3);
						if (this.riskList.length > 0) {
							for (let i = 0; i < this.riskList.length; i++) {
								if (this.riskList[i].riskCode == '0507') {
									this.riskList[i].startDate = res.data.jqStartDate;
									this.riskList[i].endDate = res.data.jqEndDate;
								}
							}
						}
						return this.yonganquote(num);
					} else if (!!res.data.syStartDate && !res.data.jqStartDate) {
						// this.totalCompanyList[num].quoteCode = '3'
						// var MsgTitle = "重复投保，新保单商业险起保时间为：" + res.data.syStartDate + "; 终保时间为：" + res.data.syEndDate;
						// this.totalCompanyList[num].msg = MsgTitle;
						this.BIStartDate = res.data.syStartDate.slice(0, -3);
						if (this.riskList.length > 0) {
							for (let i = 0; i < this.riskList.length; i++) {
								if (this.riskList[i].riskCode == '0510') {
									this.riskList[i].startDate = res.data.syStartDate;
									this.riskList[i].endDate = res.data.syEndDate;
								}
							}
						}
						return this.yonganquote(num);
					} else if (!!res.data.syStartDate && !!res.data.jqStartDate) {
						// this.totalCompanyList[num].quoteCode = '3'
						// var MsgTitle = "重复投保，新保单交强险起保时间为：" + res.data.jqStartDate + "; 终保时间为：" + res.data.jqEndDate +
						// 	"; 商业险起保时间为：" + res.data.syStartDate + ";终保时间为：" + res.data.syEndDate;
						// this.totalCompanyList[num].msg = MsgTitle;
						this.CIStartDate = res.data.jqStartDate.slice(0, -3);
						this.BIStartDate = res.data.syStartDate.slice(0, -3);
						if (this.riskList.length > 0) {
							for (let i = 0; i < this.riskList.length; i++) {
								if (this.riskList[i].riskCode == '0507') {
									this.riskList[i].startDate = res.data.jqStartDate;
									this.riskList[i].endDate = res.data.jqEndDate;
								} else if (this.riskList[i].riskCode == '0510') {
									this.riskList[i].startDate = res.data.syStartDate;
									this.riskList[i].endDate = res.data.syEndDate;
								}
							}
						}
						return this.yonganquote(num);
					} else {
						this.totalCompanyList[num].quoteCode = '3'
						this.totalCompanyList[num].msg = "重复投保";
					}

				} else if (res.code == '500' || res.code == '502' || res.code == '-9999') {
					this.totalCompanyList[num].quoteCode = '-9999'
					this.totalCompanyList[num].msg = res.msg;
				} else {
					this.totalCompanyList[num].quoteCode = 200;
					return res.data;
				}
			},
			/* 人保 */
			async renbaoquote(num) {
				this.totalCompanyList[num].msg = "";
				let res = await this.$http.post('/api/insRenbao/quote', {
					userId: this.userInfo.sysUser.id,
					quoteno: this.quoteno,
					carInfo: this.carInfo,
					ownerInfo: this.ownerInfo,
					policyHolderInfo: this.policyHolderInfo,
					insuredPersonInfo: this.insuredPersonInfo,
					riskList: this.riskList,
					kindList: this.kindList,
				});
				this.totalCompanyList[num].msg = res.msg;
				if (!!res.msg && (res.msg.indexOf("不存在有效协议") >= 0)) {
					this.totalCompanyList[num].quoteCode = '4'
					this.totalCompanyList[num].msg = res.msg;
					return;
				} else if ((res.data == null) && (res.msg.indexOf('交强险平台返回') > -1) && (res.msg.indexOf(';终保日期') > -
						1)) {
					this.CIStartDate = res.msg.substr(res.msg.indexOf(';终保日期 ') + 6, 16);
					if (this.riskList.length > 0) {
						for (let i = 0; i < this.riskList.length; i++) {
							if (this.riskList[i].riskCode == '0507') {
								this.riskList[i].startDate = this.CIStartDate;
								this.riskList[i].endDate = this.oneYearPast1(this.CIStartDate);
							}
						}
					}
					return this.renbaoquote(num);
				} else if (!!res.data) {
					this.totalCompanyList[num].quoteCode = 200;
					return res.data;
				} else {
					this.totalCompanyList[num].quoteCode = '3'
					this.totalCompanyList[num].msg = res.msg;
					return;
				}

			},
			async tiananquote(num) {
				this.totalCompanyList[num].msg = "";
				let res = await this.$http.post('/api/tianan/quote', {
					userId: this.userInfo.sysUser.id,
					quoteno: this.quoteno,
					carInfo: this.carInfo,
					ownerInfo: this.ownerInfo,
					policyHolderInfo: this.policyHolderInfo,
					insuredPersonInfo: this.insuredPersonInfo,
					riskList: this.riskList,
					kindList: this.kindList,
				});
				this.totalCompanyList[num].msg = res.msg;
				if (!!res.msg && (res.msg.indexOf("不存在有效协议") >= 0)) {
					this.totalCompanyList[num].quoteCode = '4'
					this.totalCompanyList[num].msg = res.msg;
					return;
				} else if (!!res.data) {
					this.totalCompanyList[num].quoteCode = 200;
					return res.data;
				} else {
					this.totalCompanyList[num].quoteCode = '3'
					this.totalCompanyList[num].msg = res.msg;
					return;
				}
			},
			//选择正确的车型
			async chooseCarType(item) {
				this.carInfo.brandName = item.modelname; //品牌型号
				this.carInfo.ciModelCode = item.vehiclecode; //行业车型编码
				this.carInfo.modelCode = item.modelcode;
				this.carInfo.seatCount = item.seatmax + '';
				this.carInfo.caryear = item.caryear;
				this.carInfo.exhaustScale = (item.exhaustscale * 1000) + '';
				this.carInfo.factory = item.factory;
				this.carInfo.factoryid = item.factorycode;
				this.carInfo.cimodelclass = item.inscarclassname;
				this.carInfo.powertype = item.powerType;
				this.carInfo.purchasePrice = item.purchaseprice + '';
				this.carInfo.modelcname = item.modelname;
				this.$refs.carTypePopup.hide()
				let a = await this.huanongquote(0);
				this.totalCompanyList[0].result = a;
				if (this.totalCompanyList[0].quoteCode != '4') {
					this.quoteCompanyCount++;


					let c = await this.zhongmeiquote(2);
					this.totalCompanyList[2].result = c;
					this.quoteCompanyCount++;
					let d = await this.tiananquote(1);
					this.totalCompanyList[1].result = d;
					this.quoteCompanyCount++;
					let b = await this.hengbangquote(3);
					this.totalCompanyList[3].result = b;
					this.quoteCompanyCount++;

				}
			},
			//计算输入时间一年后的的前一天(输入的参数为字符串("2019-03-02")最终输出也为日期的字符串)
			oneYearPast1(time) {
				if (time.substr(11, 5) == '00:00') {
					var date = new Date(time);
					date.setFullYear(date.getFullYear() + 1); //一年后
					date.setTime(date.getTime() - 24 * 60 * 60 * 1000); //一年后的前一天
					var strYear = date.getFullYear();
					var strDay = date.getDate();
					var strMonth = date.getMonth() + 1;
					if (strMonth < 10) {
						strMonth = "0" + strMonth;
					}
					if (strDay < 10) {
						strDay = "0" + strDay;
					}
					var datastr = strYear + "-" + strMonth + "-" + strDay;
					return datastr + " 24:00";
				} else {
					var time1 = time.substr(11, 5);
					var date = new Date(time);
					date.setFullYear(date.getFullYear() + 1); //一年后
					date.setTime(date.getTime() - 24 * 60 * 60 * 1000); //一年后的前一天
					var strYear = date.getFullYear();
					var strDay = date.getDate();
					var strMonth = date.getMonth() + 1;
					if (strMonth < 10) {
						strMonth = "0" + strMonth;
					}
					if (strDay < 10) {
						strDay = "0" + strDay;
					}
					var datastr = strYear + "-" + strMonth + "-" + strDay;
					return datastr + " " + time1;
				}
			}
		}
	}
</script>
<style lang="scss" scoped>
	@import '@/style/mixin.scss';

	/* 头部车辆信息和特权Start */
	.carInfo {
		height: 330upx;
		background: -webkit-linear-gradient(0deg, rgba($themeColor, 0.6), rgba($themeColor, 0.8));
		background-size: 100% 100%;
	}

	.carInfo .topLeft {
		width: 120upx;
		font-size: 90upx;
		color: #FFFFFF;
	}

	.carInfo .topRight .brandName {
		width: 400upx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.carInfo .other {
		background-color: #FFFFFF;
		height: 80upx;
		border-radius: 15upx;
		box-sizing: border-box;
	}

	.carInfo .other .privilege {
		background-color: rgba($themeColor, 0.6);
		font-size: 24upx;
		color: #FFFFFF;
		font-weight: bold;
	}

	.carInfo .other .content {
		width: 460upx;
		margin-left: 15upx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.carInfo .other .icon {
		width: 30upx;
	}

	/* 头部车辆信息和特权End */
	.pageContent {
		position: relative;
		top: -50upx;
		padding-bottom: 100px;
	}

	/* 报价方案Start */
	.quotePlan {
		background: #FFFFFF;
		position: relative;
		border-radius: 20upx;
	}

	.quotePlan .header {
		height: 80upx;
		position: relative;
		border-bottom: 1px solid #E6E8EA;
	}

	.quotePlan .header .title {
		// font-size: 30upx;
		font-weight: bold;
		padding-left: 25upx;
	}

	.quotePlan .header .title:before {
		content: "";
		position: absolute;
		left: 30upx;
		top: 25upx;
		width: 8upx;
		height: 30upx;
		background-color: $themeColor;
	}

	.quotePlan .body {
		padding: 0 30upx 10upx;
	}

	.quotePlan .body .insurance {
		padding-bottom: 20upx;
		border-bottom: 1px dashed #E6E8EA;
	}






	.carTypeItem {
		padding: 0 30upx 20upx;
		border-bottom: 1px solid #e5e5e5;
		margin-top: 20upx;
		width: 100%;
		box-sizing: border-box;
	}

	.carTypeItem .nav .carseriesName {
		font-size: 34upx;
		width: 360upx;
		font-family: PingFangSC-Medium, PingFangSC;
		color: #4a4a4a;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.carTypeItem .nav .modelName {
		font-size: 26upx;
		width: 400upx;
		font-family: PingFangSC-Medium, PingFangSC;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.carTypeItem .nav .nav_box {
		margin: 10upx 0;
	}

	.carTypeItem .nav .nav_box .zid {
		display: inline-block;
		padding: 6upx 10upx;
		font-size: 24upx;
		height: 40upx;
		background: #AFC9F7;
		border-radius: 25upx;
		color: #007AFF;
		font-weight: bold;
		line-height: 40upx;
	}

	.carTypeItem .nav .nav_box>p {
		margin-left: 30upx;
		color: #999;
		font-size: 24upx;
	}

	.carTypeItem .price {
		font-size: 16px;
		width: 200upx;
		flex-shrink: 0;
		font-family: PingFangSC-Regular, PingFangSC;
		font-weight: 400;
		color: #007AFF;
	}


	.quotePlan .body .row {
		height: 70upx;
	}

	.quotePlan .body .date {
		background-color: $themeColor;
		color: $themeColor;
		font-size: 22upx;
		padding: 0upx 7upx;
		border-radius: 3upx;
		margin: 10upx;
		margin-right: 10upx;
	}

	/* 报价方案End */

	/* 报价公司Start */
	.quoteCompany {
		margin: 20upx 30upx;
		box-sizing: border-box;
		/* background:#FFFFFF; */
		position: relative;
		border-radius: 20upx;
	}

	.quoteCompany .header {
		height: 80upx;
		padding: 0 30upx;
		position: relative;
	}

	.quoteCompany .header .title {
		font-size: 30upx;
		font-weight: bold;
		padding-left: 25upx;
	}

	.quoteCompany .header .title:before {
		content: "";
		position: absolute;
		left: 30upx;
		top: 25upx;
		width: 8upx;
		height: 30upx;
		background-color: rgba($themeColor, 0.6);
	}

	.quoteCompany .header .title .icon {
		color: rgba($themeColor, 0.6);
		margin-left: 15upx;
	}

	.quoteCompanyItem {
		margin-bottom: 20upx;
		background: #FFFFFF;
		border-radius: 15upx;
		padding: 40upx 30upx 30upx;
		box-sizing: border-box;
	}

	.quoteCompanyItem .top {
		position: relative;
	}

	.quoteCompanyItem .top .companyIcon {
		flex-shrink: 0;
	}

	.quoteCompanyItem .top .companyIcon image {
		width: 34px;
		height: 34px;
		margin-right: 10px;
	}

	.quoteCompanyItem .top .companyName {
		font-size: 32upx;
		font-weight: bold;
		width: 180upx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.quoteCompanyItem .top .totalMoney {
		font-size: 40upx;
		font-weight: bold;
		color: $themeColor;
		position: absolute;
		top: -15upx;
		right: 0;
	}

	.quoteCompanyItem .top .tip {
		font-size: 26upx;
		font-weight: bold;
		color: #999;
		position: absolute;
		top: 0upx;
		right: 0;
	}

	.quoteCompanyItem .top .signs {
		width: 500upx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.quoteCompanyItem .top .sign {
		height: 40upx;
		margin: 0upx 10upx;
		background: rgba($themeColor, 0.6);
		color: $themeColor;
		font-size: 20upx;
		margin-right: 10upx;
		border-radius: 6upx;
		padding: 0 2px;
		line-height: 40upx;
	}

	.jqsign {
		height: 20px;
		background: rgba(255, 177, 177, 0.55);
		color: #fd0a0a;
		font-size: 20upx;
		border-radius: 6upx;
		padding: 0 10px;
		box-sizing: border-box;
	}

	.quoteCompanyItem .body {
		padding: 20upx 0;
		flex-wrap: wrap;
	}

	.quoteCompanyItem .body>view {
		flex-shrink: 0;
		width: 50%;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.quoteCompanyItem .body .icon-exchange {
		margin-right: 15upx;
		display: inline-block;
	}

	/* 报价公司End */


	/* 查看详情按钮Start */
	.btn {
		font-size: 32upx;
		color: #fff;
	}

	/* 底部的样式Start */
	.infoBottom {
		height: 140upx;
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		background: #FFFFFF;
		border-top: 1upx solid #EEEEEE;
		z-index: 99;
	}

	.infoBottom>button {
		// font-size: 30upx;
		background: $themeColor;
		color: #FFFFFF;
		flex: 1;
		margin: 0upx 30upx;
	}

	/* 查看详情按钮End */
</style>