<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="all,follow">

    <title>后台管理系统</title>
    <!-- <link rel="shortcut icon" href="img/favicon.ico"> -->

    <!-- global stylesheets -->
    {{--<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">--}}
    <link rel="stylesheet" href="{{ asset('xadmin/css/bootstrap.min.css')}}">
{{--    <link rel="stylesheet" href="{{ asset('xadmin/font-awesome-4.7.0/css/font-awesome.min.css')}}">--}}
    {{--<link rel="stylesheet" href="{{ asset('xadmin/css/font-icon-style.css')}}">--}}
    <link rel="stylesheet" href="{{ asset('xadmin/css/style.default.css')}}" id="theme-stylesheet">
{{--    <link rel="stylesheet" href="{{ asset('xadmin/extra/bootstrapvalidator-master/dist/css/bootstrapValidator.css')}}">--}}


    <!-- Core stylesheets -->
    <link rel="stylesheet" href="{{ asset('xadmin/css/pages/login.css')}}">
    <style>
        form.cmxform label.error, label.error {
            /* remove the next line when you have trouble in IE6 with labels in list */
            color: red;
            font-style: italic;
            margin-top: 11px;
        }
    </style>
</head>

<body>
<script type="application/javascript" >
    var str = window.location.host;
    str = str .toLowerCase ();
    if(str.indexOf("dimpt") != -1 || str.indexOf("114")!= -1)
    {
        window.location = "/home";
    }

</script>
<!--====================================================
                        PAGE CONTENT
======================================================-->
<section class="hero-area">
    <div class="overlay"></div>
    <div class="container">
        <div class="row">
            <div class="col-md-12 ">
                <div class="contact-h-cont">
                    <form id="defaultForm" autocomplete="off">
                        <input type="hidden" name="_token" value="{{csrf_token()}}">
                        <div class="form-group">
                            <label for="username">用户名</label>
                            <input type="text" class="form-control" id="username" name="username" value=""
                                   placeholder="用户名" autocomplete="off">
                        </div>
                        <div class="form-group">
                            <label for="exampleInputEmail1">密码</label>
                            <input class="form-control" type="password" id="password" name="password" value=""
                                   id="example-password-input" placeholder="密码" autocomplete="off">
                        </div>
                        <button class="btn btn-general btn-blue" type="submit" onclick="login();">
                            <i fa fa-right-arrow></i>登录
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</section>
<!--Global Javascript -->
<script src="{{ asset('xadmin/js/jquery.min.js')}}"></script>
<script src="{{ asset('xadmin/js/jquery.cookie.js')}}"></script>
<script src="{{ asset('xadmin/js/jquery.validate.js')}}"></script>
<script src="{{ asset('xadmin/js/common.js')}}"></script>
<script src="{{ asset('xadmin/extra/toast/js/toast.js')}}"></script>

<script>
    function login() {

        $("#defaultForm").validate({
            rules: {
                username: {
                    required: true,
                    // minlength: 2
                },
                password: {
                    required: true,
                    // minlength: 5
                },

            },
            messages: {
                username: {
                    required: "用户名不能为空",
                    // minlength: "Your username must consist of at least 2 characters"
                },
                password: {
                    required: "密码不能为空",
                    // minlength: "Your password must be at least 5 characters long"
                },

            },
            submitHandler: function (form) {
                var form = document.querySelector("#defaultForm");
                var formdata = new FormData(form);

                fetch_response('POST', '/web/login', formdata).then(function (res) {
                    if (res.code == 200) {
                        $('body').toast({
                            position: 'fixed',
                            content: res.msg,
                            duration: 1000,
                            top: '50%'
                        });

                        setTimeout(function () {

                            window.location.href = '/web/admin';
                        }, 2000)

                    } else {
                        $('body').toast({
                            position: 'fixed',
                            content: res.msg,
                            duration: 1000,
                            top: '50%'
                        });
                    }
                });
            }
        });

    }



    // Validate the form manually
    // $('#validateBtn').click(function () {
    //     $('#defaultForm').bootstrapValidator('validate');
    //
    //     $.ajax({
    //         url: '/web/login',
    //         data: {
    //             name: $('#username').val(),
    //             password: $('#password').val()
    //         },
    //         type: 'post',
    //         dataType: 'json',
    //         success: function (res) {
    //             // console.log('res',res)
    //             if (res.code == 200) {
    //                 window.location.href = '/web/admin';
    //             } else {
    //                 verifyCode.refresh();
    //                 layer.msg(res.msg, {icon: 5});
    //             }
    //
    //
    //         }
    //     })
    //
    //
    // });

</script>
</body>

</html>