Browse Source

贷款-创建订单页新增获取产品详情接口

panyong 4 years ago
parent
commit
f2a0f03191

+ 1 - 1
htmldev/loan/config/prod.env.js

@@ -1,5 +1,5 @@
 'use strict'
 module.exports = {
   NODE_ENV: '"production"',
-  API_DOMAIN: '""'
+  API_DOMAIN: '"http://daikuanapi.codedreamit.com"'
 }

+ 1 - 1
htmldev/loan/config/uat.env.js

@@ -1,5 +1,5 @@
 'use strict'
 module.exports = {
   NODE_ENV: '"production"',
-  API_DOMAIN: '""'
+  API_DOMAIN: '"http://daikuanapi.codedreamit.com"'
 }

+ 11 - 0
htmldev/loan/src/api/common.js

@@ -43,3 +43,14 @@ export const uploadFile = (formData) => request({
   url: '/upload',
   data: formData
 })
+
+/*
+* 获取产品信息
+* */
+export const getProductDetail = (id) => request({
+  method: 'GET',
+  url: '/home/product/detail',
+  params: {
+    id
+  }
+})

+ 30 - 15
htmldev/loan/src/views/loan/apply/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="wrapper">
-    <img class="goods-cover" src="./image/header@2x.png" alt="">
+    <img class="goods-cover" :src="productInfo.productImgUrl" alt="">
     <Flow></Flow>
     <ul class="form-wrap">
       <li>
@@ -25,7 +25,7 @@
           <span v-for="(str, index) in '手机号码:'" :key="index">{{ str }}</span>
         </label>
         <div class="value-wrap">
-          <input type="number" placeholder="请输入手机号码" v-myBlur v-model.trim="postData.orderUserPhone"
+          <input type="tel" placeholder="请输入手机号码" v-myBlur v-model.trim="postData.orderUserPhone"
                  @input="funLimitLength">
         </div>
       </li>
@@ -43,7 +43,7 @@
           <span class="label-code" v-for="(str, index) in '验证码:码'" :key="index">{{ str }}</span>
         </label>
         <div class="value-wrap">
-          <input type="number" placeholder="请输入验证码" v-myBlur v-model.trim="postData.code" @input="funLimitLength">
+          <input type="tel" placeholder="请输入验证码" v-myBlur v-model.trim="postData.code" @input="funLimitLength">
         </div>
         <button class="get-code" @click="funGetCode">{{[0, 60].includes(numCount) ? '获取': numCount + '秒'}}</button>
       </li>
@@ -72,7 +72,7 @@
           <span v-for="(str, index) in '需求金额:'" :key="index">{{ str }}</span>
         </label>
         <div class="value-wrap amount-wrap">
-          <input :class="{'opacity-0': postData.orderPrice * 1 > 0}" type="number" placeholder="请输入需求金额" v-myBlur
+          <input :class="{'opacity-0': postData.orderPrice * 1 > 0}" type="tel" placeholder="请输入需求金额" v-myBlur
                  v-model.trim="amount">
           <p v-show="postData.orderPrice * 1 > 0">{{ postData.orderPrice * 1 | toThousands }}.00</p>
         </div>
@@ -100,9 +100,9 @@
   import Flow from './components/flow'
   import { Popup, Picker, Toast } from 'vant'
   import { createOrder } from './api'
-  import { getChinaArea, sendSMS } from '../../../api/common'
+  import { getChinaArea, sendSMS, getProductDetail } from '../../../api/common'
 
-  const STRCAPTURE = '//daikuanapi.codedreamit.com/captcha'
+  const STRCAPTURE = process.env.API_DOMAIN + '/captcha'
   export default {
     name: 'apply',
     components: {
@@ -135,7 +135,9 @@
         arrErrorList: [],
         strCapture: STRCAPTURE,
         showPicker: false,
-        columns: []
+        columns: [],
+        productInfo: {},
+        timer: null
       }
     },
     computed: {
@@ -158,7 +160,6 @@
           textarea.addEventListener('input', this.handleTextarea(textarea, 1), false)
         })
       }
-      this.$refreshTitle('中行贷')
     },
     activated () {
       if (!this.$route.meta.isUseCache) {
@@ -174,12 +175,15 @@
           orderDistrict: '',
           orderAddress: ''
         }
-        this.numCount = 60
         this.arrErrorList = []
         this.showPicker = false
         this.columns = []
+        this.productInfo = {}
         this.funGetChinaArea()
+        this.funGetProductDetail()
       }
+      this.numCount = 60
+      clearInterval(this.timer)
       this.$route.meta.isUseCache = false
     },
     methods: {
@@ -190,6 +194,16 @@
           }
         })
       },
+      funGetProductDetail () {
+        getProductDetail(this.orderProductId).then(res => {
+          if (res.status) {
+            this.productInfo = res.data
+            this.$nextTick(() => {
+              this.$refreshTitle(res.data.productName)
+            })
+          }
+        })
+      },
       handleTextarea (el, auto) {
         return () => {
           if (auto) {
@@ -210,15 +224,13 @@
         this.postData.code = code.length > 4 ? code.slice(0, 4) : code
       },
       funCutDown () {
-        let numCount = this.numCount
-        const timer = setInterval(() => {
-          if (numCount === 0) {
-            clearInterval(timer)
+        this.timer = setInterval(() => {
+          if (this.numCount === 0) {
+            clearInterval(this.timer)
             this.numCount = 0
             return
           }
-          numCount--
-          this.numCount = numCount
+          this.numCount--
         }, 1000)
       },
       // 获取验证码
@@ -244,6 +256,8 @@
         }).catch(err => {
           Toast(err.msg)
           this.funUpdateCapture()
+          clearInterval(this.timer)
+          this.numCount = 60
         })
       },
       verifyData () {
@@ -286,6 +300,7 @@
             message: this.arrErrorList[0],
             forbidClick: true
           })
+          return
         }
         createOrder(postData).then(res => {
           if (res.status) {

+ 6 - 0
htmldev/loan/src/views/loan/home/index.vue

@@ -82,6 +82,7 @@
           }
         })
       }
+      this.$route.meta.isUseCache = false
     },
     async mounted () {
       await this.$nextTick()
@@ -130,6 +131,11 @@
         this.$router.push({ path: '/loan/detail/' + item.id })
       }
     },
+    beforeDestroy () {
+      if (this.scroll) {
+        this.scroll.destroy()
+      }
+    },
     beforeRouteLeave (to, from, next) {
       if (['loanDetail'].includes(to.name)) {
         from.meta.isUseCache = true