置换
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
function loanCalculat(){
|
||||
|
||||
var loanPrice = $("input[name=loanPrice]").val();
|
||||
if(loanPrice=="" || loanPrice=="0"){
|
||||
$("#price_error").show();
|
||||
return false;
|
||||
}else{
|
||||
$("#price_error").hide();
|
||||
}
|
||||
|
||||
var rate = $("input[name=rate]").val();
|
||||
if(rate=="" || rate=="0"){
|
||||
$("#rate_error").show();
|
||||
return false;
|
||||
}else{
|
||||
$("#rate_error").hide();
|
||||
}
|
||||
|
||||
var repaymentWay = $("select[name=repaymentWay]").val();//贷款方式
|
||||
var amount = parseFloat(loanPrice);//贷款金额
|
||||
var month = parseInt($("select[name=loanMonth]").val());//贷款年限
|
||||
rate = parseFloat(rate);//年利率
|
||||
|
||||
|
||||
if(repaymentWay == "1"){
|
||||
var payMonth = getPayMonth1(amount, month, rate);
|
||||
var totalInterest = getTotalInterest1(payMonth, month, amount);
|
||||
$("#payMonth").html(payMonth.toFixed(3)+"<label>元</label>");
|
||||
$("#interest").html(totalInterest.toFixed(2)+"<label>元</label>");
|
||||
$("#payTotalPrice").html((totalInterest+amount*10000).toFixed(2)+"<label>元</label>");
|
||||
}else if(repaymentWay == "2"){
|
||||
var firstMonthPay = getPayMonth2(amount, month, rate);
|
||||
|
||||
var totalInterest = getTotalInterest2(amount, month, rate);
|
||||
var lessPrice = getLessMonth(amount, month, rate);
|
||||
|
||||
$("#interest").html(totalInterest.toFixed(2)+"<label>元</label>");
|
||||
$("#payTotalPrice").html((totalInterest+amount*10000).toFixed(2)+"<label>元</label>");
|
||||
|
||||
var s = "";
|
||||
for(var i=1;i<=month;i++){
|
||||
if(i!=1){
|
||||
firstMonthPay = firstMonthPay - lessPrice;
|
||||
}
|
||||
s = s + "<p>"+i+"期,"+firstMonthPay.toFixed(2)+"元</p>"
|
||||
}
|
||||
$("#payMonth").html(s);
|
||||
}
|
||||
}
|
||||
|
||||
//每月还款额(等额本息还款法)
|
||||
function getPayMonth1(amount, month, rate) {
|
||||
var monthRate = rate / 1200;
|
||||
var b = Math.pow(1 + monthRate, month) - 1;
|
||||
return amount * 10000 * monthRate * Math.pow(1 + monthRate, month) / b;
|
||||
}
|
||||
|
||||
/**
|
||||
* (等额本息还款法)
|
||||
* 总利息=每月还款额*还款月数-贷款额
|
||||
* payMonth:月供(元)
|
||||
* month:贷款月数
|
||||
* amount:贷款金额(万元)
|
||||
*/
|
||||
function getTotalInterest1(payMonth, month, amount) {
|
||||
return payMonth * month - amount * 10000;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* (等额本金还款法)
|
||||
* 首月还款额=贷款额/还款月数+贷款额*月利率
|
||||
* amount:贷款金额(万元)
|
||||
* month:贷款月数
|
||||
* rate:年利率
|
||||
*/
|
||||
function getPayMonth2(amount, month, rate) {
|
||||
var monthRate = rate / 1200;
|
||||
return amount * 10000 / month + amount * 10000 * monthRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* (等额本金还款法)
|
||||
* 总利息=贷款额*月利率*(还款月数+1)/2
|
||||
* amount:贷款金额(万元)
|
||||
* month:贷款月数
|
||||
* rate:年利率
|
||||
*/
|
||||
function getTotalInterest2(amount, month, rate) {
|
||||
var monthRate = rate / 1200;
|
||||
return amount * 10000 * monthRate * (month + 1) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* (等额本金还款法)
|
||||
* 还款每月递减额=贷款额/还款月数*月利率
|
||||
* amount:贷款金额(万元)
|
||||
* month:贷款月数
|
||||
* rate:年利率
|
||||
*/
|
||||
function getLessMonth(amount, month, rate) {
|
||||
var monthRate = rate / 1200;
|
||||
return amount * 10000 / month * monthRate;
|
||||
}
|
||||
@@ -560,6 +560,7 @@ function loadRentTrends(city, region, name, type){
|
||||
var m = re.times;
|
||||
var pm = re.distMap
|
||||
var rooms = re.rooms;
|
||||
var estateType = re.estateType
|
||||
|
||||
if(m && rooms.length>0){
|
||||
|
||||
@@ -568,6 +569,16 @@ function loadRentTrends(city, region, name, type){
|
||||
}
|
||||
for(var k in rooms){
|
||||
var room = rooms[k]
|
||||
if(estateType && estateType.indexOf("别墅")>-1){
|
||||
if(room > 8){
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
if(room > 5){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
var distM = pm[room];
|
||||
var distObj = new Object();
|
||||
var distDatas = new Array();
|
||||
|
||||
Reference in New Issue
Block a user