Explorar el Código

更改手机端登录界面

zmw hace 5 meses
padre
commit
4f0d08f0f4

+ 27 - 243
public/themes/default/views/mobile/app/auth/login.blade.php

@@ -68,81 +68,18 @@
     @include('mobile.module.widgets.thirdlogin')
     <script>
         $(function () {
-            var is_need_geetest=0;//全局,是否使用极验.
-            var login_type=1;//登录模式,1用户账号登录,2用户手机登录,3企业登录.
-            var gt_call_back=function(captchaObj) {
-                captchaObj.onReady(function () {
-                    //极验加载完成
-                });
-                captchaObj.onSuccess(function () {
-                    ajax_login(login_type,captchaObj);
-
-                });
-                captchaObj.onError(function () {
-                    // qsToast({type:2,context: "请先进行验证"});
-                });
-                captchaObj.onClose(function () {
-                    // qsToast({type:2,context: "请先进行验证"});
-                });
-                $('.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;
-                    }
-                    login_type=1;
-                    //clean_message();
-                    if (is_need_geetest==1){
-                        captchaObj.bindForm("#form_account");
-                        captchaObj.verify();
-                    }
-                    else{
-                        ajax_login(login_type,captchaObj);
-                    }
-
-                });
-
-                $('.login-mobile').on('click', function () {
-                    login_type=2;
-                    //clean_message();
-                    if (is_need_geetest==1){
-                        captchaObj.bindForm("#form_mobile");
-                        captchaObj.verify();
-                    }
-                    else{
-                        ajax_login(login_type,captchaObj);
-                    }
-                });
-
 
             $(".register_user").click(function(){
-				 var url=$(this).attr("url")
+                var url=$(this).attr("url")
                 $.getJSON("{{route($sub_site.'register.status')}}", function (result) {
 
-                        if (result.status == 0) {
-                            qsToast({type:2,context: result.msg});
-                        } else{
-                            location.href=url;
-                        }
-                });
-            })
-                $('.login-company').on('click', function () {
-                    login_type=3;
-                    //clean_message();
-                    if (is_need_geetest==1){
-                        captchaObj.bindForm("#form_company");
-                        captchaObj.verify();
-                    }
-                    else{
-                        ajax_login(login_type,captchaObj);
+                    if (result.status == 0) {
+                        qsToast({type:2,context: result.msg});
+                    } else{
+                        location.href=url;
                     }
                 });
-            };
+            })
 
             //gt_init(gt_call_back);//初始化极验
 
@@ -156,7 +93,7 @@
                     $("#ticket").val(res.ticket);
                     $("#bizState").val(res.bizState);
                     $("#randstr").val(res.randstr);
-                    ajax_login(1);
+                    ajax_login();
                 }else{
                     console.log('用户主动关闭验证码')
                 }
@@ -182,14 +119,6 @@
                 captcha.show();
             });
 
-            $(".input-login").keydown(function(ev){
-                ev = ev || window.event;
-                var code = (ev.keyCode || ev.which);
-                if (code == 10 || code == 13) {
-                    $(this).closest("form").find(".btn-group").click();
-                }
-            });
-
             // 自动登录
             $('#for-checkbox').on('click', function() {
                 $(this).toggleClass('active');
@@ -199,191 +128,46 @@
                     $('#autoLogin').val('0');
                 }
             })
-            $('.btn-getcode').on('click', function () {
-                submit_data={
-                    "mobile":$("input[name='mobile']").val(),
-                    "type":"login"
-                };
+
+
+
+            function ajax_login() {
                 $.ajax({
-                    method: 'post',
-                    url: '{{route('sms.send')}}',
-                    data: submit_data,
+                    type: 'post',
+                    url: $("#form_account").attr('action'),
+                    data: $("#form_account").serialize(),
                     beforeSend:function () {
-                       // console.log('请求开始');
-                        $(".errinfo").text("");
-                        $(".errinfo").removeClass("errinfo");
+                        //console.log('请求开始');
 
                     },
                     complete:function() {
-                        console.log('请求结束');
+                        //console.log('请求结束');
+
                     },
                     success: function (data) {
-                       // console.log(data);
-                        $("#message_mobile").addClass("successinfo");
-                        $("#message_mobile").text("发送成功,请注意查收");
-                        settime();
+                        //console.log(data);
+                        qsToast({type:2,context: "登录成功, 正在跳转..."});
+                        location.href=data.data.redirect_url+'?token='+data.data.token;
                     },
                     error: function (errorData) {
-                       // console.log(errorData);
+                        //console.log(errorData);
+                        var response=$.parseJSON(errorData.response);
+
                         if (errorData.status==422) {//验证错误
-                            $.each(errorData.responseJSON.errors,function (key,val) {
-                                $("#"+key).addClass("errinfo");
-                                $("#"+key).text(val[0]);
+                            $.each(response.errors,function (key,val) {
+                                qsToast({type:2,context: val[0]});
+                                return false;
                             });
                         }
                         else if(errorData.status==400) {//业务错误
-                            $("#message_mobile").addClass("errinfo");
-                            $("#message_mobile").text(errorData.responseJSON.message);
+                            qsToast({type:2,context: response.message});
                         }
                     }
                 });
-            });
-
-
-            function ajax_login(type, captchaObj) {
-                if (type==1) {
-                    $.ajax({
-                        type: 'post',
-                        url: $("#form_account").attr('action'),
-                        data: $("#form_account").serialize(),
-                        beforeSend:function () {
-                            //console.log('请求开始');
-
-                        },
-                        complete:function() {
-                            //console.log('请求结束');
-
-                        },
-                        success: function (data) {
-                            //console.log(data);
-                            qsToast({type:2,context: "登录成功, 正在跳转..."});
-                            location.href=data.data.redirect_url+'?token='+data.data.token;
-                        },
-                        error: function (errorData) {
-                            //console.log(errorData);
-                            var response=$.parseJSON(errorData.response);
-
-                            if (errorData.status==422) {//验证错误
-                                $.each(response.errors,function (key,val) {
-                                    qsToast({type:2,context: val[0]});
-                                    return false;
-                                });
-                            }
-                            else if(errorData.status==400) {//业务错误
-                                qsToast({type:2,context: response.message});
-                                //is_need_geetest=response.errors.is_need_geetest;
-                            }
-                        }
-                    });
-                }
-                else if (type==2) {
-                    $.ajax({
-                        method: 'post',
-                        url: $("#form_mobile").attr('action'),
-                        data: $("#form_mobile").serialize(),
-                        beforeSend:function () {
-                            //console.log('请求开始');
-                            clean_message();
-                            $('.login-mobile').addClass("btn-disabled").prop('disabled', true);
-                            $('.login-mobile').val("登录中...");
-
-                        },
-                        complete:function() {
-                            //console.log('请求结束');
-                            $('.login-mobile').val("登录");
-                            $('.login-mobile').removeClass("btn-disabled").prop('disabled', false);
-                        },
-                        success: function (data) {
-                            //console.log(data);
-                            $("#message_mobile").addClass("successinfo");
-                            $("#message_mobile").text("登录成功, 正在跳转...");
-                            location.href=data.data.redirect_url+'?token='+data.data.token;
-                        },
-                        error: function (errorData) {
-                            //console.log(errorData);
-                            if (is_need_geetest==1){
-                                captchaObj.reset();
-                            }
-                            if (errorData.status==422) {//验证错误
-                                $.each(errorData.responseJSON.errors,function (key,val) {
-                                    $("#"+key).addClass("errinfo");
-                                    $("#"+key).text(val[0]);
-                                });
-                            }
-                            else if(errorData.status==400) {//业务错误
-                                $("#message_mobile").addClass("errinfo");
-                                $("#message_mobile").text(errorData.responseJSON.message);
-                                is_need_geetest=errorData.responseJSON.errors.is_need_geetest;
-                            }
-                        }
-                    });
-                }
-                else if (type==3){
-                    $.ajax({
-                        method: 'post',
-                        url: $("#form_company").attr('action'),
-                        data: $("#form_company").serialize(),
-                        beforeSend:function () {
-                            //console.log('请求开始');
-                            clean_message();
-                            $('.login-company').addClass("btn-disabled").prop('disabled', true);
-                            $('.login-company').val("登录中...");
-
-                        },
-                        complete:function() {
-                            //console.log('请求结束');
-                            $('.login-company').val("登录");
-                            $('.login-company').removeClass("btn-disabled").prop('disabled', false);
-
-                        },
-                        success: function (data) {
-                            //console.log(data);
-                            $("#message_company").addClass("successinfo");
-                            $("#message_company").text("登录成功, 正在跳转...");
-                            location.href=data.data.redirect_url+'?token='+data.data.token;
-                        },
-                        error: function (errorData) {
-                            //console.log(errorData);
-                            if (is_need_geetest==1){
-                                captchaObj.reset();
-                            }
-                            if (errorData.status==422) {//验证错误
-                                $.each(errorData.responseJSON.errors,function (key,val) {
-                                    $("#"+key).addClass("errinfo");
-                                    $("#"+key).text(val[0]);
-                                });
-                            }
-                            else if(errorData.status==400) {//业务错误
-                                $("#message_company").addClass("errinfo");
-                                $("#message_company").text(errorData.responseJSON.message);
-                                is_need_geetest=errorData.responseJSON.errors.is_need_geetest;
-                            }
-                        }
-                    });
-                }
             };
 
         });
 
-        // 倒计时
-        var countdown = 60;
-        function settime() {
-            if (countdown == 0) {
-                $('.btn-getcode').prop("disabled", false);
-                $('.btn-getcode').removeClass('btn-disabled');
-                $('.btn-getcode').val('获取验证码');
-                countdown = 60;
-                return;
-            } else {
-                $('.btn-getcode').prop("disabled", true);
-                $('.btn-getcode').addClass('btn-disabled');
-                $('.btn-getcode').val('重新发送' + countdown + '秒');
-                countdown--;
-            }
-            setTimeout(function() {
-                settime()
-            },1000)
-        }
 
         $('.gohome').on('click', function () {
             location.href="{{route($sub_site.'home')}}";

+ 33 - 170
public/themes/default/views/mobile/app/auth/login_mobile.blade.php

@@ -139,8 +139,6 @@
                 });
             };
 
-            //gt_init(gt_call_back);//初始化极验
-
             var mobile_captcha_flag = false;
             var mobile_captcha_callback = function(res){
                 if(res.hasOwnProperty('errorMessage')){
@@ -220,7 +218,7 @@
                 login_type=2;
 
                 if (mobile_captcha_flag){
-                    ajax_login(2);
+                    ajax_login();
                 }
                 else{
                     alert('验证码组件异常')
@@ -244,180 +242,45 @@
                     $('#autoLogin').val('0');
                 }
             })
-            {{--$('.btn-getcode').on('click', function () {--}}
-            {{--    var mobile = $.trim($('input[name=mobile]').val());--}}
-            {{--    if (mobile == '') {--}}
-            {{--        qsToast({type:2,context: '请输入手机号码'});--}}
-            {{--        return false;--}}
-            {{--    }--}}
-            {{--    if ($('#getVerfyCode').hasClass('qs-btn-border-disabled')) {--}}
-            {{--        return false;--}}
-            {{--    }--}}
-            {{--    $('#getVerfyCode').addClass('qs-btn-border-disabled');--}}
-            {{--    $('#getVerfyCode').text('发送中...');--}}
-            {{--    submit_data={--}}
-            {{--        "mobile":mobile,--}}
-            {{--        "type":"login"--}}
-            {{--    };--}}
-            {{--    $.ajax({--}}
-            {{--        type: 'post',--}}
-            {{--        url: '{{route('sms.send')}}',--}}
-            {{--        data: submit_data,--}}
-            {{--        beforeSend:function () {--}}
-            {{--           // console.log('请求开始');--}}
-
-
-            {{--        },--}}
-            {{--        complete:function() {--}}
-            {{--            //console.log('请求结束');--}}
-            {{--        },--}}
-            {{--        success: function (data) {--}}
-            {{--           // console.log(data);--}}
-            {{--            qsToast({type:2,context: '验证码已发送,请注意查收'});--}}
-            {{--            settime();--}}
-            {{--        },--}}
-            {{--        error: function (errorData) {--}}
-            {{--           // console.log(errorData);--}}
-            {{--            if (countdown == 60) {--}}
-            {{--                $('#getVerfyCode').removeClass('qs-btn-border-disabled');--}}
-            {{--                $('#getVerfyCode').text('获取验证码');--}}
-            {{--            }--}}
-            {{--            var response=$.parseJSON(errorData.response);--}}
-            {{--            if (errorData.status==422) {//验证错误--}}
-            {{--                $.each(response.errors,function (key,val) {--}}
-            {{--                    qsToast({type:2,context: val[0]});--}}
-            {{--                    return false;--}}
-            {{--                });--}}
-            {{--            }--}}
-            {{--            else if(errorData.status==400) {//业务错误--}}
-            {{--                qsToast({type:2,context: response.message});--}}
-            {{--                is_need_geetest=response.errors.is_need_geetest;--}}
-            {{--            }--}}
-            {{--        }--}}
-            {{--    });--}}
-            {{--});--}}
 
 
-            function ajax_login(type, captchaObj) {
-                if (type==1) {
-                    $.ajax({
-                        type: 'post',
-                        url: $("#form_account").attr('action'),
-                        data: $("#form_account").serialize(),
-                        beforeSend:function () {
-                            //console.log('请求开始');
-                            clean_message();
-                            $('.login-account').addClass("btn-disabled").prop('disabled', true);
-                            $('.login-account').val("登录中...");
-
-                        },
-                        complete:function() {
-                            //console.log('请求结束');
-                            $('.login-account').val("登录");
-                            $('.login-account').removeClass("btn-disabled").prop('disabled', false);
 
-                        },
-                        success: function (data) {
-                            //console.log(data);
-                            qsToast({type:2,context: "登录成功, 正在跳转..."});
-                            location.href=data.data.redirect_url+'?token='+data.data.token;;
-                        },
-                        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]});
-                                    return false;
-                                });
-                            }
-                            else if(errorData.status==400) {//业务错误
-                                qsToast({type:2,context: response.message});
-                                is_need_geetest=response.errors.is_need_geetest;
-                            }
+            function ajax_login() {
+
+                $.ajax({
+                    type: 'post',
+                    url: $("#form_mobile").attr('action'),
+                    data: $("#form_mobile").serialize(),
+                    beforeSend:function () {
+                        //console.log('请求开始');
+                    },
+                    complete:function() {
+                        //console.log('请求结束');
+                    },
+                    success: function (data) {
+                        //console.log(data);
+                        qsToast({type:2,context: "登录成功, 正在跳转..."});
+                        location.href=data.data.redirect_url+'?token='+data.data.token;;
+                    },
+                    error: function (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]});
+                                return false;
+                            });
                         }
-                    });
-                }
-                else if (type==2) {
-                    $.ajax({
-                        type: 'post',
-                        url: $("#form_mobile").attr('action'),
-                        data: $("#form_mobile").serialize(),
-                        beforeSend:function () {
-                            //console.log('请求开始');
-                        },
-                        complete:function() {
-                            //console.log('请求结束');
-                        },
-                        success: function (data) {
-                            //console.log(data);
-                            qsToast({type:2,context: "登录成功, 正在跳转..."});
-                            location.href=data.data.redirect_url+'?token='+data.data.token;;
-                        },
-                        error: function (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]});
-                                    return false;
-                                });
-                            }
-                            else if(errorData.status==400) {//业务错误
-                                qsToast({type:2,context: response.message});
-                                //is_need_geetest=response.errors.is_need_geetest;
-                            }
+                        else if(errorData.status==400) {//业务错误
+                            qsToast({type:2,context: response.message});
+                            //is_need_geetest=response.errors.is_need_geetest;
                         }
-                    });
-                }
-                else if (type==3){
-                    $.ajax({
-                        method: 'post',
-                        url: $("#form_company").attr('action'),
-                        data: $("#form_company").serialize(),
-                        beforeSend:function () {
-                            //console.log('请求开始');
-                            clean_message();
-                            $('.login-company').addClass("btn-disabled").prop('disabled', true);
-                            $('.login-company').val("登录中...");
+                    }
+                });
 
-                        },
-                        complete:function() {
-                            //console.log('请求结束');
-                            $('.login-company').val("登录");
-                            $('.login-company').removeClass("btn-disabled").prop('disabled', false);
 
-                        },
-                        success: function (data) {
-                            //console.log(data);
-                            $("#message_company").addClass("successinfo");
-                            $("#message_company").text("登录成功, 正在跳转...");
-                            location.href=data.data.redirect_url+'?token='+data.data.token;;
-                        },
-                        error: function (errorData) {
-                            //console.log(errorData);
-                            if (is_need_geetest==1){
-                                captchaObj.reset();
-                            }
-                            if (errorData.status==422) {//验证错误
-                                $.each(errorData.responseJSON.errors,function (key,val) {
-                                    $("#"+key).addClass("errinfo");
-                                    $("#"+key).text(val[0]);
-                                });
-                            }
-                            else if(errorData.status==400) {//业务错误
-                                $("#message_company").addClass("errinfo");
-                                $("#message_company").text(errorData.responseJSON.message);
-                                is_need_geetest=errorData.responseJSON.errors.is_need_geetest;
-                            }
-                        }
-                    });
-                }
             };