function loan_calc(bj, year, rate) {
    //贷款总额
    var loan_ceiling = bj * 10000;
    //贷款期限
    var loan_period = year * 12;
    var number_of_month = loan_period;
    //贷款利率
    var loan_rate = rate / 100 / 12;
    //公式需要
    var _rate = Math.pow(1 + loan_rate, loan_period);
    //等额本息月供
    var acpi_monthly_payment = (loan_ceiling * loan_rate * _rate) / (_rate - 1);
    var acpi_interest = loan_period * acpi_monthly_payment - loan_ceiling;
    //等额本金计算
    var em = loan_ceiling / loan_period;
    var nbj = loan_ceiling;
    var i = 0;
    var ac_interest = 0;
    var ac_monthly_payment = [];
    for (; loan_period > 0; loan_period--) {
        var interest = (loan_ceiling - i * em) * loan_rate;
        ac_interest += interest;
        ac_monthly_payment.push(em + interest);
        i++;
        nbj -= em;
    }

    return {
        //等额本息
        acpi: {
            interest: acpi_interest,
            monthlyPayment: acpi_monthly_payment
        },
        //等额本金
        ac: {
            interest: ac_interest,
            monthlyPayment: ac_monthly_payment
        },
        loan_period: number_of_month,
        loan_ceiling: bj
    }
}


/*
 等额本息 Average Capital Plus Interest
 等额本金 average capital
 利息 interest
 还款总额：Total repayment
 {ACPI:{interest, MonthlyPayment},
 AC：[],
 interest：
 loan_period：月
 totalPayment}*/
