Browse Source

计算器-新增先息后本

panyong 3 years ago
parent
commit
adabde362c

+ 27 - 2
htmldev/loan/src/views/loan/calculator/config/calculate.js

@@ -6,6 +6,8 @@ export const calcute = {
       return this.benxi(type, num, year, lilv)
     } else if (type === 2) {
       return this.benjin(type, num, year, lilv)
+    } else if (type === 3) {
+      return this.xianxi(type, num, year, lilv)
     }
   },
   // 组合贷款计算 type:还款方式 sdnum:商贷金额 gjjnum:公积金贷款金额, sdyear:商贷年限 gjjyear:公积金贷款年限 sdlilv:商贷利率 gjjlilv:公积金贷款利率
@@ -61,7 +63,6 @@ export const calcute = {
         totalDknum: parseFloat(sdObj.totalDknum) + parseFloat(gjjObj.totalDknum),
         year: year
       }
-
     } else if (type === 2) {
       var sdObj = _this.benjin(type, sdnum, sdyear, sdlilv)
       var gjjObj = _this.benjin(type, gjjnum, gjjyear, gjjlilv)
@@ -112,8 +113,14 @@ export const calcute = {
         year: year,
         mouthdataArray: mergemouthdataArray
       }
+    } else if (type === 3) {
+      var sdObj = _this.xianxi(type, sdnum, sdyear, sdlilv)
+      var gjjObj = _this.xianxi(type, gjjnum, gjjyear, gjjlilv)
+      return {
+        yuegong: sdObj.yuegong + gjjObj.yuegong,
+        totalLixi: sdObj.totalLixi + gjjObj.totalLixi
+      }
     }
-
   },
   // 等额本息计算
   benxi (type, num, year, lilv) {
@@ -227,6 +234,24 @@ export const calcute = {
       totalDknum: num,
       year: year
     }
+  },
+  // 先息后本
+  xianxi (type, num, year, lilv) {
+    // 月利率 = 年利率/12
+    var mouth = parseInt(year) * 12
+    var mouthlilv = parseFloat(lilv) / 12
+    var dknum = parseFloat(num) * 10000
 
+    // 月供=月利率x本金
+    var yuegong = mouthlilv * dknum
+    // 总利息=〔(总贷款额÷+总贷款额×月利率)+总贷款额÷还款月数×(1+月利率)〕÷2×还款月数-总贷款额
+    // 总利息= 还款月数 * 月利率 * 总贷款额
+    var totalLixi = mouth * mouthlilv * dknum
+    return {
+      yuegong: yuegong,
+      totalLixi: totalLixi,
+      totalDknum: num,
+      year: year
+    }
   }
 }

+ 2 - 1
htmldev/loan/src/views/loan/calculator/config/index.js

@@ -18,7 +18,8 @@ export const loanConfig = {
   ],
   payType: [
     { text: '等额本息', value: 1 },
-    { text: '等额本金', value: 2 }
+    { text: '等额本金', value: 2 },
+    { text: '先息后本', value: 3 }
   ],
   shangdaiLilv: [
     { year: 1, lilv: '0.0435' },