common_car.js 31.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994
var modelCodeNumber;
var modelName;
var chgownerFlag;
var vhlVal;
var datalist;
var datapy;
var memnerid;


(function($) {
	$.h.car = {
		doSearch: function(value) {
			let vehicleNo = $("#licenseNo").val()
			let frameNo = $("input[name='frameNo']").val()
			let vehicleName = value
			//let cityCode = "420500"
			let cityCode = "420500"
			let vhlInfo = {}
			vhlInfo.vehicleNo = vehicleNo
			vhlInfo.frameNo = frameNo
			vhlInfo.vehicleName = vehicleName
			vhlInfo.cityCode = cityCode
			$(".carList").html("")
			$.ajax({
				//url: "http://120.53.120.7/index.php/sapi/car/carmodel",
				//url: "http://demo8.xiaochakeji.com/serviceapi/car/carmodel",
				url: "www.aisigit.com/products/car/carmodel",
				data: vhlInfo,
				type: "post",
				beforeSend: function() {
					$.h.car.load()
				},
				complete: function() {
					$.h.car.disLoad();
				},
				success: function(dd) {
					if (dd.vhlList) {
						// console.log(dd);
						$.each(dd.vhlList, function(i, e) {
							$(".carList").show()
							var $ul = $('<ul class="clearfix"></ul>');
							var $modelName = $('<li>' + e.modelName + '</li>');
							var $setNum = $('<li class="color_orange">' + e.setNum + '座</li>');
							var $marketYear = $('<li class="color_orange">' + e.marketYear + '款</li>');
							var $carPrice = $('<li class="color_blue">¥' + e.carPrice + '</li>');
							var $modelCode = $('<li class="hide">' + e.modelCode + '</li>');
							if (typeof e.marketYear == 'undefined') {
								e.marketYear = "未知年份"
								$marketYear = $('<li class="color_orange">' + e.marketYear + '</li>');
								// console.log(e.marketYear)
							} else if (typeof e.marketYear != 'undefined') {
								$marketYear = $('<li class="color_orange">' + e.marketYear + '款</li>');
							}
							if (typeof e.displacement == 'undefined') {
								e.displacement = "--"
							}
							if (typeof e.carRemark == 'undefined') {
								e.carRemark = ""
							}
							var $carRemark = $('<li class="color_aaa">' + e.carRemark + '</li>');
							var $displacement = $('<li>排量:' + e.displacement + '</li>');
							$ul.append($modelName)
							$ul.append($setNum)
							$ul.append($displacement)
							$ul.append($marketYear)
							$ul.append($carRemark)
							$ul.append($carPrice)
							$ul.append($modelCode)
							$(".carList").append($ul)

						})
						$(".carList ul").click(function() {
							modelName = $(this).find("li").first().html()
							modelCodeNumber = $(this).find("li").last().html()
							vhlVal = $(this).find("li").last().prev().html().substr(1)
							$("#svalue").searchbox("setValue", modelName)
							$(".carList").hide()
						})
					} else {
						alert(dd.head.responseMsg)
					}

				}
			})
		},
		//有无车牌
		isCarNew: function() {
			if (!this.checked) {
				$(".licenseNo").textbox("disable", "none");
				$("#licenseNo").textbox("setValue", '*-*');
				$("#hide_licenseNo").hide()
			} else {
				$("#hide_licenseNo").show()
				$("#licenseNo").textbox("enable", "none");
				$("#licenseNo").textbox("setValue", '');
			}
		},
		//投保人同车主
		iscar_policy_holder: function() {
			if (this.checked) {
				$(".car_policy_holder").hide()
			} else {
				$(".car_policy_holder").show()
			}

		},
		//被保人同车主
		iscar_applicant: function() {
			if (this.checked) {
				$(".car_applicant").hide()
			} else {
				$(".car_applicant").show()
			}
		},
		//过户车
		ischgownerFlag: function() {
			if (this.checked) {
				$("#ischgownerFlag")[0].value = true
				chgownerFlag = 1
			} else {
				$("#ischgownerFlag")[0].value = false
				chgownerFlag = 0
			}
		},
		//弹出加载层
		load: function() {
			$("<div class=\"datagrid-mask\"></div>").css({
				display: "inline-block",
				width: "100%",
				height: $(window).height()
			}).appendTo("body");
			$("<div class=\"datagrid-mask-msg\"></div>").html("加载中...").appendTo("body").css({
				display: "inline-block",
				left: ($(document.body).outerWidth(true) - 190) / 2,
				top: ($(window).height() - 45) / 2,
				lineHeight: 0
			});
		},
		//取消加载层  
		disLoad: function() {
			$(".datagrid-mask").remove();
			$(".datagrid-mask-msg").remove();
		}
	}
	$.fn.step = function(e) {

		var t = this,
			n = {
				index: 0,
				time: 400,
				title: []
			},
			s = (e = $.extend({}, n, e)).title,
			d = s.length,
			u = e.time,
			// p = t[0].scrollWidth / d;
			p = 1000 / d;
		console.log(d)
		t.index = e.index;
		var a = function() {
			var e = "";
			s.length > 0 && (e +=
				'<div class="ui-step-wrap"><div class="ui-step-bg"></div><div class="ui-step-progress"></div><ul class="ui-step">',
				$.each(s, function(i, t) {
					e += '<li class="ui-step-item"><div class="ui-step-item-title">' + t +
						'</div><div class="ui-step-item-num"><span>' + (i + 1) + "</span></div></li>"
				}), e += "</ul></div>"), t.append(e), t.find(".ui-step").children(".ui-step-item").width(p), t.toStep(t.index)
		};
		return t.toStep = function(e) {
			var n = t.find(".ui-step").children(".ui-step-item");
			t.index = e, t.find(".ui-step-progress").animate({
				width: p * (e + 1)
			}, u, function() {
				$.each(n, function(t) {
					t > e ? $(this).removeClass("active") : $(this).addClass("active")
				})
			})
		}, t.getIndex = function() {
			return t.index
		}, t.nextStep = function() {
			t.index > d - 2 || (t.index++, t.toStep(t.index))
		}, t.prevStep = function() {
			t.index < 1 || (t.index--, t.toStep(t.index))
		}, a(), this
	}
})(jQuery);
// 分步表单
var $step = $("#step");
var $index = $("#index");
//调用封装方法
$step.step({
	index: 0,
	time: 500,
	title: ["填写信息", "选择方案", "确认订单", "支付费用"]
});

$index.text($step.getIndex());

// 内容切换
function isTab() {
	//console.log($step.getIndex())
	$(".form_tab").eq($step.getIndex()).show().siblings(".form_tab").hide()

	// console.log($(".form_tab").eq(0))
}
//上一步
$("#prevBtn").on("click", function() {
	$step.prevStep();
	$index.text($step.getIndex());
	isTab()
});

//下一步
var myDate = new Date();
var year = myDate.getFullYear();
var mouth = myDate.getMonth() + 1;
var day = myDate.getDate() + 1;
var insrncBgnTm = year + "-" + mouth + "-" + day + " 09:00:00"
var sumUpTax_add;
// var time =  new Date().toLocaleTimeString();
// console.log(myDate.replace(/\//g, "-")+time.replace(/下午/," "))
$("#nextBtn").on("click", function() {
	var frameNo = $("input[name=frameNo]").val()
	var email = $("input[name=email]").val()
	var licenseNo = $("#licenseNo").val() //车牌
	var engNo = $("input[name=engNo]").val()
	var registerDate = $("input[name=registerDate]").val()
	var drvOwner = $("input[name=drvOwner]").val()
	var certiCode = $("input[name=certiCode]").val()
	var certiTel = $("input[name=certiTel]").val()
	if ($("#car_policy_holder")[0].checked) {
		var appName = $("input[name=drvOwner]").val()
		var appCertNo = $("input[name=certiCode]").val()
		var appTel = $("input[name=certiTel]").val()
	}else{
		var appName = $("input[name=appName]").val()
		var appCertNo = $("input[name=appCertNo]").val()
		var appTel = $("input[name=appTel]").val()
	}

	if ($("#iscar_applicant")[0].checked) {
		var insuredName = $("input[name=drvOwner]").val()
		var insuredCertNo = $("input[name=certiCode]").val()
		var insuredTel =$("input[name=certiTel]").val()
	}else{
		var insuredName = $("input[name=insuredName]").val()
		var insuredCertNo = $("input[name=insuredCertNo]").val()
		var insuredTel = $("input[name=insuredTel]").val()
	}

	// console.log(insuredName)
	if ($step.getIndex() == 0) {
		var dataJson = {
			cityCode: "420500",
			modelName: modelName,
			email: email,
			base: {
				joinFlag: "0", //交商同保标识 0-否;1-是
				cityCode: "420500", //城市代码(与车型查询相同)
				channelCode: "",
				channelName: "",
				salesCode: "" //申请出单员毕传
			},
			vhl: {
				licenseNo: licenseNo, //未上牌车传:*-*
				frameNo: frameNo, //车架号/VIN码
				engNo: engNo, //发动机号
				brndCode: modelCodeNumber, //厂牌车型代码
				registerDate: registerDate, //初次登记日期
				chgownerFlag: chgownerFlag, //过户车标志 否:0、是:1
				transferDate: "", //转移登记日期 过户车时必传
				glassType: "", //玻璃类型  01 :国产,02 :进口(选择玻璃单独破碎险时必传)
				vhlVal: vhlVal,
				carCheckTime: "",
				chkResperson: "",
				specialCarFlag: "",
				chkRec: "",
				carChecker: "",
				chkRemark: "",
				belongType: "",
				certificateDate: "",
				certificateNo: "",
				calAppNo: "",
				chkCode: "",
				demandNo: "",
				chkResult: "",
				platformCode: "",
				certificateType: ""
			},
			owner: {
				drvOwner: drvOwner, //行驶证车主
				certiType: "01", //车主证件类型 01身份证
				certiCode: certiCode, //车主证件号码
				certiTel: certiTel //车主电话号码
			},
			riskList: [{
					riskCode: "0301", // 险种代码   0301:交强险、0302:商业险
					insrncBgnTm: insrncBgnTm, //保险起期
					insrncEndTm: "", //保险止期  格式同起期,当不传时默认一年
					effectFlag: "", //即时生效的单子必传,非即时:0、即时:1
					answer: "", //有转保问题时会返回,需输入验证码答案
					electronicInd: "", //电子保单标志  0-否  1-是
					demandNo: "", //投保查询码 1.打回修改再次报价时必传上一次投保查询码; 2.行业车型编码不一致时必传入上一次投保查询码;  3.申请折扣时必传入上一次投保查询码; 4.有转保问题时会返回,直接回传查询码;
					appNo: "", //打回修改的单子重新提交时,上次提单的投保单必传
					calcAppNo: "", //报价单号 1.打回修改再次报价时必传上次提单的报价单;  2.行业车型编码不一致时必传入上一次报价单号;  3.申请折扣时必传入上一次报价单号 4.有转保问题时,必传上一次报价单号.
					tax: {}, //车船税 选择较强险时必传,内容可为空
					coverageList: [{
						number: "", //保障天数/人数 根据具体险别而定(乘客,司机等)
						deductible: "", //车损绝对免赔额 选择车损险时选填,(代码参批注)
						bulletGlass: "", //030107玻璃险需要用到的字段(0 否,1 是)
						amt: "", //保险金额 详细代码见批注(交强险、玻璃险、发动机涉水、修理厂、无法找到第三方不需要传值;车损、盗抢、自燃由保险公司设置为实际车价;其它除批注险别,均由客户填入)
						insrncCode: "BZ", //险别代码  较强险 	BZ
						remark: "", //新增设备险 时 新增设备信息
						franchiseFlag: ""
					}]
				},
				{
					riskCode: "0302", // 险种代码   0301:交强险、0302:商业险
					insrncBgnTm: insrncBgnTm, //保险起期
					insrncEndTm: "", //保险止期  格式同起期,当不传时默认一年
					effectFlag: "", //即时生效的单子必传,非即时:0、即时:1
					answer: "", //有转保问题时会返回,需输入验证码答案
					electronicInd: "", //电子保单标志  0-否  1-是
					demandNo: "", //投保查询码 1.打回修改再次报价时必传上一次投保查询码; 2.行业车型编码不一致时必传入上一次投保查询码;  3.申请折扣时必传入上一次投保查询码; 4.有转保问题时会返回,直接回传查询码;
					appNo: "", //打回修改的单子重新提交时,上次提单的投保单必传
					calcAppNo: "", //报价单号 1.打回修改再次报价时必传上次提单的报价单;  2.行业车型编码不一致时必传入上一次报价单号;  3.申请折扣时必传入上一次报价单号 4.有转保问题时,必传上一次报价单号.
					//tax:{},             //车船税 选择较强险时必传,内容可为空
					coverageList: [{
							number: "", //保障天数/人数 根据具体险别而定(乘客,司机等)
							deductible: "",
							bulletGlass: "",
							amt: vhlVal,
							insrncCode: "030101",
							remark: "",
							franchiseFlag: "1" //不计免赔  0,否;1,是(可投险别见批注)
						},
						{
							number: "", //保障天数/人数 根据具体险别而定(乘客,司机等)
							deductible: "",
							bulletGlass: "",
							amt: "SZ01",
							insrncCode: "030102",
							remark: "",
							franchiseFlag: "1"
						}
					]
				}
			],
			applacation: { //投保人信息
				appName: appName,
				appCertType: "01",
				appCertNo: appCertNo,
				appTel: appTel,
				taxPersonType: "",
				kpType: ""
			},
			insured: { //被保人信息
				insuredName: insuredName,
				insuredCertType: "01",
				insuredCertNo: insuredCertNo,
				insuredTel: insuredTel
			}

		}
		$.ajax({
			//url: "http://120.53.120.7/index.php/sapi/car/premium",
			//url: "http://demo8.xiaochakeji.com/serviceapi/car/premium",
			url: "www.aisigit.com/products/car/premium",
			data: {
				data: JSON.stringify(dataJson)
			},
			type: "post",
			beforeSend: function() {
				$.h.car.load()
			},
			complete: function() {
				$.h.car.disLoad();
			},
			success: function(dd) {

				if (dd.head) {
					$step.nextStep();
					isTab()
					console.log(dd.jqBase.tax)
					// sumUpTax_add = dd.jqBase.tax.sumUpTax
					$(".scheme .jqPremium").html("¥" + dd.jqBase.jqPremium)
					$(".scheme .sumUpTax").html("¥" + dd.jqBase.tax.sumUpTax)
					$(".scheme .syPremium").html("¥" + dd.syBase.syPremium)
					$(".vhlVal").html(vhlVal)
					var addAllPrice = Number(dd.jqBase.jqPremium) + Number(dd.jqBase.tax.sumUpTax) + Number(dd.syBase.syPremium)
					$(".addAllPrice").html("¥" + addAllPrice)
					var calAppNo = dd.jqBase.jqCalAppNo + "_" + dd.syBase.syCalAppNo
					datalist = {
						calAppNo: calAppNo,
						appName: appName,
						appCertType: "01",
						appCertNo: appCertNo,
						appTel: appTel,
						appAddr: "投保人地址测试",
						appEmail: email,
						insrntName: insuredName,
						insrntCertType: "01",
						insrntCertNo: insuredCertNo,
						insrntTel: insuredTel,
						insrntAddr: "被保人地址测试",
						email: email,
						appntList: []
					}
				}else{
					alert(dd.msg)
				}

				console.log(dd)
			},
			error(v) {
				alert("请求失败,错误代码" + v.status)
			}
		})
	} else if ($step.getIndex() == 1) {
		// console.log(datalist)
		//核保数据
		$.ajax({

			//url: "http://120.53.120.7/index.php/sapi/car/underwrite",
			//url: "http://demo8.xiaochakeji.com/serviceapi/car/underwrite",
			url: "www.aisigit.com/products/car/underwrite",
			data: {
				data: JSON.stringify(datalist)
			},
			type: "post",
			beforeSend: function() {
				$.h.car.load()
			},
			complete: function() {
				$.h.car.disLoad();
			},
			success: function(dd) {
				alert(dd.head.responseMsg)
				if (dd.resultList) {
					datapy={}
					$.each(dd.resultList,function(i,e){
						console.log(e)
						if(e.riskCode=="0301"){
							$(".jqappNo").html(e.appNo)
							$(".jqappName").html(e.appName)
							$(".jqinsurdName").html(e.insurdName)
							$(".jqamount").html(e.amount)
							$(".jqpremium").html(e.premium)
							$(".jqoperDate").html(e.operDate)
							var jqstatus;
							if (e.status == 0) {
								jqstatus = "转人工核保"
							} else if (e.status == 3) {
								jqstatus = "打回修改"
							} else if (e.status == 4) {
								jqstatus = "拒保"
							} else if (e.status == 7) {
								jqstatus = "核保通过"
							}
							$(".jqstatus").html(jqstatus)
							datapy.jqAppNo=e.appNo;
							datapy.jqAmount= Number(e.premium) +Number(sumUpTax_add)+"";
							datapy.jqAppName=e.appName
						}else if(e.riskCode=="0302"){
							$(".syappNo").html(e.appNo)
							$(".syappName").html(e.appName)
							$(".syinsurdName").html(e.insurdName)
							$(".syamount").html(e.amount)
							$(".sypremium").html(e.premium)
							$(".syoperDate").html(e.operDate)
							var systatus;
							if (e.status == 0) {
								systatus = "转人工核保"
							} else if (e.status == 3) {
								systatus = "打回修改"
							} else if (e.status == 4) {
								systatus = "拒保"
							} else if (e.status == 7) {
								systatus = "核保通过"
							}
							$(".systatus").html(systatus)
							datapy.syAppNo=e.appNo;
							datapy.syAmount=e.premium;
							datapy.syAppName=e.appName;
						}
					})
					$step.nextStep();
					isTab()
				}
				console.log(dd)
			},
			error(v) {
				alert("请求失败,错误代码" + v.status)
			}
		})

	} else if ($step.getIndex() == 2) {
		console.log(datapy)
		$.ajax({

			//url: "http://120.53.120.7/index.php/sapi/car/payment",
			//url: "http://demo8.xiaochakeji.com/serviceapi/car/payment",
			url: "www.aisigit.com/products/car/payment",
			data: {
				data: JSON.stringify(datapy)
			},
			type: "post",
			beforeSend: function() {
				$.h.car.load()
			},
			complete: function() {
				$.h.car.disLoad();
			},
			success: function(dd) {
				alert(dd.head.responseMsg)


					// $step.nextStep();
					// isTab()


				console.log(dd)

			},
			error(v) {
				alert("请求失败,错误代码" + v.status)
			}
		})

	}else {
		$step.nextStep();
		isTab()
	}

});

// 三级联动
var selectAddress = {
	cmbProvince: $("#cmbProvince"),
	cmbCity: $("#cmbCity"),
	cmbArea: $("#cmbArea"),
	//初始化
	init: function() {
		//初始化省
		console.log(this)
		for (var i = 0; i < provinceList.length; i++) {
			//console.log(provinceList[i].name)
			this.creatOption(provinceList[i].name, this.cmbProvince)
		}
		//初始化市
		this.creatOption(provinceList[0].cityList[0].name, this.cmbCity)
		//初始化县
		this.creatOption(provinceList[0].cityList[0].areaList[0], this.cmbArea)
		//省改变时改变市o(゚Д゚)っ
		this.cmbProvince[0].onchange = this.changeCity;
	},
	//创建option
	creatOption: function(word, parentN) {
		var options = $("<option>" + word + "</option>")
		parentN.append(options)

	},
	//改变市
	changeCity: function() {
		//清空市
		selectAddress.cmbCity.html("")
		//清空县区
		selectAddress.cmbArea.html("")
		//console.log(this) this指使用这个函数的
		//省的下标
		var ind = this.selectedIndex
		var cityList = provinceList[ind].cityList;
		for (var i = 0; i < cityList.length; i++) {
			//console.log(cityList[i].name)
			selectAddress.creatOption(cityList[i].name, selectAddress.cmbCity)
		}
		//县区的第一个显示
		var areaList = cityList[0].areaList;
		for (var i = 0; i < areaList.length; i++) {
			//console.log(areaList[i])
			selectAddress.creatOption(areaList[i], selectAddress.cmbArea)
		}
		selectAddress.cmbCity[0].onchange = selectAddress.changeArea;
	},
	changeArea: function() {
		selectAddress.cmbArea.html("") //?
		//省的下标
		ind1 = selectAddress.cmbProvince[0].selectedIndex
		//市的下标
		ind2 = this.selectedIndex
		var areaList = provinceList[ind1].cityList[ind2].areaList
		for (var i = 0; i < areaList.length; i++) {
			selectAddress.creatOption(areaList[i], selectAddress.cmbArea)
		}

	}
}
selectAddress.init()
// 车型搜索
// $('#userId').combobox({
//             prompt:'输入首关键字自动检索',
//             required:false,
//             url:'',
//             editable:true,
//             hasDownArrow:true,
//             filter: function(q, row){
//                 var opts = $(this).combobox('options');
//                 return row[opts.textField].indexOf(q) == 0;
//             }
//         });
// $("#btn_click").click(function(){
// 	alert($("#brndCodeId").val())
// })
//重新计算保费
$(".qibao_Time").val(insrncBgnTm)
$(".syqibao_Time").val(insrncBgnTm)

function onSubmitData() {
	var frameNo = $("input[name=frameNo]").val()
	var insrncBgnTm2 = $(".qibao_Time").val()
	var syinsrncBgnTm = $(".syqibao_Time").val()
	console.log(insrncBgnTm)
	var email = $("input[name=email]").val()
	var licenseNo = $("#licenseNo").val() //车牌
	var engNo = $("input[name=engNo]").val()
	var registerDate = $("input[name=registerDate]").val()
	var drvOwner = $("input[name=drvOwner]").val()
	var certiCode = $("input[name=certiCode]").val()
	var certiTel = $("input[name=certiTel]").val()
	if ($("#car_policy_holder")[0].checked) {
		$("input[name=appName]").val($("input[name=drvOwner]").val())
		$("input[name=appCertNo]").val($("input[name=certiCode]").val())
		$("input[name=appTel]").val($("input[name=certiTel]").val())

	}
	var appName = $("input[name=appName]").val()
	var appCertNo = $("input[name=appCertNo]").val()
	var appTel = $("input[name=appTel]").val()
	if ($("#iscar_applicant")[0].checked) {
		$("input[name=insuredName]").val($("input[name=drvOwner]").val())
		$("input[name=insuredCertNo]").val($("input[name=certiCode]").val())
		$("input[name=insuredTel]").val($("input[name=certiTel]").val())
	}
	var insuredName = $("input[name=insuredName]").val()
	var insuredCertNo = $("input[name=insuredCertNo]").val()
	var insuredTel = $("input[name=insuredTel]").val()
	var dataJson = {
		cityCode: "420500",
		modelName: modelName,
		email: email,
		base: {
			joinFlag: "0", //交商同保标识 0-否;1-是
			cityCode: "420500", //城市代码(与车型查询相同)
			channelCode: "",
			channelName: "",
			salesCode: "" //申请出单员毕传
		},
		vhl: {
			licenseNo: licenseNo, //未上牌车传:*-*
			frameNo: frameNo, //车架号/VIN码
			engNo: engNo, //发动机号
			brndCode: modelCodeNumber, //厂牌车型代码
			registerDate: registerDate, //初次登记日期
			chgownerFlag: "0", //过户车标志 否:0、是:1
			transferDate: "", //转移登记日期 过户车时必传
			glassType: "", //玻璃类型  01 :国产,02 :进口(选择玻璃单独破碎险时必传)
			vhlVal: vhlVal,
			carCheckTime: "",
			chkResperson: "",
			specialCarFlag: "",
			chkRec: "",
			carChecker: "",
			chkRemark: "",
			belongType: "",
			certificateDate: "",
			certificateNo: "",
			calAppNo: "",
			chkCode: "",
			demandNo: "",
			chkResult: "",
			platformCode: "",
			certificateType: ""
		},
		owner: {
			drvOwner: drvOwner, //行驶证车主
			certiType: "01", //车主证件类型 01身份证
			certiCode: certiCode, //车主证件号码
			certiTel: certiTel //车主电话号码
		},
		riskList: [{
				riskCode: "0301", // 险种代码   0301:交强险、0302:商业险
				insrncBgnTm: insrncBgnTm2 + ":00", //保险起期
				insrncEndTm: "", //保险止期  格式同起期,当不传时默认一年
				effectFlag: "", //即时生效的单子必传,非即时:0、即时:1
				answer: "", //有转保问题时会返回,需输入验证码答案
				electronicInd: "", //电子保单标志  0-否  1-是
				demandNo: "", //投保查询码 1.打回修改再次报价时必传上一次投保查询码; 2.行业车型编码不一致时必传入上一次投保查询码;  3.申请折扣时必传入上一次投保查询码; 4.有转保问题时会返回,直接回传查询码;
				appNo: "", //打回修改的单子重新提交时,上次提单的投保单必传
				calcAppNo: "", //报价单号 1.打回修改再次报价时必传上次提单的报价单;  2.行业车型编码不一致时必传入上一次报价单号;  3.申请折扣时必传入上一次报价单号 4.有转保问题时,必传上一次报价单号.
				tax: {}, //车船税 选择较强险时必传,内容可为空
				coverageList: [{
					number: "", //保障天数/人数 根据具体险别而定(乘客,司机等)
					deductible: "", //车损绝对免赔额 选择车损险时选填,(代码参批注)
					bulletGlass: "", //030107玻璃险需要用到的字段(0 否,1 是)
					amt: "", //保险金额 详细代码见批注(交强险、玻璃险、发动机涉水、修理厂、无法找到第三方不需要传值;车损、盗抢、自燃由保险公司设置为实际车价;其它除批注险别,均由客户填入)
					insrncCode: "BZ", //险别代码  较强险 	BZ
					remark: "", //新增设备险 时 新增设备信息
					franchiseFlag: ""
				}]
			},
			{
				riskCode: "0302", // 险种代码   0301:交强险、0302:商业险
				insrncBgnTm: syinsrncBgnTm + ":00", //保险起期
				insrncEndTm: "", //保险止期  格式同起期,当不传时默认一年
				effectFlag: "", //即时生效的单子必传,非即时:0、即时:1
				answer: "", //有转保问题时会返回,需输入验证码答案
				electronicInd: "", //电子保单标志  0-否  1-是
				demandNo: "", //投保查询码 1.打回修改再次报价时必传上一次投保查询码; 2.行业车型编码不一致时必传入上一次投保查询码;  3.申请折扣时必传入上一次投保查询码; 4.有转保问题时会返回,直接回传查询码;
				appNo: "", //打回修改的单子重新提交时,上次提单的投保单必传
				calcAppNo: "", //报价单号 1.打回修改再次报价时必传上次提单的报价单;  2.行业车型编码不一致时必传入上一次报价单号;  3.申请折扣时必传入上一次报价单号 4.有转保问题时,必传上一次报价单号.
				//tax:{},             //车船税 选择较强险时必传,内容可为空
				coverageList: [{
						number: "", //保障天数/人数 根据具体险别而定(乘客,司机等)
						deductible: "",
						bulletGlass: "",
						amt: vhlVal,
						insrncCode: "030101",
						remark: "",
						franchiseFlag: "1" //不计免赔  0,否;1,是(可投险别见批注)
					},
					{
						number: "", //保障天数/人数 根据具体险别而定(乘客,司机等)
						deductible: "",
						bulletGlass: "",
						amt: "SZ07",
						insrncCode: "030102",
						remark: "",
						franchiseFlag: "1"
					}
				]
			}
		],
		applacation: { //投保人信息
			appName: appName,
			appCertType: "01",
			appCertNo: appCertNo,
			appTel: appTel,
			taxPersonType: "",
			kpType: ""
		},
		insured: { //被保人信息
			insuredName: insuredName,
			insuredCertType: "01",
			insuredCertNo: insuredCertNo,
			insuredTel: insuredTel
		}

	}
	dataJson.riskList[1].coverageList = []
	$.each($(".table_f .xianCheBox"), function(i, e) {
		if (e.checked) {
			var v = this.value
			var franchiseFlag = 1
			if ($(this).parent().next().next().next().next().children()[0].checked) {
				franchiseFlag = "1"
			} else {
				franchiseFlag = "0"
			}
			if (v == "030101" || v == "030103" || v == "030108" || v == "030111" || v == "030115" || v == "030116") {
				var o = new Object();
				o.amt = $(this).parent().next().next().next().html();
				if ($(this).parent().next().next().next().html() == "按规定执行") {
				o.amt = "";
				}
				o.number = "";
				o.deductible = "";

				o.insrncCode = v;
				o.remark = "";
				o.franchiseFlag = franchiseFlag
				dataJson.riskList[1].coverageList.push(o)
			} else if (v == "030107") {
				var o = new Object();
				o.number = "";
				o.deductible = "";
				o.amt = "";
				o.insrncCode = v;
				o.remark = "";
				o.bulletGlass = $(this).parent().next().next().next().children().val();
				o.franchiseFlag = franchiseFlag
				dataJson.riskList[1].coverageList.push(o)
			} else {
				var o = new Object();
				o.number = "";
				o.deductible = "";
				o.amt = $(this).parent().next().next().next().children().val();
				o.insrncCode = v;
				o.remark = "";
				o.franchiseFlag = franchiseFlag
				dataJson.riskList[1].coverageList.push(o)
			}
          console.log(dataJson.riskList[1].coverageList)
		}
	})
	$.ajax({

		//url: "http://120.53.120.7/index.php/sapi/car/premium",
		//url: "http://demo8.xiaochakeji.com/serviceapi/car/premium",
		url: "www.aisigit.com/products/car/premium",
		data: {
			data: JSON.stringify(dataJson)
		},
		type: "post",
		beforeSend: function() {
			$.h.car.load()
		},
		complete: function() {
			$.h.car.disLoad();
		},
		success: function(dd) {
			alert(dd.head.responseMsg)
			if (dd.head.errorCode == "C0000000") {
				$(".scheme .jqPremium").html("¥" + dd.jqBase.jqPremium)
				$(".scheme .sumUpTax").html("¥" + dd.jqBase.tax.sumUpTax)
				$(".scheme .syPremium").html("¥" + dd.syBase.syPremium)
				$(".vhlVal").html(vhlVal)
				var addAllPrice = Number(dd.jqBase.jqPremium) + Number(dd.jqBase.tax.sumUpTax) + Number(dd.syBase.syPremium)
				$(".addAllPrice").html("¥" + addAllPrice)
			}
			console.log(dd)
			var calAppNo = dd.jqBase.jqCalAppNo + "_" + dd.syBase.syCalAppNo
			datalist = {
				calAppNo: calAppNo,
				appName: appName,
				appCertType: "01",
				appCertNo: appCertNo,
				appTel: appTel,
				appAddr: "投保人地址测试",
				appEmail: email,
				insrntName: insuredName,
				insrntCertType: "01",
				insrntCertNo: insuredCertNo,
				insrntTel: insuredTel,
				insrntAddr: "被保人地址测试",
				email: email,
				appntList: []
			}
			console.log(datalist)
		},
		error(v) {
			alert("请求失败,错误代码" + v.status)
		}
	})
	// console.log($(".sanzhe_select").val())
	// console.log(dataJson.riskList[1])
}




//列表展示时间
//右侧 数据分页展示
$(function(){
	var pager = $('#dg').datagrid().datagrid('getPager');	// get the pager of datagrid
})

//搜索按钮
$('#search_btn').bind('click', function() {

	var start = $("#start").val();
	var end = $("#end").val();
	var name = $("#name").val();
	var tel = $("#tel").val();

	var result = {
		start,
		end,
		name,
		tel
	}
	init_datagrid('/products/car/select', result);
});
function init_datagrid(data_url, res) {
	//表头字段
	var arr_columns = dg_columns();

	$("#dg").datagrid({
		rownumbers:true,
		singleSelect:true,
		pagination:true,
		url:data_url,
		queryParams: res,
		method:'post',
		columns: [arr_columns],
		loadMsg: '正在加载数据',
		emptyMsg: '列表为空',
		onDblClickRow :function(rowIndex,rowData){
			showSelectedSurveryDataOnMap(rowData);
		}
	});
}
function dg_columns() {
	var arr = new Array();
	arr.push({
		field: 'drvOwner',
		title: '车主姓名',
		width: 143,
		align: 'center'
	});
	arr.push({
		field: 'certiTel',
		title: '车主电话',
		width: 170,
		align: 'center'
	});
	// console.log(arr)
	return arr;
}


//双击事件
var showSelectedSurveryDataOnMap=function(rowData){
	if(rowData.id){
		$('#bottom').datagrid({
			url:'/products/car/carOrderDetail?id='+rowData.id,
			fit:true,
			fitColumns:true,
			collapsible:true,
			iconCls:'kbi-icon-record',
			singleSelect:true,
			border:false,
			rownumbers:true,
			toolbar:'#tb',
			columns:[[
				{field:'appNo',title:'投保单号',width:225,align:'center'},
				{field:'type',title:'险种类别',width:80,align:'center'},
				{field:'amount',title:'保额',width:80,align:'center'},
				{field:'premium',title:'保费',width:80,align:'center'},
				{field:'insrncStaTm',title:'起保时间',width:180,align:'center'},
				{field:'insrncEndTm',title:'截保时间',width:180,align:'center'},
				{field:'insuredName',title:'投保人',width:130,align:'center'},
				{field:'insuredName',title:'被保人',width:130,align:'center'},
				{field:'status_arr',title:'状态',width:100,align:'center'},
				{field:'number_id', formatter:function(number_id,status,status_arr){
						var btn = '<a class="editcls" onclick="payRow(\''+number_id+'\',\''+status.status+'\',\''+status.status_arr+'\')" href="javascript:void(0)"></a>';
						return btn;
					},title:'操作',width:110,align:'center'},
			] ],
			onLoadSuccess:function(number_id,status,status_arr){
				$('.editcls').linkbutton({text:'支付',plain:true,iconCls:'icon-redo'});
			}
		});
	}
}
//支付申请
function payRow(id,sta,msg) {
//	var msg='';
	if(sta !=7){
		// if(sta >  7){
		// 	msg='订单已支付'
		// }else{
		// 	msg='订单审核还未通过,请稍后重试'
		// }
		$.messager.alert('',msg);


	}else{
		$.ajax({
			url : '/products/car/pay',
			type : 'post',
			async : false,
			data : {id:id},
			success:function(data){
				//console.log(data);
				if(data.head.errorCode == "C0000000"){
					window.open(data.resultInfo.payAddress);
				}else{
					$.messager.alert('',支付申请失败稍后重试);

				}
				//data为后台返回值。我们这里后台返回的是map类型。map.put("latiao":3.5);所以到前台取值方式:
				//var  price=data.latiao;
			},
			error:function() {

			}
		});
	}


}