Browse Source

更新验证码逻辑

sandm 1 năm trước cách đây
mục cha
commit
1ceece001f

+ 25 - 5
public/themes/default/views/app/auth/password_request.blade.php

@@ -131,6 +131,25 @@
         var sms_url="{{route('sms.send')}}";
         var find_type=1;
         var captcha_open ={{config('aix.system.site_safety.site_vo_code.captcha_open', 0) }};
+
+        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);
+                toSetSms(res);
+            }else{
+                console.log('用户主动关闭验证码')
+            }
+            console.log('callback:', res);
+        };
+        var captcha = new TencentCaptcha('196587903', captcha_callback, {});
+
         //找回用户类型
         $('.find_type').click(function(event) {
             var indexValue = $('.find_type').index(this);
@@ -179,14 +198,15 @@
                 error:function(data){
                     var error_obj=eval('(' + data.responseText + ')');
                     if(data.status==400) {//业务错误
-                        toSetSms({});
+                        captcha.show();
+
                     }
                 }
             });
         });
 
         // 发送手机验证码
-        function toSetSms(geet_result) {
+        function toSetSms(result) {
             function settime(countdown) {
                 if (countdown == 0) {
                     $('#J_getverificode').prop("disabled", 0);
@@ -207,13 +227,13 @@
             $('#J_getverificode').prop("disabled", !0);
             $('#J_getverificode').addClass('btn_disabled');
             $('#J_getverificode').val('发送中...');
-            geet_result.mobile= $.trim($('#mobile').val());
-            geet_result.type= "check";
+            result.mobile= $.trim($('#mobile').val());
+            result.type= "check";
             $.ajax({
                 url: sms_url,
                 type: 'POST',
                 dataType: 'json',
-                data: geet_result,
+                data: result,
                 success: function (data) {
                     // console.log(data);
                     setTimeout(function() {