Ver Fonte

计算器-推荐有礼

panyong há 3 anos atrás
pai
commit
b89f5af188

+ 4 - 0
htmldev/loan/src/store/modules/loan.js

@@ -7,6 +7,7 @@ const state = {
     userName: '', // 用户名称
     userImgUrl: '' // 用户头像
   },
+  recommendedProduct: [], // 贷款计算器所推荐的产品
   userInfo: {} // 用户信息
 }
 
@@ -26,6 +27,9 @@ const mutations = {
   UPDATE_USERSHARECONFIG (state, value) {
     state.userShareConfig = value
   },
+  UPDATE_RECOMMENDEDPRODUCT (state, value) {
+    state.recommendedProduct = value
+  },
   UPDATE_USERINFO (state, value) {
     state.userInfo = value
   }

+ 7 - 0
htmldev/loan/src/views/loan/calculator/api/index.js

@@ -0,0 +1,7 @@
+import request from '@/api/request'
+
+export const getRecommendProduct = (postData) => request({
+  method: 'POST',
+  url: '/home/product/recommend',
+  data: postData
+})

+ 30 - 2
htmldev/loan/src/views/loan/calculator/index.vue

@@ -268,9 +268,10 @@
 </template>
 
 <script>
-import { Form, Field, Popup, Picker, Button } from 'vant'
+import { Form, Field, Popup, Picker, Button, Toast } from 'vant'
 import { loanConfig } from './config'
 import { calcute } from './config/calculate'
+import { getRecommendProduct } from './api'
 
 export default {
   name: 'index',
@@ -330,6 +331,14 @@ export default {
     // 商贷利率
     columns4 () {
       return this.lilvCal(this.sdnianxian.value, loanConfig.shangdaiLilv, loanConfig.shangdaiSelect)
+    },
+    recommendedProduct: {
+      get () {
+        return this.$store.state.loan.recommendedProduct
+      },
+      set (val) {
+        this.$store.commit('loan/UPDATE_RECOMMENDEDPRODUCT', val)
+      }
     }
   },
   activated () {
@@ -469,16 +478,35 @@ export default {
           }
           break
       }
-
+      this.recommendedProduct = []
       if (result.yuegong) {
         yuegong = this.formatCurrency(result.yuegong)
       }
 
       if (result.totalLixi) {
         totalLixi = this.formatCurrency(result.totalLixi / 10000)
+        this.fetchRecommendProduct(result.totalLixi)
       }
       this.meiyuehuanchuan = yuegong
       this.zonglixi = totalLixi
+      this.fetchRecommendProduct()
+    },
+    fetchRecommendProduct (moneyRate) {
+      const postData = {
+        total_money: parseFloat(this.gjjjine) * 10000 + parseFloat(this.sdjine) * 10000, // 总贷款金额(单位:元)
+        product_max_year: this.gjjnianxian.value + this.sdnianxian.value, // 贷款年限
+        product_back_method: this.hkfangshi.text, // 还款方式(先息后本、等额本息、等额本金)
+        money_rate: moneyRate // 计算器计算的利息
+      }
+      getRecommendProduct(postData).then(res => {
+        if (res.status) {
+          this.recommendedProduct = res.data
+          return
+        }
+        Toast(res.msg)
+      }).catch(err => {
+        Toast(err.msg)
+      })
     }
   },
   beforeDestroy () {