Quellcode durchsuchen

腾讯验证码

wangxin vor 5 Jahren
Ursprung
Commit
c55ce0999d
1 geänderte Dateien mit 82 neuen und 73 gelöschten Zeilen
  1. 82 73
      src/view/captcha/captcha.vue

+ 82 - 73
src/view/captcha/captcha.vue

@@ -1,35 +1,35 @@
 <template>
     <div>
-<!--        <img-->
-<!--                src="https://happyjob.oss-cn-shanghai.aliyuncs.com/uploadfiles/mina/images/happyjob/login_xiaobai.png"-->
-<!--                alt=""-->
-<!--                class="image">-->
-<!--        <div class="title">-->
-<!--            <div class="tips">-->
-<!--                请输入验证码-->
-<!--            </div>-->
-<!--            <div class="number">-->
-<!--                验证码已发送至 {{number}}-->
-<!--            </div>-->
-<!--        </div>-->
-<!--        <div class="captcha">-->
-<!--            <div class="input">-->
-<!--                <input-->
-<!--                        v-for="(val,ind) in captcha"-->
-<!--                        :key="ind"-->
-<!--                        maxlength="1"-->
-<!--                        type="text"-->
-<!--                        :autofocus="!Boolean(ind)"-->
-<!--                        placeholder=""-->
-<!--                        :class="val&&'border'"-->
-<!--                        v-model="captcha[ind]"-->
-<!--                        @input="next(ind)"-->
-<!--                >-->
-<!--            </div>-->
-<!--        </div>-->
-<!--        <div class="time" @click="getCaptcha">-->
-<!--            {{time_tips}}-->
-<!--        </div>-->
+        <!--        <img-->
+        <!--                src="https://happyjob.oss-cn-shanghai.aliyuncs.com/uploadfiles/mina/images/happyjob/login_xiaobai.png"-->
+        <!--                alt=""-->
+        <!--                class="image">-->
+        <!--        <div class="title">-->
+        <!--            <div class="tips">-->
+        <!--                请输入验证码-->
+        <!--            </div>-->
+        <!--            <div class="number">-->
+        <!--                验证码已发送至 {{number}}-->
+        <!--            </div>-->
+        <!--        </div>-->
+        <!--        <div class="captcha">-->
+        <!--            <div class="input">-->
+        <!--                <input-->
+        <!--                        v-for="(val,ind) in captcha"-->
+        <!--                        :key="ind"-->
+        <!--                        maxlength="1"-->
+        <!--                        type="text"-->
+        <!--                        :autofocus="!Boolean(ind)"-->
+        <!--                        placeholder=""-->
+        <!--                        :class="val&&'border'"-->
+        <!--                        v-model="captcha[ind]"-->
+        <!--                        @input="next(ind)"-->
+        <!--                >-->
+        <!--            </div>-->
+        <!--        </div>-->
+        <!--        <div class="time" @click="getCaptcha">-->
+        <!--            {{time_tips}}-->
+        <!--        </div>-->
     </div>
 </template>
 
@@ -52,6 +52,9 @@
             }
         },
         mounted() {
+            document.querySelector('iframe').onload = function () {
+                document.querySelector('.t-mask').style.background = 'transparent'
+            }
             const that = this;
             const u = navigator.userAgent;
             this.isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
@@ -68,10 +71,12 @@
                             randstr: res.randstr,
                             phone: that.phone
                         }).then(() => {
-                            that.can_jump = true
-                            that.$toast.success({message: '验证码发送成功'})
-                        }).catch((data) => {
-                            that.$toast.fail({icon: 'close', message: data.errmsg})
+                            if (this.isiOS) {
+                                window.webkit.messageHandlers.returnVerificationCode.postMessage('发送成功');
+                            }
+                            if (this.isAndroid) {
+                                // window.webkit.messageHandlers.returnVerificationCode.postMessage(this.captcha.join(''));
+                            }
                         })
                     }
                 },
@@ -86,49 +91,49 @@
             this.getCaptcha();
         },
         methods: {
-            next(index) {
-                const input = document.querySelectorAll('input');
-                if (this.captcha[index]) {
-                    if (this.captcha.length === index + 1) {
-                        if (this.can_jump) {
-                            if (this.isiOS) {
-                                window.webkit.messageHandlers.returnVerificationCode.postMessage('发送成功');
-                            }
-                            if (this.isAndroid) {
-                                // window.webkit.messageHandlers.returnVerificationCode.postMessage(this.captcha.join(''));
-                            }
-                        }
-                    } else {
-                        input[index + 1].focus();
-                    }
-                } else {
-                    if (index > 0) {
-                        input[index - 1].focus();
-                    }
-                }
-            },
+            // next(index) {
+            //     const input = document.querySelectorAll('input');
+            //     if (this.captcha[index]) {
+            //         if (this.captcha.length === index + 1) {
+            //             if (this.can_jump) {
+            //                 if (this.isiOS) {
+            //                     window.webkit.messageHandlers.returnVerificationCode.postMessage('发送成功');
+            //                 }
+            //                 if (this.isAndroid) {
+            //                     // window.webkit.messageHandlers.returnVerificationCode.postMessage(this.captcha.join(''));
+            //                 }
+            //             }
+            //         } else {
+            //             input[index + 1].focus();
+            //         }
+            //     } else {
+            //         if (index > 0) {
+            //             input[index - 1].focus();
+            //         }
+            //     }
+            // },
             getCaptcha() {
                 this.can_jump = false;
                 this.TencentCaptcha.show();
             },
-            countDown() {
-                if (this.time === 60) {
-                    this.time = --this.time;
-                    this.time_tips = `${this.time}s 后重新获取验证码`
-                    const setint = setInterval(() => {
-                        if (this.time > 0) {
-                            this.time = --this.time;
-                            this.time_tips = `${this.time}s 后重新获取验证码`
-                        } else {
-                            clearInterval(setint);
-                            this.time = 60;
-                            this.time_tips = `重新获取验证码`
-                        }
-                    }, 1000)
-                } else {
-                    this.$toast({message: '请勿重复点击'})
-                }
-            }
+            // countDown() {
+            //     if (this.time === 60) {
+            //         this.time = --this.time;
+            //         this.time_tips = `${this.time}s 后重新获取验证码`
+            //         const setint = setInterval(() => {
+            //             if (this.time > 0) {
+            //                 this.time = --this.time;
+            //                 this.time_tips = `${this.time}s 后重新获取验证码`
+            //             } else {
+            //                 clearInterval(setint);
+            //                 this.time = 60;
+            //                 this.time_tips = `重新获取验证码`
+            //             }
+            //         }, 1000)
+            //     } else {
+            //         this.$toast({message: '请勿重复点击'})
+            //     }
+            // }
         }
     }
 </script>
@@ -188,4 +193,8 @@
         padding: 0 45px;
         margin-top: 15px;
     }
+
+    /deep/ #t_mask {
+        background: transparent !important;
+    }
 </style>