Browse Source

更新验证码逻辑

sandm 1 year ago
parent
commit
888ab87b87

+ 1 - 0
public/themes/default/views/app/auth/login.blade.php

@@ -260,6 +260,7 @@
             $('.btn-getcode').on('click', function () {
                 var mobile = $("input[name='mobile']").val();
                 if(mobile == null || mobile == ''){
+                    $("#message_mobile").addClass("errinfo");
                     $("#message_mobile").text("请输入手机号码");
                     return false;
                 }

+ 43 - 6
public/themes/default/views/mobile/app/auth/login.blade.php

@@ -21,6 +21,9 @@
     </div>
     <div class="split-block"></div>
     <form method="post" id="form_account" action="{{route($sub_site.'mobile.login')}}">
+        <input type="hidden" name="ticket" id="ticket">
+        <input type="hidden" name="bizState" id="bizState">
+        <input type="hidden" name="randstr" id="randstr">
         {{ csrf_field() }}
         <div class="loging-input-group">
             <div class="group-list">
@@ -119,7 +122,7 @@
             $(".register_user").click(function(){
 				 var url=$(this).attr("url")
                 $.getJSON("{{route($sub_site.'register.status')}}", function (result) {
-                        
+
                         if (result.status == 0) {
                             qsToast({type:2,context: result.msg});
                         } else{
@@ -140,7 +143,43 @@
                 });
             };
 
-            gt_init(gt_call_back);//初始化极验
+            //gt_init(gt_call_back);//初始化极验
+
+            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);
+            };
+
+
+            var captcha = new TencentCaptcha('196587903', captcha_callback, {});
+            $('.login-account').on('click', function () {
+                var usernameValue = $.trim($('input[name=account]').val());
+                var passwordValue = $.trim($('input[name=password]').val());
+                if (usernameValue == '') {
+                    qsToast({type:2,context: '请输入用户名/手机号'});
+                    return false;
+                }
+                if (passwordValue == '') {
+                    qsToast({type:2,context: '请输入密码'});
+                    return false;
+                }
+
+                ajax_login(1);
+
+                captcha.show();
+            });
 
             $(".input-login").keydown(function(ev){
                 ev = ev || window.event;
@@ -222,9 +261,7 @@
                         error: function (errorData) {
                             //console.log(errorData);
                             var response=$.parseJSON(errorData.response);
-                            if (is_need_geetest==1){
-                                captchaObj.reset();
-                            }
+
                             if (errorData.status==422) {//验证错误
                                 $.each(response.errors,function (key,val) {
                                     qsToast({type:2,context: val[0]});
@@ -233,7 +270,7 @@
                             }
                             else if(errorData.status==400) {//业务错误
                                 qsToast({type:2,context: response.message});
-                                is_need_geetest=response.errors.is_need_geetest;
+                                //is_need_geetest=response.errors.is_need_geetest;
                             }
                         }
                     });