u013882314
天空簋云
采纳率100%
2021-03-22 11:03

小程序中贷款计算器中先息后本还款方式,显示明细代码怎么实现,看一下公式怎么写

/**
 * 每月还息到期还本
 * @param {*贷款总额} total
 * @param {*还款月数} months
 * @param {*月利率} monthRate
 */
const equalPrincipall = (total, months, monthRate) => {
    // 每月月供额 = 每月应还利息   
    // 每月应还本金 = 0     
    // 每月应还利息 = 贷款总额 × 月利率  
    let interest = total * monthRate;   //本期利息
    //let principal =interest/monthRate;   //本期本金
      let monthlyPayment=interest;
      return monthlyPayment;
}
let tempTotalPaid = 0;
/**
 *  //本期本金
 * @param {*待还本金} surplus
 * @param {*没有偿还本息} monthlyPayment
 * @param {*月利率} monthRate
 */
const equalPrincipalll = (surplus, monthlyPayment, monthRate) => {
    let interest = surplus * monthRate;   //本期利息
    let principal =0;     //本期本金
    surplus = surplus ;             //剩余本金
    return {
        monthlyPayment: monthlyPayment,
        principal: principal,
        interest: interest,
        surplus: surplus
    }
}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

相关推荐