浏览代码

code input

abpcoder 2 月之前
父节点
当前提交
f0344c0e92
共有 1 个文件被更改,包括 30 次插入22 次删除
  1. 30 22
      src/views/pay/index.vue

+ 30 - 22
src/views/pay/index.vue

@@ -86,14 +86,17 @@
         </div>
       </template>
     </el-dialog>
+    <code-input-popup :show.sync="showCodeInput" @complete="confirmCodeInput"/>
   </div>
 </template>
 
 <script>
 import { getEcardPrices, getOrderPayStatus, prepayCard, sendSmsNoValidation } from '@/api/webApi/pay'
+import CodeInputPopup from "@/views/components/CodeInputPopup.vue";
 
 export default {
   name: 'PayIndex',
+  components: {CodeInputPopup},
   data() {
     let checkPhone = (rule, value, callback) => {
       let reg = /^1[345789]\d{9}$/
@@ -119,6 +122,7 @@ export default {
       captchaBtnText: '免费获取',
       disabled: false,
       spaceTime: 60,
+      showCodeInput: false,
       cardActive: {},
       cardList: [],
       countdownTimer: null,
@@ -159,29 +163,33 @@ export default {
       this.$refs.form.clearValidate([])
       this.$refs.form.validateField('phoneNumber', (res) => {
         if (res == '') {
-          // 通过
-          sendSmsNoValidation({
-            mobile: this.form.phoneNumber,
-            smsType: 1
-          }).then(res => {
-            if (res.code == 200) {
-              this.$message.success('发送成功,请在手机上查收')
-              // 成功60秒不让点击
-              this.disabled = true
-              this.captchaBtnText = `(${this.spaceTime}秒)免费获取`
-              this.countdownTimer = window.setInterval(() => {
-                this.spaceTime--
-                this.captchaBtnText = `(${this.spaceTime}秒)免费获取`
-                if (this.spaceTime < 0) {
-                  this.stopCountdownTimer()
-                  this.captchaBtnText = '免费获取'
-                  this.totalTime = 60
-                  this.disabled = false
-                }
-              }, 1000)
-
+          this.showCodeInput = true
+        }
+      })
+    },
+    confirmCodeInput(events) {
+      // 通过
+      sendSmsNoValidation({
+        mobile: this.form.phoneNumber,
+        smsType: 1,
+        ...events
+      }).then(res => {
+        if (res.code == 200) {
+          this.$message.success('发送成功,请在手机上查收')
+          // 成功60秒不让点击
+          this.disabled = true
+          this.captchaBtnText = `(${this.spaceTime}秒)免费获取`
+          this.countdownTimer = window.setInterval(() => {
+            this.spaceTime--
+            this.captchaBtnText = `(${this.spaceTime}秒)免费获取`
+            if (this.spaceTime < 0) {
+              this.stopCountdownTimer()
+              this.captchaBtnText = '免费获取'
+              this.totalTime = 60
+              this.disabled = false
             }
-          })
+          }, 1000)
+
         }
       })
     },