Перейти к основному содержимому
claw
am
tools
Инструменты
Документы
Daoark
EN
Главная
Главная
/
Calculadora
›
0)) throw new Error('贷款金额必须大于 0'); if (!(annualRate >= 0)) throw new Error('年利率不能为负'); if (!(years >= 1 && years <= 50)) throw new Error('年限需在 1-50 年之间'); var months = years * 12; var monthlyRate = annualRate / 100 / 12; var html = ''; if (method === 'equal_payment') { var M = calcEqualPayment(P, monthlyRate, months); var totalPay = M * months; var totalInterest = totalPay - P; html += '
' + '
' + '
每月月供
¥ ' + fmt(M) + '
' + '
总利息
¥ ' + fmt(totalInterest) + '
' + '
总还款
¥ ' + fmt(totalPay) + '
' + '
'; html += '
' + '
等额本息
: 每月还款额固定 ¥ ' + fmt(M) + ',共 ' + months + ' 期,总利息 ¥ ' + fmt(totalInterest) + '。' + '利息占比 ' + (totalInterest / totalPay * 100).toFixed(1) + '%。' + '
'; } else { var r = calcEqualPrincipalSchedule(P, monthlyRate, months); var totalPay = P + r.totalInterest; var first = r.schedule[0]; var last = r.schedule[r.schedule.length - 1]; html += '
' + '
' + '
首月月供
¥ ' + fmt(first.payment) + '
' + '
末月月供
¥ ' + fmt(last.payment) + '
' + '
总利息
¥ ' + fmt(r.totalInterest) + '
' + '
' + '
总还款: ¥ ' + fmt(totalPay) + ' · 利息占比 ' + (r.totalInterest / totalPay * 100).toFixed(1) + '%
' + '
'; html += '
' + '
首月 vs 末月
: 首月 ¥ ' + fmt(first.payment) + ' (本金 ¥ ' + fmt(first.principal) + ' + 利息 ¥ ' + fmt(first.interest) + ')' + ' · 末月 ¥ ' + fmt(last.payment) + ' (本金 ¥ ' + fmt(last.principal) + ' + 利息 ¥ ' + fmt(last.interest) + ')' + ' · 每月本金固定 ¥ ' + fmt(first.principal) + ',利息逐月递减。' + '
'; html += '
每月还款明细
' + '
期次
月供
本金
利息
剩余本金
'; r.schedule.forEach(function(s) { html += '
' + s.month + '
' + fmt(s.payment) + '
' + fmt(s.principal) + '
' + fmt(s.interest) + '
' + fmt(s.remaining) + '
'; }); html += '
'; } resultMeta.textContent = '方式: ' + (method === 'equal_payment' ? '等额本息' : '等额本金') + ' · 金额 ¥ ' + fmt(P) + ' · 年利率 ' + annualRate + '% · ' + years + ' 年 (' + months + ' 期)'; resultContent.innerHTML = html; resultArea.classList.add('show'); } catch (err) { errorMsg.textContent = '错误: ' + err.message; resultArea.classList.remove('show'); } finally { btnMain.disabled = false; } }); })();