//CarCalculator.js

var checkedClass = "jsq-item-check jsq-item-checked";
var uncheckedClass = "jsq-item-check";
var shangPai = ; //格式化前的税价
var taxPriceList = {"shoufu":, "acquisitionTax": ,"jiaoQiangX":,"cheChuanTax":,"commonTotal":,"diSanZheX":,"cheSunShiX":,"buJiX":,"quanCheX":,"boLiX":,"ziRanX":,"engineX":,"cheShenX":,"siJiX":,"chengKeX":,"shangYeXian":,"totalPrice": }; //购置税
function calcAcquisitionTax() {
var acquisitionTax = parseFloat($("#hidCarPrice").val()) / ( + 0.17) * 0.1;
taxPriceList.acquisitionTax = Math.round(acquisitionTax); //四舍五入取整
if (exhaustforfloat == "" || parseFloat(exhaustforfloat) == ) {
taxPriceList.acquisitionTax = ;
$("#gouZhiShuiDesc").text("免征购置税");
} else {
if (parseFloat(exhaustforfloat) <= 1.6) {
var beginTime = new Date('2015/10/01 00:00:00').getTime();
var endTime = new Date('2016/12/31 23:59:59').getTime();
var currentDate = new Date().getTime();
if (currentDate > beginTime && currentDate < endTime) {
taxPriceList.acquisitionTax = Math.round(taxPriceList.acquisitionTax / ); }
$("#gouZhiShuiDesc").text("购置税减半");
}else{
$("#gouZhiShuiDesc").text("");
}
}
acquisitionTax = formatCurrency(taxPriceList.acquisitionTax);
$('#gouZhiShui').html(acquisitionTax);
}
//交强险
var is6ZuoYiXia = true;
function calcCompulsory() {
var content = $("#zuoWeiSDl").find(".current").find("p").text();
if ($("#hidCarPrice").val() == "") {
taxPriceList.jiaoQiangX = ;
$("#jiaoQiangX").html("");
} else {
if (content == "家用6座以下") {
is6ZuoYiXia = true;
taxPriceList.jiaoQiangX = ;
$("#jiaoQiangX").html("");
} else {
is6ZuoYiXia = false;
taxPriceList.jiaoQiangX = ;
$("#jiaoQiangX").html("1,100");
}
}
} //======================车船使用税 start==============================
//车船使用税信息
var vehicleAndVesselTaxInfos = {
: {
Level: ,
MinDisplacement: ,
MaxDisplacement: 1.0,
DisplacementDescription: "1.0L(含)以下",
Tax:
},
: {
Level: ,
MinDisplacement: 1.0,
MaxDisplacement: 1.6,
DisplacementDescription: "1.0-1.6L(含)",
Tax: ,
IsDefault: true
},
: {
Level: ,
MinDisplacement: 1.6,
MaxDisplacement: 2.0,
DisplacementDescription: "1.6-2.0L(含)",
Tax:
},
: {
Level: ,
MinDisplacement: 2.0,
MaxDisplacement: 2.5,
DisplacementDescription: "2.0-2.5L(含)",
Tax:
},
: {
Level: ,
MinDisplacement: 2.5,
MaxDisplacement: 3.0,
DisplacementDescription: "2.5-3.0L(含)",
Tax:
},
: {
Level: ,
MinDisplacement: 3.0,
MaxDisplacement: 4.0,
DisplacementDescription: "3.0-4.0L(含)",
Tax:
},
: {
Level: ,
MinDisplacement: 4.0,
MaxDisplacement: Number.MAX_VALUE,
DisplacementDescription: "4.0L以上",
Tax:
}
}; //根据排量获得车船使用税信息
function GetVehicleAndVesselTaxInfo(dispplacement) {
for (var taxLevel in vehicleAndVesselTaxInfos) {
if (dispplacement > vehicleAndVesselTaxInfos[taxLevel].MinDisplacement
&& dispplacement <= vehicleAndVesselTaxInfos[taxLevel].MaxDisplacement) {
return vehicleAndVesselTaxInfos[taxLevel];
}
}
}
//车船使用税减免信息(免征 减半)
var vehicleAndVesselTaxRelief;
//排量
var exhaustforfloat;
//车船使用税
function CalculateVehicleAndVesselTax() {
if ($("#hidCarPrice").val() == "") {
taxPriceList.cheChuanTax = ;
$('#cheChuanTax').html("");
} else {
var idValue = $("#cheChuanDl").find(".current").find("p").attr("id");
var taxLevel = idValue.substr();
var vehicleAndVesselTaxValue = vehicleAndVesselTaxInfos[taxLevel].Tax;
//车船使用税一般只能缴纳当年的,按月计算
//vehicleAndVesselTaxValue = vehicleAndVesselTaxValue * (12 - new Date().getMonth()) / 12;
//计算车船使用税减免
if (vehicleAndVesselTaxRelief == "免征") {
vehicleAndVesselTaxValue = ;
}
else if (vehicleAndVesselTaxRelief == "减半") {
vehicleAndVesselTaxValue = vehicleAndVesselTaxValue / ;
}
taxPriceList.cheChuanTax = Math.ceil(vehicleAndVesselTaxValue);
vehicleAndVesselTaxValue = formatCurrency(taxPriceList.cheChuanTax);
$('#cheChuanTax').html(vehicleAndVesselTaxValue);
}
}
//======================车船使用税 end============================== //必要花费 小计
function calcEssentialCost() {
var commonTotal = ;
commonTotal += taxPriceList.acquisitionTax;
if (shangPai == ) { //光标在文本框中 backspace也需要实时计算
commonTotal += ;
} else {
commonTotal += shangPai;
}
if (taxPriceList.cheChuanTax == ) { //光标在文本框中 backspace也需要实时计算
commonTotal += ;
} else {
commonTotal += taxPriceList.cheChuanTax;
}
commonTotal += taxPriceList.jiaoQiangX;
taxPriceList.commonTotal = commonTotal;
$("#biYaoHuaFei1").html(formatCurrency(commonTotal));
$("#biYaoHuaFei2").html(formatCurrency(commonTotal));
}
//强制保险小计
function calcQzbx(){
commonTotal = taxPriceList.jiaoQiangX;
$("#qzbx").html(formatCurrency(commonTotal));
} //======================商业险 start==============================
//第三责任险
function calcTPL() {
isDiSanZheXCheck=$("#chkDiSanZheX1").is(':checked');
//var isDiSanZheXCheck = $("#chkDiSanZheX1").attr("checked") == "true";
if ($("#hidCarPrice").val() == "") {
if (isDiSanZheXCheck) {
$("#liDiSanZheX").attr("class", "jsq-item-click");
} else {
$("#liDiSanZheX").attr("class", "");
}
taxPriceList.diSanZheX = ;
$("#diSanZheX").html("");
var idValue1 = $("#diSanZheXDl").find(".current").find("p").attr("id");
idValue1 = idValue1.substr();
switch (idValue1) {
case "":
$("#diSanZhePeiFu").text("赔付5万");
break;
case "":
$("#diSanZhePeiFu").text("赔付10万");
break;
case "":
$("#diSanZhePeiFu").text("赔付20万");
break;
case "":
$("#diSanZhePeiFu").text("赔付50万");
break;
case "":
$("#diSanZhePeiFu").text("赔付100万");
break;
default:
$("#diSanZhePeiFu").text("赔付5万");
break;
} } else {
if (isDiSanZheXCheck) {
var jdata1 = { j5: , j10: , j20: , j50: , j100: };//6座以下
var jdata2 = { j5: , j10: , j20: , j50: , j100: }; //6座及以上
var idValue = $("#diSanZheXDl").find(".current").find("p").attr("id");
idValue = idValue.substr();
var jdata = is6ZuoYiXia ? jdata1 : jdata2;
var reuslt;
switch (idValue) {
case "":
reuslt = jdata["j5"];
$("#diSanZhePeiFu").text("赔付5万");
break;
case "":
reuslt = jdata["j10"];
$("#diSanZhePeiFu").text("赔付10万");
break;
case "":
reuslt = jdata["j20"];
$("#diSanZhePeiFu").text("赔付20万");
break;
case "":
reuslt = jdata["j50"];
$("#diSanZhePeiFu").text("赔付50万");
break;
case "":
reuslt = jdata["j100"];
$("#diSanZhePeiFu").text("赔付100万");
break;
default:
reuslt = jdata["j5"];
$("#diSanZhePeiFu").text("赔付5万");
break;
}
taxPriceList.diSanZheX = reuslt;
$("#diSanZheX").html(formatCurrency(reuslt));
$("#liDiSanZheX").attr("class", "jsq-item-click");
$("#liBuJiX").attr("class", "");
} else {
taxPriceList.diSanZheX = ;
$("#diSanZheX").html("");
$("#liDiSanZheX").attr("class", "");
}
}
}
//车辆损失险
function calcCarDamage() {
isCheSunShiXCheck=$("#chkCheSunShiX1").is(':checked');
if ($("#hidCarPrice").val() == "") {
taxPriceList.cheSunShiX = ;
$('#cheSunShiX').html("");
} else {
if (isCheSunShiXCheck) {
var rate = 0.0095;
var baseCost = ;
//没选车
if (parseInt($("#hidCarID").val()) <= ) {
if (!is6ZuoYiXia) { //6座及以上
rate = 0.009;
baseCost = ;
}
} else { //选车
var seatNum = $("#hidSeatNum").val();
if (!is6ZuoYiXia) { //6座及以上
if (seatNum >= && seatNum < ) {
rate = 0.009;
baseCost = ;
} else if (seatNum >= && seatNum < ) {
rate = 0.0095;
baseCost = ;
} else if (seatNum >= ) {
rate = 0.0095;
baseCost = ;
} else { //车本身座位数小于6 但又选择了6座以上
rate = 0.009;
baseCost = ;
}
}
}
var result = Math.round(parseInt($("#hidCarPrice").val()) * rate + baseCost);
taxPriceList.cheSunShiX = result;
$("#cheSunShiX").html(formatCurrency(result));
} else {
taxPriceList.cheSunShiX = ;
$('#cheSunShiX').html("");
}
}
}
//不计免赔特约险
function calcAbatement() {
var isSunShiCheck = $("#chkCheSunShiX1").is(':checked');
var isDiSanZheCheck =$("#chkDiSanZheX1").is(':checked');
var isBuJiCheck = $("#chkBuJiX1").is(':checked');
if ($("#hidCarPrice").val() == "") {
if (isSunShiCheck && isDiSanZheCheck) {
$("#liBuJiX").attr("class", "");
} else {
$('#chkBuJiX1').attr("checked",false);
$("#liBuJiX").attr("class", "jsq-item-click-gray");
}
taxPriceList.buJiX = ;
$('#chkBuJiX1').attr("checked", false);
$("#buJiX").html("");
} else {
if (isSunShiCheck && isDiSanZheCheck) {
$("#liBuJiX").attr("class", "");
if (isBuJiCheck) {
var total = taxPriceList.cheSunShiX + taxPriceList.diSanZheX;
total = Math.round(total * 0.2);
taxPriceList.buJiX = total;
$("#buJiX").html(formatCurrency(total));
} else {
$('#chkBuJiX1').attr("checked", false);
taxPriceList.buJiX = ;
$("#buJiX").html("");
}
}
else {
$('#chkBuJiX1').attr("checked",false);
taxPriceList.buJiX = ;
$("#buJiX").html("");
$("#liBuJiX").attr("class", "jsq-item-click-gray");
}
}
}
//全车盗抢险
function calcCarTheft() {
var isQuanCheX = $('#chkQuanCheX1').is(':checked');
var isCheSunShiX = $("#chkCheSunShiX1").is(':checked'); if ($("#hidCarPrice").val() == "") {
if (isCheSunShiX) {
$("#liQuanCheX").attr("class", "");
} else {
$('#chkQuanCheX1').attr("checked",false);
$("#liQuanCheX").attr("class", "jsq-item-click-gray");
} taxPriceList.quanCheX = ;
$("#quanCheX").html("");
} else {
if (isCheSunShiX) {
$("#liQuanCheX").attr("class", "");
if (isQuanCheX) {
if (!is6ZuoYiXia) //6座及以上
{
var result = Math.round(parseInt($("#hidCarPrice").val()) * 0.0044 + );
taxPriceList.quanCheX = result;
$("#quanCheX").html(formatCurrency(result));
} else {
var total = Math.round(parseInt($("#hidCarPrice").val()) * 0.0049 + );
taxPriceList.quanCheX = total;
$("#quanCheX").html(formatCurrency(total));
}
} else {
taxPriceList.quanCheX = ;
$("#quanCheX").html("");
}
} else {
$('#chkQuanCheX1').attr("checked",false);
taxPriceList.quanCheX = ;
$("#quanCheX").html("");
$("#liQuanCheX").attr("class", "jsq-item-click-gray");
}
}
}
//玻璃单独破碎险
function calcBreakageOfGlass() {
var isSunShiXCheck = $("#chkCheSunShiX1").is(':checked');
var isBoLiXCheck = $("#chkBoLiX1").is(':checked'); if ($("#hidCarPrice").val() == "") {
if (isSunShiXCheck) {
if (isBoLiXCheck) {
$("#liBoLiX").attr("class", "jsq-item-click");
} else {
$("#liBoLiX").attr("class", "");
}
} else {
$('#chkBoLiX1').attr("checked",false);
$("#liBoLiX").attr("class", "jsq-item-click-gray");
}
taxPriceList.boLiX = ;
$("#boLiX").html("");
var content1 = $("#boLiXDl").find(".current").find("p").text();
if (content1 == "进口")//进口
{
$("#boLiPeiFu").text("进口玻璃");
}
if (content1 == "国产")//国产
{
$("#boLiPeiFu").text("国产玻璃");
}
} else {
if (isSunShiXCheck) {
if (isBoLiXCheck) {
$("#liBoLiX").attr("class", "jsq-item-click");
var content = $("#boLiXDl").find(".current").find("p").text();
if (content == "进口")//进口
{
$("#boLiPeiFu").text("进口玻璃");
if (!is6ZuoYiXia) { //6-10座客车
taxPriceList.boLiX = Math.round(parseInt($("#hidCarPrice").val()) * 0.003);
$("#boLiX").html(formatCurrency(taxPriceList.boLiX));
} else {
taxPriceList.boLiX = Math.round(parseInt($("#hidCarPrice").val()) * 0.0031);
$("#boLiX").html(formatCurrency(taxPriceList.boLiX));
}
}
if (content == "国产")//国产
{
$("#boLiPeiFu").text("国产玻璃");
taxPriceList.boLiX = Math.round(parseInt($("#hidCarPrice").val()) * 0.0019);
$("#boLiX").html(formatCurrency(taxPriceList.boLiX));
}
} else {
taxPriceList.boLiX = ;
$("#liBoLiX").attr("class", "");
$("#boLiX").html("");
}
} else {
$('#chkBoLiX1').attr("checked",false);
taxPriceList.boLiX = ;
$("#boLiX").html("");
$("#liBoLiX").attr("class", "jsq-item-click-gray");
}
}
} //自燃损失险
function calcSelfignite() {
if ($("#hidCarPrice").val() == "") {
taxPriceList.ziRanX = ;
$("#ziRanX").html("");
} else {
var isZiRanCheck = $("#chkZiRanX1").is(':checked');
if (!isZiRanCheck) {
taxPriceList.ziRanX = ;
$("#ziRanX").html("");
$("#liZiRanX").attr("class", "");
} else {
taxPriceList.ziRanX = Math.round(parseInt($("#hidCarPrice").val()) * 0.0015);
$('#ziRanX').html(formatCurrency(taxPriceList.ziRanX));
$("#liZiRanX").attr("class", "");
}
}
} //发动机特别损失险(车损险*5%)
function calcCarEngineDamage() {
var isEngineXCheck = $("#chkEngineX1").is(':checked');
var isSunShiXCheck = $("#chkCheSunShiX1").is(':checked'); if ($("#hidCarPrice").val() == "") {
if (isSunShiXCheck) {
$("#liEngineX").attr("class", "");
} else {
$("#chkEngineX1").attr("checked",false);
$("#liEngineX").attr("class", "jsq-item-click-gray");
}
taxPriceList.engineX = ;
$("#engineX").html("");
} else {
if (isSunShiXCheck) {
$("#liEngineX").attr("class", "");
if (isEngineXCheck) {
var cDamage = taxPriceList.cheSunShiX * 0.05;
taxPriceList.engineX = Math.round(cDamage);
$("#engineX").html(formatCurrency(taxPriceList.engineX));
} else {
taxPriceList.engineX = ;
$("#engineX").html("");
}
} else {
$("#chkEngineX1").attr("checked",false);
taxPriceList.engineX = ;
$("#engineX").html("");
$("#liEngineX").attr("class", "jsq-item-click-gray");
}
}
} //车身划痕险
function calcCarDamageDW() {
var isSunShiXCheck = $("#chkCheSunShiX1").is(':checked');
var isCheShenXCheck = $("#chkCheShenX1").is(':checked');
if ($("#hidCarPrice").val() == "") {
if (isSunShiXCheck) {
if (isCheShenXCheck) {
$("#liCheShenX").attr("class", "jsq-item-click");
} else {
$("#liCheShenX").attr("class", "");
}
} else {
$('#chkCheShenX1').attr("checked",false);
$("#liCheShenX").attr("class", "jsq-item-click-gray");
}
taxPriceList.cheShenX = ;
$("#cheShenX").html("");
var vv = $("#cheShenXDl").find(".current").find("p").attr("id");
vv = vv.substr();
switch (vv) {
case "":
$("#cheShenPeiFu").text("赔付2千");
break;
case "":
$("#cheShenPeiFu").text("赔付5千");
break;
case "":
$("#cheShenPeiFu").text("赔付1万");
break;
case "":
$("#cheShenPeiFu").text("赔付2万");
break;
default:
break;
}
} else {
if (isSunShiXCheck) {
if (isCheShenXCheck) {
$("#liCheShenX").attr("class", "jsq-item-click");
var jdata1 = { j2000: , j5000: , j10000: , j20000: };
var jdata2 = { j2000: , j5000: , j10000: , j20000: };
var jdata3 = { j2000: , j5000: , j10000: , j20000: }; var money = parseInt($("#hidCarPrice").val());
var jdata;
if (money < ) {
jdata = jdata1;
} else if (money > ) {
jdata = jdata2;
} else {
jdata = jdata3;
}
var result = ;
var v = $("#cheShenXDl").find(".current").find("p").attr("id");
v = v.substr();
switch (v) {
case "":
$("#cheShenPeiFu").text("赔付2千");
result = jdata["j2000"];
break;
case "":
$("#cheShenPeiFu").text("赔付5千");
result = jdata["j5000"];
break;
case "":
$("#cheShenPeiFu").text("赔付1万");
result = jdata["j10000"];
break;
case "":
$("#cheShenPeiFu").text("赔付2万");
result = jdata["j20000"];
break;
default:
break;
}
taxPriceList.cheShenX = result;
$("#cheShenX").html(formatCurrency(result));
} else {
taxPriceList.cheShenX = ;
$("#liCheShenX").attr("class", "");
$("#cheShenX").html("");
}
} else {
$('#chkCheShenX1').attr("checked",false);
taxPriceList.cheShenX = ;
$("#cheShenX").html("");
$("#liCheShenX").attr("class", "jsq-item-click-gray");
}
}
} //司机责任险
function calcLimitofDriver() {
var isSiJiXCheck = $("#chkSiJiX1").is(':checked');
if ($("#hidCarPrice").val() == "") {
if (isSiJiXCheck) {
$("#liSiJiX").attr("class", "jsq-item-click");
} else {
$("#liSiJiX").attr("class", "");
}
taxPriceList.siJiX = ;
$("#siJiX").html("");
var idValue1 = $("#siJiXDl").find(".current").find("p").attr("id");
idValue1 = idValue1.substr();
switch (idValue1) {
case "":
$("#sijiPeiFu").text("赔付1万");
break;
case "":
$("#sijiPeiFu").text("赔付2万");
break;
case "":
$("#sijiPeiFu").text("赔付3万");
break;
case "":
$("#sijiPeiFu").text("赔付4万");
break;
case "":
$("#sijiPeiFu").text("赔付5万");
break;
default:
break;
}
} else {
if (isSiJiXCheck) {
var idValue = $("#siJiXDl").find(".current").find("p").attr("id");
idValue = idValue.substr();
switch (idValue) {
case "":
$("#sijiPeiFu").text("赔付1万");
break;
case "":
$("#sijiPeiFu").text("赔付2万");
break;
case "":
$("#sijiPeiFu").text("赔付3万");
break;
case "":
$("#sijiPeiFu").text("赔付4万");
break;
case "":
$("#sijiPeiFu").text("赔付5万");
break;
default:
break;
}
if (is6ZuoYiXia) { //6座以下
//所选金额*费率*(座位数-1)。如果没有座位数,则*4
taxPriceList.siJiX = Math.round(idValue * 0.0042);
$("#siJiX").html(formatCurrency(taxPriceList.siJiX));
} else {
taxPriceList.siJiX = Math.round(idValue * 0.004);
$("#siJiX").html(formatCurrency(taxPriceList.siJiX));
}
$("#liSiJiX").attr("class", "jsq-item-click");
} else {
taxPriceList.siJiX = ;
$("#siJiX").html("");
$("#liSiJiX").attr("class", "");
}
}
} //乘客责任险(//所选金额*费率*(座位数-1)。如果没有座位数,则*4)
function calcLimitofPassenger() {
var isChengKeXCheck = $("#chkChengKeX1").is(':checked');
if ($("#hidCarPrice").val() == "") {
if (isChengKeXCheck) {
$("#liChengKeX").attr("class", "jsq-item-click");
} else {
$("#liChengKeX").attr("class", "");
}
taxPriceList.chengKeX = ;
$("#chengKeX").html("");
var idValue1 = $("#chengKeXDl").find(".current").find("p").attr("id");
idValue1 = idValue1.substr();
switch (idValue1) {
case "":
$("#chengkePeiFu").text("赔付1万");
break;
case "":
$("#chengkePeiFu").text("赔付2万");
break;
case "":
$("#chengkePeiFu").text("赔付3万");
break;
case "":
$("#chengkePeiFu").text("赔付4万");
break;
case "":
$("#chengkePeiFu").text("赔付5万");
break;
default:
break;
}
} else { if (isChengKeXCheck) {
var idValue = $("#chengKeXDl").find(".current").find("p").attr("id");
idValue = idValue.substr();
switch (idValue) {
case "":
$("#chengkePeiFu").text("赔付1万");
break;
case "":
$("#chengkePeiFu").text("赔付2万");
break;
case "":
$("#chengkePeiFu").text("赔付3万");
break;
case "":
$("#chengkePeiFu").text("赔付4万");
break;
case "":
$("#chengkePeiFu").text("赔付5万");
break;
default:
break;
}
var seatNum = $("#hidSeatNum").val();
var calCount;
if (seatNum < ) { //小于四座看做没有座位数
calCount = ;
} else {
calCount = seatNum - ;
}
if (is6ZuoYiXia) { //6座以下
taxPriceList.chengKeX = Math.round(idValue * 0.0027 * calCount);
$("#chengKeX").html(formatCurrency(taxPriceList.chengKeX));
} else {
taxPriceList.chengKeX = Math.round(idValue * 0.0026 * calCount);
$("#chengKeX").html(formatCurrency(taxPriceList.chengKeX));
}
$("#liChengKeX").attr("class", "jsq-item-click");
} else {
taxPriceList.chengKeX = ;
$("#chengKeX").html("");
$("#liChengKeX").attr("class", "");
}
}
} //商业保险小计
function calcCommonTotal() {
var commonTotal = ;
if ($("#chkDiSanZheX1").is(':checked') == true) {
commonTotal += taxPriceList.diSanZheX;
}
if ($("#chkCheSunShiX1").is(':checked') == true) {
commonTotal += taxPriceList.cheSunShiX;
}
if ($("#chkBuJiX1").is(':checked') == true) {
commonTotal += taxPriceList.buJiX;
}
if ($("#chkQuanCheX1").is(':checked') == true) {
commonTotal += taxPriceList.quanCheX;
}
if ($("#chkBoLiX1").is(':checked') == true) {
commonTotal += taxPriceList.boLiX;
}
if ($("#chkZiRanX1").is(':checked') == true) {
commonTotal += taxPriceList.ziRanX;
}
if ($("#chkEngineX1").is(':checked') == true) {
commonTotal += taxPriceList.engineX;
}
if ($("#chkCheShenX1").is(':checked') == true) {
commonTotal += taxPriceList.cheShenX;
}
if ($("#chkSiJiX1").is(':checked') == true) {
commonTotal += taxPriceList.siJiX;
}
if ($("#chkChengKeX1").is(':checked') == true) {
commonTotal += taxPriceList.chengKeX;
}
taxPriceList.shangYeXian = Math.round(commonTotal);
$("#shangYeXian1").html(formatCurrency(taxPriceList.shangYeXian));
$("#shangYeXian2").html(formatCurrency(taxPriceList.shangYeXian));
} //======================商业险 end==============================
//计算全款
function calcTotal() {
taxPriceList.totalPrice = parseInt($("#hidCarPrice").val()) + taxPriceList.commonTotal + taxPriceList.shangYeXian;
$("#totalPrice").html(formatCurrency(taxPriceList.totalPrice));
if ($("#totalPriceLayer")) {
$("#totalPriceLayer").html(formatCurrency(taxPriceList.totalPrice));
}
if ($("#totalPriceBottom")) {
$("#totalPriceBottom").html(formatCurrency(taxPriceList.totalPrice));
}
} //检查车价格
function checkMoneyValidation() {
var money = $('#luochePrice2').val();
if (isNaN(money)) {
alert("请输入数字!");
$('#luochePrice2').val("").focus();
return false;
}
if (parseInt(money) == || money == "") {
return false;
}
if (parseInt(money) != && (parseInt(money) < || parseInt(money) > )) {
alert("请输入正确的价格!");
$('#luochePrice2').val("").focus();
return false;
}
return true;
} function GetCarInfo(model_id) {
$.ajax({
url:"pz",
type:"POST",
data:{"model_id":model_id},
dataType:"json",
success:function(datad){
console.log(datad);
seatNum=""; //座位数
exhaustforfloat=""; //排气量
for(i in datad){
if(datad[i].name === "座位数(个)"){
seatNum= datad[i].value;
}else if(datad[i].name==="排量(mL)"){
exhaustforfloat=datad[i].value/;
}else{
continue;
}
}
//alert(exhaustforfloat);
//alert(seatNum);
//alert(seatNum.substring(seatNum.indexOf('-')+1));
seatNum=seatNum.toString();
if(seatNum.indexOf('-') !=-){
seatNum=seatNum.substring(seatNum.indexOf('-')+);
}
//座位数
$("#hidSeatNum").val(seatNum);
//alert($("#hidSeatNum").val());
if (seatNum != "" && seatNum >= ) {
$("#zuoWeiSDl dd").attr("class", "");
$("#zuoWeiSDl dd").eq().attr("class", "current");
$("#zuoWeiSDl dd a").attr("style", "");
$(".current").find("a").attr("style","color:#3b5998;");
calcCompulsory();
}else{
$("#zuoWeiSDl dd").attr("class", "");
$("#zuoWeiSDl dd").eq().attr("class", "current");
$("#zuoWeiSDl dd a").attr("style", "");
$(".current").find("a").attr("style","color:#3b5998;");
calcCompulsory();
}
//根据排量选择车船税的级别
var vehicleAndVesselTaxInfo = GetVehicleAndVesselTaxInfo(exhaustforfloat);
//alert(vehicleAndVesselTaxInfo);
if (typeof vehicleAndVesselTaxInfo != "undefined") {
$("#cheChuanDl dd").attr("class", "");
$("#cheChuanDl dd").eq(vehicleAndVesselTaxInfo.Level-).attr("class", "current");
$("#cheChuanDl dd a").attr("style", "");
$(".current").find("a").attr("style","color:#3b5998;");
CalculateVehicleAndVesselTax();
}
calcEssentialCost();
//车船使用税减免信息
//vehicleAndVesselTaxRelief = json.traveltax;
//玻璃是否国产
$.getJSON('http://cardb.test.chelintong.com/rest-api/v1/models/'+model_id+'?expand=manufacturerTxt', function (data1) {
//alert(data.manufacturerTxt);
//是否国产
$.getJSON('http://cardb.test.chelintong.com/rest-api/v1/manufacturers/'+data1.manufacturer_id, function (data2) {
if (data2.type_id ==) {
$("#boLiXDl dd").attr("class", "");
$("#boLiXDl dd").eq().attr("class", "current");
$("#boLiXDl dd a").attr("style", "");
$(".current").find("a").attr("style","color:#3b5998;");
calcBreakageOfGlass();
} else {
$("#boLiXDl dd").attr("class", "");
$("#boLiXDl dd").eq().attr("class", "current");
$("#boLiXDl dd a").attr("style", "");
$(".current").find("a").attr("style","color:#3b5998;");
calcBreakageOfGlass();
}
});
});
}
});
} //==========================通用方法=================================
//4.784->4784
function GetIntValue(num) {
num = num.toString().replace(/\,/g, '');
return parseInt(num);
}
//格式化字符串占位符
function formatString() {
if (arguments.length == )
return null;
var str = arguments[];
var obj = arguments[];
for (var key in obj) {
var re = new RegExp('\\{' + key + '\\}', 'gi');
str = str.replace(re, obj[key]);
}
return str;
}
//格式化千位符(6701->6,701)
function formatCurrency(num) {
if (num == null || num == undefined) return "";
num = num.toString().replace(/\$|\,/g, '');
if (isNaN(num)) num = "";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num * + 0.50000000001);
num = Math.floor(num / ).toString();
for (var i = ; i < Math.floor((num.length - ( + i)) / ); i++)
num = num.substring(, num.length - ( * i + )) + ',' + num.substring(num.length - ( * i + ));
return (((sign) ? '' : '-') + num);
} function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr().match(reg);
if (r != null) return unescape(r[]); return null;
} //==========================汽车贷款=================================
//首付款:首付金额+必要花费+商业保险 首付金额=购车价格×首付比例
function calcDownPayments() {
var shoufu = $("#shoufuDiv a.current").eq().html().trim();
var result = ;
switch (shoufu) {
case "30%": result = 0.3; break;
case "40%": result = 0.4; break;
case "50%": result = 0.5; break;
case "60%": result = 0.6; break;
default: break;
}
taxPriceList.shoufu = Math.round(parseInt($("#hidCarPrice").val()) * result);
var shoufuTotal = formatCurrency(taxPriceList.shoufu + taxPriceList.commonTotal + taxPriceList.shangYeXian);
//$("#shoufu").html(shoufuTotal);
$("#shoufuLayer").html(shoufuTotal);
$("#shoufuBottom").html(shoufuTotal);
}
//贷款额
function calcLoanValue() {
var years = parseInt($("#yearDiv a.current").eq().html().trim());
var loanMonths = years * ;
$("#yueShuLayer").text(loanMonths);
$("#yueShuBottom").text(loanMonths);
if (!isHaveLoanRate) {
switch (years) {
case :
$("#loanRate").attr("value", "6.31");
break;
case :
case :
$("#loanRate").attr("value", "6.4");
break;
case :
case :
$("#loanRate").attr("value", "6.65");
break;
default:
break;
}
}
}
//贷款购车总花费 首付款+贷款所花总钱数
//贷款所花总钱数=月付款×还款年限×12
//比全款购车多花费=贷款所花总钱数+首付金额-裸车价格。
function calcLoanTotal() {
var moneyMonthPayments = GetIntValue($("#yueShuLayer").html()) *GetIntValue($("#yueGongLayer").html());
var totolCost = Math.round(GetIntValue($("#shoufuLayer").html()) + moneyMonthPayments);
$("#totalPrice").html(formatCurrency(totolCost) + "<span>元</span>");
$("#totalPriceLayer").html(formatCurrency(totolCost));
$("#totalPriceBottom").html(formatCurrency(totolCost));
}
//月供
function calcMonthPayments() {
var loanMonths = parseInt($("#yueShuLayer").text());
var loanRate = $("#loanRate").val();
var yearRate = loanRate / ;
var monthPercent = yearRate / ;
var loanValue = parseInt($("#hidCarPrice").val()) - taxPriceList.shoufu;
var fenzi = loanValue * monthPercent * Math.pow(( + monthPercent), loanMonths);
var fenmu = (Math.pow(( + monthPercent), loanMonths) - );
var result = ;
if (fenmu != ) {
result = Math.round(fenzi / fenmu);
}
//$("#yueGong").text(formatCurrency(result));
$("#yueGongLayer").text(formatCurrency(result));
$("#yueGongBottom").text(formatCurrency(result)); //利息 月供*月数-贷款金额
var lixi = result * loanMonths - loanValue;
//$("#liXi").text(formatCurrency(lixi));
$("#liXiLayer").text(formatCurrency(lixi));
$("#liXiBottom").text(formatCurrency(lixi));
} //=========================保险=====================================
//官方指导价
function calcCompany() {
var companyTotal = taxPriceList.jiaoQiangX + taxPriceList.shangYeXian;
$("#guanFangPrice").html(formatCurrency(companyTotal));
}
//计算市场报价
function calcMarket() {
var marketTotal = taxPriceList.jiaoQiangX + (taxPriceList.shangYeXian * 0.9);
marketTotal = Math.round(marketTotal);
$("#totalPriceLayer").html(formatCurrency(marketTotal));
$("#totalPriceBottom").html(formatCurrency(marketTotal));
//$("#marketPrice").html(formatCurrency(marketTotal));
//$("#marketPrice1").html(formatCurrency(marketTotal));
}

最新文章

  1. Java final 修饰符知识点总结
  2. JS之mouseover和mouseenter
  3. form表单中控件较多,加载完成后切换页面都很慢的解决方法
  4. 报错:org.apache.jasper.JasperException: /index.jsp (line: 1, column: 17) equal symbol expected
  5. 团队开发——SCRUM报告(一)
  6. Eclipse 下如何引用另一个项目的Java文件
  7. 一个类搞定UIScrollView那些事
  8. hdu 5402 Travelling Salesman Problem(大模拟)
  9. php 通过referer防盗链(以图片为例)
  10. 使用IntelliLock加密授权你的.Net程序
  11. 用PhotoSwipe制作相册,手势可放大
  12. CodeForces 622C Not Equal on a Segment
  13. 项目实战12.1—企业级监控工具应用实战-zabbix安装与基础操作
  14. Git版本管理的简介与安装[一]
  15. 支持向量机(SVM)
  16. PAT甲题题解-1051. Pop Sequence (25)-堆栈
  17. Sketch 使用中文字体
  18. iText7生成pdf
  19. node初识——node中的require方法与require.js的区别
  20. win7卸载打印机驱动

热门文章

  1. 三天的Python课程
  2. 转专业后对于C语言补修的一些体会(1)
  3. 一、json与jsonp的使用
  4. centos7搭建hadoop2.10完全分布式
  5. sqllab less-1
  6. UIKeyWindow的设置
  7. Python 中命令行参数解析工具 docopt 安装和应用
  8. async处理异步操作
  9. 第1节 Scala基础语法:3、环境;4、插件
  10. 使用 TestFight 构建 Beta 测试版本