瀏覽代碼

Default Changelist

panyong 4 年之前
父節點
當前提交
0b287086ee

+ 1 - 0
htmldev/loan/src/views/loan/calculator/config/calculate.js

@@ -2,6 +2,7 @@
 export const calcute = {
   // 商贷或公积金贷款统一函数 type: 还款方式 1等额本息 2等额本金 num: 贷款金额 year: 贷款年限 lilv: 贷款基准利率
   singleDk (type, num, year, lilv) {
+    console.log(arguments)
     if (type === 1) {
       return this.benxi(type, num, year, lilv)
     } else if (type === 2) {

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

@@ -12,13 +12,13 @@ const loanYear = () => {
 export const loanConfig = {
   loanYear: loanYear(),
   loanType: [
-    { text: '商业贷款', value: '1' },
-    { text: '公积金贷款', value: '2' },
-    { text: '组合贷款', value: '3' }
+    { text: '商业贷款', value: 1 },
+    { text: '公积金贷款', value: 2 },
+    { text: '组合贷款', value: 3 }
   ],
   payType: [
-    { text: '等额本息', value: 'benxi', type: 1 },
-    { text: '等额本金', value: 'benjin', type: 2 }
+    { text: '等额本息', value: 1 },
+    { text: '等额本金', value: 2 }
   ],
   shangdaiLilv: [
     { year: 1, lilv: '0.0435' },

+ 42 - 9
htmldev/loan/src/views/loan/calculator/index.vue

@@ -1,8 +1,7 @@
 <template>
   <div class="ttyf-wrapper">
     <!--信息编辑-->
-    <van-form @submit="onSubmit"
-              ref="myVanform">
+    <van-form ref="myVanform">
       <!--标题:妥妥计算器-->
       <img class="title" src="" alt="">
       <van-field
@@ -23,7 +22,7 @@
         </template>
       </van-field>
       <!--公积金-->
-      <template v-if="['2', '3'].findIndex(item => item === loanType.value) > -1">
+      <template v-if="[2, 3].findIndex(item => item === loanType.value) > -1">
         <van-field
           v-model="gjjjine"
           type="tel"
@@ -75,7 +74,7 @@
         </van-field>
       </template>
       <!--商业贷款-->
-      <template v-if="['1', '3'].findIndex(item => item === loanType.value) > -1">
+      <template v-if="[1, 3].findIndex(item => item === loanType.value) > -1">
         <van-field
           v-model="sdjine"
           type="tel"
@@ -134,7 +133,7 @@
         :border="false"
         :right-icon="iconOfarrow"
         placeholder="请选择还款方式"
-        class="ttyf-van-cell ttyf-no-arrow"
+        class="ttyf-van-cell"
         @click="showPicker5 = true">
         <template #label>
           <p>
@@ -344,7 +343,6 @@ export default {
     this.$route.meta.isUseCache = false
   },
   methods: {
-    // sdYear, config.shangdaiLilv, config.shangdaiSelect
     lilvCal (year, lilv, selectcontent) {
       let getLilv = ''
       lilv.forEach(item => {
@@ -363,6 +361,8 @@ export default {
     onConfirm0 (value, index) {
       this.loanType = value
       this.showPicker0 = false
+
+      this.handleComputed()
     },
     onCancel0 () {
       const index = this.columns0.findIndex(item => item.value === this.loanType.value)
@@ -375,6 +375,8 @@ export default {
     onConfirm1 (value, index) {
       this.gjjnianxian = value
       this.showPicker1 = false
+
+      this.handleComputed()
     },
     onCancel1 () {
       const index = this.columns1.findIndex(item => item.value === this.gjjnianxian.value)
@@ -387,6 +389,8 @@ export default {
     onConfirm2 (value, index) {
       this.gjjlilv = value
       this.showPicker2 = false
+
+      this.handleComputed()
     },
     onCancel2 () {
       const index = this.columns2.findIndex(item => item.lilv === this.gjjlilv.lilv)
@@ -396,9 +400,11 @@ export default {
       this.showPicker2 = false
     },
     // 商贷年限
-    onConfirm3 (value, index) {
+    onConfirm3 (value) {
       this.sdnianxian = value
       this.showPicker3 = false
+
+      this.handleComputed()
     },
     onCancel3 () {
       const index = this.columns3.findIndex(item => item.value === this.sdnianxian.value)
@@ -411,7 +417,9 @@ export default {
     onConfirm4 (value, index) {
       this.sdlilv = value
       this.showPicker4 = false
-      console.log(calcute.singleDk(1, 20, this.sdnianxian.value, this.sdlilv.lilv))
+      calcute.singleDk(1, 20, this.sdnianxian.value, this.sdlilv.lilv)
+
+      this.handleComputed()
     },
     onCancel4 () {
       const index = this.columns4.findIndex(item => item.lilv === this.sdlilv.lilv)
@@ -424,6 +432,8 @@ export default {
     onConfirm5 (value, index) {
       this.hkfangshi = value
       this.showPicker5 = false
+
+      this.handleComputed()
     },
     onCancel5 () {
       const index = this.columns5.findIndex(item => item.value === this.hkfangshi.value)
@@ -432,7 +442,30 @@ export default {
       }
       this.showPicker5 = false
     },
-    onSubmit (values = {}) {
+    async handleComputed () {
+      await this.$nextTick()
+      let result = {}
+      // 还款方式
+      const payType = this.hkfangshi.value
+      switch (this.loanType.value) {
+        case 1:
+          if (this.sdjine) {
+            result = calcute.singleDk(payType, this.sdjine, this.sdnianxian.value, this.sdlilv.lilv)
+          }
+          break
+        case 2:
+          if (this.gjjjine) {
+            result = calcute.singleDk(payType, this.gjjjine, this.gjjnianxian.value, this.gjjlilv.lilv)
+          }
+          break
+        case 3:
+          if (this.sdjine && this.gjjjine) {
+            result = calcute.zuhe(payType, this.sdjine, this.gjjjine, this.sdnianxian.value, this.gjjnianxian.value, this.sdlilv.lilv, this.gjjlilv.lilv)
+          }
+          break
+      }
+      this.meiyuehuanchuan = result.yuegong
+      this.zonglixi = result.totalLixi
     }
   },
   beforeDestroy () {