<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="csrf-token" content="{{ csrf_token() }}" />
  <title>{{trans('cs.login.title')}}</title>
  <link rel="stylesheet" href="/assets/vendors/iconfonts/mdi/css/materialdesignicons.min.css">
  <link rel="stylesheet" href="/assets/vendors/css/vendor.bundle.base.css">
  <link rel="stylesheet" href="/assets/css/style.css">
  <link rel="shortcut icon" href="/assets/images/favicon.png" />
</head>

<body>
  <div class="container-scroller">
    <div class="container-fluid page-body-wrapper full-page-wrapper">
      <div class="content-wrapper d-flex align-items-center auth">
        <div class="row w-100">
          <div class="col-lg-4 mx-auto">
            <div class="auth-form-light text-left p-5">
              <div class="brand-logo">
{{--                <img src="/uploads/config/20181107/5be269ef937d1.png">--}}
              </div>
              <form class="pt-3">
                <div class="form-group">
                  <input type="text" class="form-control form-control-lg" id="account" placeholder="{{trans('cs.login.notice_user')}}">
                </div>
                <div class="form-group">
                  <input type="password" class="form-control form-control-lg" id="password" placeholder="{{trans('cs.login.notice_pass')}}">
                </div>
                <div class="form-group">
                  <input type="text" class="form-control form-control-lg" id="ga_code" name="ga_code" autocomplete="off" maxlength="6" placeholder="手机验证码">
                </div>
                <div class="form-group">
                  <div class="input-group">
                    <input type="text" class="form-control form-control-lg" id="captcha" name="captcha" autocomplete="off" maxlength="6" placeholder="{{ trans('cs.login.captcha_placeholder') }}">
                    <div class="input-group-append">
                      <span class="input-group-text p-0 border-0 bg-transparent" style="cursor:pointer;" onclick="refreshCaptcha()" title="{{ trans('cs.login.captcha_refresh') }}">
                        <img id="captcha-img" src="/admin/login_captcha" alt="captcha" style="height:48px;border-radius:4px;">
                      </span>
                    </div>
                  </div>
                </div>

                <div class="mb-2">
                  <button type="button" onclick="login()" class="btn btn-gradient-info btn-lg btn-block">
                      {{trans('cs.login.btn')}}
                  </button>
                </div>
                <div class="text-center mt-4 font-weight-light">

                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <script src="/assets/vendors/js/vendor.bundle.base.js"></script>
  <script src="/assets/vendors/js/vendor.bundle.addons.js"></script>
  <script src="/assets/js/off-canvas.js"></script>
  <script src="/assets/js/misc.js"></script>
  <script src="/assets/js/jquery-3.0.0.min.js"></script>
  <script src="/assets/layer/layer.js"></script>
  <script src="/assets/js/common.js"></script>
</body>
<script>

    document.onkeydown=keyListener;
    function keyListener(e){
        if(e.keyCode == 13){
            login();
        }
    }

    function refreshCaptcha(){
        $('#captcha-img').attr('src', '/admin/login_captcha?t=' + Date.now());
    }

    function login(){
        var account = $("#account").val();
        var password = $("#password").val();
        var gaCode = $("#ga_code").val();
        var captcha = $("#captcha").val();
        if(!account || !password){
            layer.msg('账号和密码不能为空', function(){});
            return false;
        }
        if(!captcha){
            layer.msg(@json(trans('cs.login.notice_captcha')), function(){});
            return false;
        }
        var data = {
            'account':account,
            'password':password,
            'ga_code':gaCode,
            'captcha':captcha,
        };
        myRequest("/admin/login_op","post",data,function(res){
            if(res.code == '200'){
                layer.msg(res.msg)
                setTimeout(function(){
                    window.location.href="/admin/bx_nb";
                },1500)
            }else{
                layer.msg(res.msg)
                refreshCaptcha();
                $("#captcha").val('');
            }
        });
    }
</script>

</html>
