Bläddra i källkod

腾讯验证码

wangxin 5 år sedan
förälder
incheckning
7adb57da2b
1 ändrade filer med 4 tillägg och 3 borttagningar
  1. 4 3
      src/view/captcha/captcha.vue

+ 4 - 3
src/view/captcha/captcha.vue

@@ -58,16 +58,17 @@
             }
 
             this.isAndroid = /(Android)/i.test(navigator.userAgent)
+            this.isiOS = /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)
             const that = this;
             this.phone = location.href.split('?')[1].split('&')[0].split('=')[1];
-            this.isiOS = location.href.split('?')[1].split('&')[1] ? location.href.split('?')[1].split('&')[1].split('=')[1] : false;
             this.number = this.phone.substring(0, 3) + ' ' + this.phone.substring(3, 7) + ' ' + this.phone.substring(7, 11);
             this.TencentCaptcha = new window.TencentCaptcha(
                 getAppId('development'),
                 function (res) {/* callback */
-                    if (that.isiOS === '1') {
+                    if (that.isiOS) {
                         window.webkit.messageHandlers.returnVerificationCode.postMessage(res.ret.toString());
-                    } else {
+                    }
+                    if (that.isAndroid) {
                         window.hap.verificationCode(res.ret.toString());
                     }
                     if (res.ret === 0) {