//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));
}

车林通购车之家--购车计算器模块--算法js的更多相关文章

  1. 车林通购车之家--购车计算器模块js实现

    //jsq-nav.twig <ul class="switch-nav db-tags bgfff clearfix"> <li id="qk&quo ...

  2. 编写计算器程序学习JS责任链模式

    设计模式中的责任链模式能够很好的处理程序过程的逻辑判断,提高程序可读性. 责任链模式的核心在于责任链上的元素判断能够处理该数据,不能处理的话直接交给它的后继者. 计算器的基本样式: 通过div+css ...

  3. PID算法通俗理解,平衡车,倒立摆,适合不理解PID算法的人来看!

    先插句广告,本人QQ522414928,不熟悉PID算法的可以一起交流学习,随时在线(PID资料再我的另一篇博客里) 倒立摆资料连接↓ https://www.cnblogs.com/LiuXinyu ...

  4. bzoj2242: [SDOI2011]计算器 && BSGS 算法

    BSGS算法 给定y.z.p,计算满足yx mod p=z的最小非负整数x.p为质数(没法写数学公式,以下内容用心去感受吧) 设 x = i*m + j. 则 y^(j)≡z∗y^(-i*m)) (m ...

  5. bzoj 2242: [SDOI2011]计算器 & BSGS算法笔记

    这题的主要难点在于第三问该如何解决 于是就要知道BSGS是怎样的一种方法了 首先BSGS是meet in the middle的一种(戳下面看) http://m.blog.csdn.net/blog ...

  6. uniapp vue 购车计算器,贷款计算器,保险计算器

    基于vue开发的买车计算器,支持uniapp 概述 项目为工作中开发,感觉比较有意思,而且能够帮助其他人快速开发功能,我就发上来了,大佬勿喷吧,没什么技术含量! uniapp打包多端[小程序类]可能会 ...

  7. 非科班双非本科投的337家Java后台(励志)

    考试结束,班级平均分只拿到了年级第二,班主任于是问道:大家都知道世界第一高峰珠穆朗玛峰,有人知道世界第二高峰是什么吗?正当班主任要继续发话,只听到角落默默想起来一个声音:”乔戈里峰” 前言 文章出自h ...

  8. 爬虫实战:汽车之家配置页面 破解伪元素和混淆JS

    本篇介绍如何破解汽车之家配置页面的伪元素和混淆的JS. ** 温馨提示:如需转载本文,请注明内容出处.** 本文链接:https://www.cnblogs.com/grom/p/9242156.ht ...

  9. 最新 物易云通java校招面经 (含整理过的面试题大全)

    从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.物易云通等10家互联网公司的校招Offer,因为某些自身原因最终选择了物易云通.6.7月主要是做系统复习.项目复盘.Leet ...

随机推荐

  1. 《Web安全攻防 渗透测试实战指南》 学习笔记 (四)

    Web安全攻防 渗透测试实战指南   学习笔记 (四) Nmap                                       Network  Mapper    是一款开放源代码的网 ...

  2. juypter

    juypter 1.      jupyter 1.1.    它是什么? Jupyter Notebooks 是一款开源的网络应用,我们可以将其用于创建和共享代码与文档. 以前叫ipython no ...

  3. 吴裕雄 python 神经网络——TensorFlow 实现LeNet-5模型处理MNIST手写数据集

    import os import numpy as np import tensorflow as tf from tensorflow.examples.tutorials.mnist import ...

  4. mysql数据库关系表设计原则

    三范式https://blog.csdn.net/qq_36432666/article/details/78934073 https://kb.cnblogs.com/page/138526/ ht ...

  5. Python基础语法笔记2

    ------------------------------------------------------------------------------- 常量和Pylint的规范 1.常量:常量 ...

  6. 秋招落幕,对自己的总结by2018-10-20

    在今天阿里沟通offer完毕,正式三方也确定了,一切如梦,想想1月的自己还担心未来的自己会花落谁家,到10月的今天,一切尘埃落地.一直不怎么喜欢总结自己的历程,今天无聊的我也总结一波吧. 准确的说没有 ...

  7. CSRF预防手段

    1 referer 验证 2 token 验证

  8. Python3.5学习之旅——day4

    本节内容 1.装饰器 2.迭代器与生成器 3.内置方法 4.软件目录结构规范 一.装饰器 装饰器是一个用来装饰其他函数的工具,即为其他函数添加附加功能,其本质就是函数. 装饰器需要遵循的以下两个原则: ...

  9. python pandas模块简单使用(读取excel为例)

    第一步:模块安装 pip install pandas 第二步:使用(单个工作表为例) 说明:如果有多个工作表,那么只要指定sheetname=索引,(第一个工作表为0,第二个工作表为1,以此类推) ...

  10. [转]Shell编程

    原文链接 Shell编程其实真的很简单(一) 如今,不会Linux的程序员都不意思说自己是程序员,而不会shell编程就不能说自己会Linux.说起来似乎shell编程很屌啊,然而不用担心,其实she ...