Przeglądaj źródła

合伙人-加入我们接数据

panyong 4 lat temu
rodzic
commit
a755f753c4

+ 1 - 1
htmldev/loan/src/views/partner/agreement/index.vue

@@ -7,7 +7,7 @@
     name: 'agreement',
     async mounted () {
       await this.$nextTick()
-      this.$refreshTitle('协议')
+      this.$refreshTitle('服务协议')
     }
   }
 </script>

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

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

+ 58 - 23
htmldev/loan/src/views/partner/join/index.vue

@@ -63,7 +63,7 @@
           <span class="label-profession" v-for="(str, index) in '职业:职业'" :key="index">{{ str }}</span>
         </label>
         <div class="value-wrap">
-          <input type="text" placeholder="请输入职业" v-myBlur v-model.trim="postData.profession">
+          <input type="text" placeholder="请输入职业" v-myBlur v-model.trim="postData.orderUserProfess">
         </div>
       </li>
       <li>
@@ -71,9 +71,9 @@
           <span class="label-age" v-for="(str, index) in '年龄:年龄'" :key="index">{{ str }}</span>
         </label>
         <div class="value-wrap age-wrap">
-          <input :class="{'opacity-0': postData.age * 1 > 0}" type="tel" placeholder="请输入年龄" v-myBlur
+          <input :class="{'opacity-0': postData.orderUserAge * 1 > 0}" type="tel" placeholder="请输入年龄" v-myBlur
                  v-model.trim="age">
-          <p v-show="postData.age * 1 > 0">{{ postData.age * 1 }}</p>
+          <p v-show="postData.orderUserAge * 1 > 0">{{ postData.orderUserAge * 1 }}</p>
         </div>
       </li>
       <li>
@@ -81,7 +81,7 @@
           <span class="label-invite-code" v-for="(str, index) in '邀请码:码'" :key="index">{{ str }}</span>
         </label>
         <div class="value-wrap">
-          <input type="text" placeholder="请输入邀请码" v-myBlur v-model.trim="postData.inviteCode">
+          <input type="text" placeholder="请输入邀请码" v-myBlur v-model.trim="postData.inviteCode" @input="funLimitLength">
         </div>
       </li>
     </ul>
@@ -106,6 +106,7 @@
 <script>
   import { Popup, Picker, Toast } from 'vant'
   import { getChinaArea, sendSMS } from '../../../api/common'
+  import { createOrder } from './api'
 
   const STRCAPTURE = process.env.API_DOMAIN + '/api/captcha'
   export default {
@@ -125,8 +126,8 @@
           orderProvince: '', // 省份
           orderCity: '', // 城市
           orderDistrict: '', // 区域
-          profession: '', // 职业
-          age: 0,
+          orderUserProfess: '', // 职业
+          orderUserAge: 0,
           inviteCode: ''
         },
         numCount: 60,
@@ -140,16 +141,15 @@
     computed: {
       age: {
         get () {
-          return this.postData.age ? this.postData.age * 1 : ''
+          return this.postData.orderUserAge ? this.postData.orderUserAge : ''
         },
         set (value) {
-          this.postData.age = value
+          this.postData.orderUserAge = /^[1-9]+$/.test(value) ? value * 1 : 0
         }
       }
     },
     async mounted () {
-      await this.$nextTick()
-      this.$refreshTitle('成为合伙人')
+      this.funGetChinaArea()
     },
     activated () {
       if (!this.$route.meta.isUseCache) {
@@ -162,17 +162,19 @@
           orderProvince: '',
           orderCity: '',
           orderDistrict: '',
-          profession: '',
-          age: 0,
+          orderUserProfess: '',
+          orderUserAge: 0,
           inviteCode: ''
         }
+        this.numCount = 60
         this.arrErrorList = []
-        this.showPicker = false
-        this.columns = []
-        this.funGetChinaArea()
+        this.timer = null
+      } else {
+        clearInterval(this.timer)
       }
-      this.numCount = 60
-      clearInterval(this.timer)
+      this.$nextTick(() => {
+        this.$refreshTitle('成为合伙人')
+      })
       this.$route.meta.isUseCache = false
     },
     methods: {
@@ -180,7 +182,11 @@
         getChinaArea().then(res => {
           if (res.status) {
             this.columns = res.data
+          } else {
+            Toast(res.msg)
           }
+        }).catch(err => {
+          Toast(err)
         })
       },
       onConfirm (value) {
@@ -190,9 +196,10 @@
         this.$set(this.postData, 'orderDistrict', value[2])
       },
       funLimitLength () {
-        const { orderUserPhone, code } = this.postData
+        const { orderUserPhone, code, inviteCode } = this.postData
         this.postData.orderUserPhone = orderUserPhone.length > 11 ? orderUserPhone.slice(0, 11) : orderUserPhone
         this.postData.code = code.length > 4 ? code.slice(0, 4) : code
+        this.postData.inviteCode = inviteCode.length > 4 ? inviteCode.slice(0, 4) : inviteCode
       },
       funCutDown () {
         this.timer = setInterval(() => {
@@ -222,9 +229,14 @@
           return
         }
         this.funCutDown()
-        sendSMS(orderUserPhone, 0, capture).then(res => {
+        sendSMS(orderUserPhone, 2, capture).then(res => {
           if (res.status) {
             Toast('发送成功')
+          } else {
+            Toast(res.msg)
+            this.funUpdateCapture()
+            clearInterval(this.timer)
+            this.numCount = 60
           }
         }).catch(err => {
           Toast(err.msg)
@@ -234,7 +246,7 @@
         })
       },
       verifyData () {
-        const { orderUserName, orderUserSex, orderUserPhone, code, orderProvince, orderCity, orderDistrict, profession, age } = this.postData
+        const { orderUserName, orderUserSex, orderUserPhone, code, orderProvince, orderCity, orderDistrict, orderUserProfess, orderUserAge } = this.postData
         this.arrErrorList = []
         if (!orderUserName) {
           this.arrErrorList.push('请输入姓名')
@@ -251,10 +263,10 @@
         if (!orderProvince || !orderCity || !orderDistrict) {
           this.arrErrorList.push('请选择所在城市')
         }
-        if (!profession) {
+        if (!orderUserProfess) {
           this.arrErrorList.push('请输入职业')
         }
-        if (age * 1 <= 0) {
+        if (orderUserAge * 1 <= 0) {
           this.arrErrorList.push('请输入年龄')
         }
         return this.arrErrorList.length <= 0
@@ -274,7 +286,30 @@
           })
           return
         }
-        this.$router.replace({ path: '/partner/detail' })
+        const myToast = Toast.loading({
+          message: '提交中...',
+          duration: 1000 * 100,
+          forbidClick: true
+        })
+        createOrder(postData).then(res => {
+          myToast.clear()
+          if (res.status) {
+            const { id } = res.data
+            Toast({
+              type: 'success',
+              message: '提交成功',
+              forbidClick: true,
+              onClose: () => {
+                this.$router.replace({ path: '/partner/detail?id=' + id })
+              }
+            })
+            return
+          }
+          Toast(res.msg)
+        }).catch(err => {
+          myToast.clear()
+          Toast(err)
+        })
       }
     },
     beforeRouteLeave (to, from, next) {