ソースを参照

腾讯验证码

wangxin 5 年 前
コミット
60e5348f5b
1 ファイル変更14 行追加16 行削除
  1. 14 16
      src/view/captcha/captcha.vue

+ 14 - 16
src/view/captcha/captcha.vue

@@ -53,7 +53,8 @@
             }
         },
         mounted() {
-            var container = document.querySelector("body")
+            const container = document.querySelector("body")
+            container.style.background = 'red'
             container.addEventListener('DOMSubtreeModified', function () {
                 const element = document.querySelector('#tcaptcha_transform')
                 const t_verify = document.querySelector('#t_verify')
@@ -62,17 +63,16 @@
                     mask.style.display = 'none'
                 }
                 if (t_verify) {
+                    // console.log(t_verify);
+                    // document.querySelector('.t-verify').style.background = 'transparent'
                     t_verify.style.border = 'none'
+                    t_verify.style.background = 'transparent'
                 }
                 if (element) {
                     element.style.border = 'none'
                 }
 
             }, false);
-            document.querySelector('iframe').onload = function () {
-
-            }
-
             this.isAndroid = /(Android)/i.test(navigator.userAgent)
             this.isiOS = /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)
             const that = this;
@@ -87,21 +87,23 @@
                             randstr: res.randstr,
                             phone: that.phone
                         }).then(() => {
-                            that.$toast.fail({message: '验证码获取成功'})
                             if (that.isiOS) {
                                 window.webkit.messageHandlers.returnVerificationCode.postMessage(res.ret.toString());
                             }
                             if (that.isAndroid) {
                                 window.hap.verificationCode(res.ret.toString());
                             }
+
                         }).catch(data => {
                             that.$toast.fail({icon: 'close', message: data.errmsg})
-                            if (that.isiOS) {
-                                window.webkit.messageHandlers.returnVerificationCode.postMessage(res.ret.toString());
-                            }
-                            if (that.isAndroid) {
-                                window.hap.verificationCode(res.ret.toString());
-                            }
+                            setTimeout(function () {
+                                if (that.isiOS) {
+                                    window.webkit.messageHandlers.returnVerificationCode.postMessage(res.ret.toString());
+                                }
+                                if (that.isAndroid) {
+                                    window.hap.verificationCode(res.ret.toString());
+                                }
+                            }, 1200)
                         })
                     } else {
                         if (that.isiOS) {
@@ -171,10 +173,6 @@
 </script>
 
 <style lang="less" scoped>
-    body {
-        background: transparent;
-    }
-
     .image {
         height: 180px;
         position: fixed;