Explorar o código

修复手机端找回密码

sandm hai 1 ano
pai
achega
7c463e8419

+ 68 - 29
public/themes/default/views/mobile/app/auth/password_mobile.blade.php

@@ -11,6 +11,7 @@
 @push('js')
     <script type="text/javascript" src="{{ theme_asset('gt/gt.js') }}"></script>
     <script type="text/javascript" src="{{ theme_asset('gt/gt.handle.js') }}"></script>
+    <script src="https://captcha.253.com/TCaptcha.js"></script>
 @endpush
 
 @section('content')
@@ -47,38 +48,76 @@
     <script type="text/javascript" src="{{ theme_asset('app/js/regular.js') }}"></script>
 <script>
     //发送短信
-    var handler = function(captchaObj) {
-        captchaObj.appendTo("#popup-captcha");
-        captchaObj.onSuccess(function() {
-            var result = captchaObj.getValidate();
-            toSetSms(result);
-        });
+    // var handler = function(captchaObj) {
+    //     captchaObj.appendTo("#popup-captcha");
+    //     captchaObj.onSuccess(function() {
+    //         var result = captchaObj.getValidate();
+    //         toSetSms(result);
+    //     });
+    //
+    //     captchaObj.onError(function() {
+    //
+    //     });
+    //     $('#getVerfyCode').on('click', function () {
+    //         if ($('#getVerfyCode').hasClass('qs-btn-border-disabled')) {
+    //             return false;
+    //         }
+    //         var mobileValue = $.trim($('input[name=mobile]').val());
+    //         if (mobileValue == '') {
+    //             qsToast({type:2,context: '请输入手机号码'});
+    //             return false;
+    //         }
+    //         if (mobileValue != "" && !regularMobile.test(mobileValue)) {
+    //             qsToast({type:2,context: '手机号码格式不正确'});
+    //             return false;
+    //         }
+    //         if (remoteValid('mobile',mobileValue)) {
+    //             qsToast({type:2,context: '该手机号没有注册账号'});
+    //             return false;
+    //         }
+    //         captchaObj.verify();
+    //
+    //     });
+    // };
+    // gt_init(handler);
 
-        captchaObj.onError(function() {
+    var captcha_callback = function(res){
+        if(res.hasOwnProperty('errorMessage')){
+            alert(res.errorMessage)
+        }
+        if(res.ret == 0){
+            console.log('行为验证通过');
+            $("#ticket").val(res.ticket);
+            $("#bizState").val(res.bizState);
+            $("#randstr").val(res.randstr);
+            ajax_login(1);
+        }else{
+            console.log('用户主动关闭验证码')
+        }
+        console.log('callback:', res);
+    }
 
-        });
-        $('#getVerfyCode').on('click', function () {
-            if ($('#getVerfyCode').hasClass('qs-btn-border-disabled')) {
-                return false;
-            }
-            var mobileValue = $.trim($('input[name=mobile]').val());
-            if (mobileValue == '') {
-                qsToast({type:2,context: '请输入手机号码'});
-                return false;
-            }
-            if (mobileValue != "" && !regularMobile.test(mobileValue)) {
-                qsToast({type:2,context: '手机号码格式不正确'});
-                return false;
-            }
-            if (remoteValid('mobile',mobileValue)) {
-                qsToast({type:2,context: '该手机号没有注册账号'});
-                return false;
-            }
-            captchaObj.verify();
+    var captcha = new TencentCaptcha('196587903', captcha_callback, {});
+    $('#getVerfyCode').on('click', function () {
+        if ($('#getVerfyCode').hasClass('qs-btn-border-disabled')) {
+            return false;
+        }
+        var mobileValue = $.trim($('input[name=mobile]').val());
+        if (mobileValue == '') {
+            qsToast({type:2,context: '请输入手机号码'});
+            return false;
+        }
+        if (mobileValue != "" && !regularMobile.test(mobileValue)) {
+            qsToast({type:2,context: '手机号码格式不正确'});
+            return false;
+        }
+        if (remoteValid('mobile',mobileValue)) {
+            qsToast({type:2,context: '该手机号没有注册账号'});
+            return false;
+        }
+        captcha.show();
 
-        });
-    };
-    gt_init(handler);
+    });
 
     // 发送手机验证码
     function toSetSms(geet_result) {