瀏覽代碼

腾讯验证码

wangxin 5 年之前
父節點
當前提交
0b2dbe0387
共有 1 個文件被更改,包括 23 次插入6 次删除
  1. 23 6
      src/view/captcha/captcha.vue

+ 23 - 6
src/view/captcha/captcha.vue

@@ -65,19 +65,36 @@
             this.TencentCaptcha = new window.TencentCaptcha(
                 getAppId(process.env.NODE_ENV),
                 function (res) {/* callback */
-                    if (that.isiOS) {
-                        window.webkit.messageHandlers.returnVerificationCode.postMessage(res.ret.toString());
-                    }
-                    if (that.isAndroid) {
-                        window.hap.verificationCode(res.ret.toString());
-                    }
                     if (res.ret === 0) {
                         // that.countDown();
                         postAction(getCaptchaCode, {
                             ticket: res.ticket,
                             randstr: res.randstr,
                             phone: that.phone
+                        }).then(() => {
+                            this.$toast({message: '验证码获取成功'})
+                            if (that.isiOS) {
+                                window.webkit.messageHandlers.returnVerificationCode.postMessage(res.ret.toString());
+                            }
+                            if (that.isAndroid) {
+                                window.hap.verificationCode(res.ret.toString());
+                            }
+                        }).catch(data => {
+                            this.$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());
+                            }
                         })
+                    } else {
+                        if (that.isiOS) {
+                            window.webkit.messageHandlers.returnVerificationCode.postMessage(res.ret.toString());
+                        }
+                        if (that.isAndroid) {
+                            window.hap.verificationCode(res.ret.toString());
+                        }
                     }
                 },
                 {