let money = 10000; // 贷款本金
let periods = 12; // 期数
let yearInterest = 18; // 年率
let month = null; // 月率
let monthInterest = null; // 每月偿还本息
let resultArr = []; // 每月偿还利息
let resultMoneyArr = []; // 每月偿还本金
let monthMoney = []; // 每月剩余本金
// 月率
month = parseInt(yearInterest, 10) / 100 / 12;
// 公式 贷款本金×月利率×(1+月利率)^还款月数〕÷〔(1+月利率)^还款月数 - 1〕
let repayMonthPow = Math.pow((1 + month), periods);
monthInterest = ((money * month * repayMonthPow)/(repayMonthPow-1)).toFixed(2);
// 每月偿还本息
let _money = money;
for(let i = 0, len = periods; i <len; i++) {
_money-=(monthInterest - (_money * month));
monthMoney.push(parseFloat(_money.toFixed(2)));
}
// 每月偿还利息
resultArr = monthMoney.map((value) => {