login.html 12.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta charset="utf-8" />
    <title data-i18n="">$$$$$${txt-4037}</title>
    <link
            href="/metronic_v4.5.4/plugins/font-awesome/css/font-awesome.min.css"
            rel="stylesheet" type="text/css" />
    <!-- Bootstrap style -->
    <link href="/metronic_v4.5.4/plugins/bootstrap/css/bootstrap.min.css"
          rel="stylesheet" type="text/css" />

    <!-- METRONIC style -->
    <link href="/metronic_v4.5.4/css/components.css" rel="stylesheet"
          type="text/css" />

    <style type="text/css">
        body>.wrapper {
            background-image: url(/assets/img/bg_9b9dcb65ff.png);
            background-size: 100px;
            background-repeat: repeat;
            min-height: 800px;
            min-width: 630px;
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
        }

        #loginPanel.dialog-shadow {
            width: 450px;
            /* height: 400px; */
            border: 1px solid #dadada;
            border-radius: 10px !important;
            position: absolute;
            box-shadow: 0 9px 30px -6px rgba(0, 0, 0, .2), 0 18px 20px -10px
            rgba(0, 0, 0, .04), 0 18px 20px -10px rgba(0, 0, 0, .04), 0 10px 20px
            -10px rgba(0, 0, 0, .04);
            background: url(/assets/img/dialog-gray-bg_42c40b3eb6.png) #fff bottom
            repeat-x;
            top: 50%;
            left: 50%;
            margin-left: -225px;
            margin-top: -300px;
            text-align: center;
            color: #333;
            opacity: .5;

            padding-bottom: 56px;

            animation: to_center 1s forwards;
            animation-delay: .2s;

            transition: all .3s ease;
        }

        @keyframes to_center
        {
            0%   {margin-top: -300px;opacity: .5;}
            100% {margin-top: -270px;opacity: 1;}
        }


        h3 {
            font-size: 25px;
            font-weight: 600;
            color: #4a4a4a
        }

        .input-icon input {
            height: 48px;
            border-radius: 5px !important;
            transition: all .5s ease;
        }

        .input-icon input:FOCUS {
            border-color: #c2cad8;
            box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12) !important;
        }

        .input-icon>i {
            margin-top: 16px;
        }

        #loginPanel #loginBtn.btn{
            border-radius: 6px !important;
            width: 378px;
            height: 48px;
            font-size: 20px;
            font-family: 微软雅黑;
            transition: all .3s ease;

            background: #5f7ed7;
            background: linear-gradient(#6f97e5,#527ed9);
            box-shadow: inset 0 1px 2px #7ea1e8 !important;
            color: #fff;
            text-shadow: #4f70b3 0 -1px 0;
            border: none;
        }

        #loginPanel #loginBtn.btn:HOVER {
            box-shadow: inset 0 1px 1px #7696de,inset 0 0 2px #627dca,inset 0 -2px 3px #5a77c7,inset 0 0 100px rgba(48,77,147,.4) !important;
        }


        #loginPanel.show_msg{
            top: calc(50% - 10px);
        }

        #loginPanel .alert{
            display: none;
            padding: 12px;
            margin-top: 21px;
            border-radius: 0 0 10px 10px !important;
            font-size: 13px;

            position: absolute;
            width: 100%;
            border-bottom: 1px solid #dadada;
        }

        #loginPanel .alert.login-success{
            color: #27a4b0;
            background: #abe7ed;
            border-color: #abe7ed;
        }

        #loginPanel .alert i{
            font-size: 16px;
            vertical-align: middle;
            margin: 0 5px 3px;
        }

        #loginPanel.show_msg .alert{
            display: block;
        }

        #captchaWrap{
            display: none;
            text-align: left;
            border-top: 1px solid #f3f2f2;
        }

        img.captcha-img{
            cursor: pointer;
        }

        .login-footer{
            position: fixed;
            width: 100%;
            bottom: 35px;
            text-align: center;
            color: #a6a6a6;
        }

        h3.logo-text{
            font-family: 华文楷体,华文细黑;
            font-size: 28px;
        }

        .warn-note{
            width: 100%;
            position: absolute;
            top: 0;
            z-index: 2;
            text-align: center;
            background: #ff4646;
            color: white;
            padding: 12px;
            display: none;
        }
    </style>
</head>

<body>
<div class="warn-note" data-i18n="">$$$$$${txt-177}</div>
<div class="wrapper ng-scope">
    <div id="loginPanel" class="dialog dialog-shadow">
        <br>
        <h3 class="logo-text" data-i18n="">$$$$$${txt-1373}</h3>
        <hr>
        <form style="padding: 0px 35px;">
            <div class="form-group" style="margin-bottom: 0">
                <label></label>
                <div class="input-icon">
                    <i class="fa fa-user font-gray"></i> <input type="text"
                                                                name="userName" class="form-control" placeholder="$$$$$${txt-2372}"
                                                                autofocus="autofocus" autocomplete="off" data-i18n="placeholder">
                </div>
            </div>

            <div class="form-group">
                <label></label>
                <div class="input-icon">
                    <i class="fa fa-key font-gray"></i> <input type="password"
                                                               name="password" class="form-control" placeholder="$$$$$${txt-3406}" data-i18n="placeholder">
                </div>
            </div>

            <div class="form-group" id="captchaWrap">
                <label></label>
                <div class="input-icon">
                    <input type="text" name="captcha" style="width: 153px !important;"
                           class="form-control input-inline input-medium"
                           placeholder="$$$$$${txt-2321}" data-i18n="placeholder"> <span class="help-inline"> <img class="captcha-img" title="$$$$$${txt-1237}" data-i18n="title">
						</span>
                </div>
            </div>
        </form>
        <br>
        <br>
        <div class="form-actions">
            <button class="btn blue-steel" id="loginBtn" disabled="disabled" data-i18n="">$$$$$${txt-4037}</button>
        </div>

        <div class="alert alert-danger"></div>
    </div>

    <div class="login-footer">© 2016 上海巴士拓华科技发展有限公司 Some Rights
        Reserved</div>
</div>

<script>
    delete window.require;
    delete window.exports;
    delete window.module;
</script>
<!-- jQuery -->
<script src="/metronic_v4.5.4/plugins/jquery.min.js"></script>
<script src="/assets/plugins/jsencrypt.min.js"></script>
<script>
    window.onload=function(){
        var body=document.getElementsByTagName("body")[0];
        if(typeof body.style.WebkitAnimation=="undefined")
            $('.warn-note').fadeIn();
    };

    var message = {};
    function i18n(key) {
        return message[key];
    }
    function i18n4dom(data) {
        message = data;
        $('*[data-i18n]').each(function () {
            var prop = $(this).data('i18n'), html = '';
            html = prop ? $(this).prop(prop) : $(this).html();
            if (!html) {
                return;
            }
            var key = '', start = html.indexOf('$$$$$${'), end;
            while (start > -1) {
                end = html.indexOf('}', start);
                if (end == -1) {
                    throw new Error('[' + html + '] i18n表达式异常')
                }
                key = html.substring(start + 7, end);
                html = html.replaceAll(html.substring(start, end + 1), i18n(key));
                start = html.indexOf('$$$$$${');
            }
            prop ? $(this).prop(prop, html) : $(this).html(html);
        })
    }

    !function(){
        var form = $('#loginPanel form')
                ,nameInput = $('input[name=userName]', form)
                ,pwdInput = $('input[name=password]', form)
                ,msgAlert = $('#loginPanel .alert-danger');

        $('input', form).on('keyup', checkBtnStatus);

        var keys;
        $.get('/user/login/jCryptionKey?t='+Math.random(), function(data){
            keys = data.publickey;
        });



        function checkBtnStatus(){
            var es = $('input:visible', form);
            for(var i = 0, e; e = es[i++];){
                if($.trim($(e).val()) == ''){
                    $('#loginBtn').attr('disabled', 'disabled');
                    $('#loginPanel').removeClass('show_msg');
                    return;
                }
            }
            $('#loginBtn').removeAttr('disabled');
        }

        nameInput.on('blur', checkStatus);
        //keyup 事件做延迟
        var uNameKeyup;
        nameInput.on('keyup', function(){
            if(uNameKeyup)
                return;
            uNameKeyup = true;
            setTimeout(function(){
                checkStatus();
                uNameKeyup = false;
            }, 200);
        });

        //密码框回车事件
        pwdInput.on('keyup', function(e){
            if (e.keyCode == 13)
                $('#loginBtn').click();
        });
        //验证码框回车事件
        $('input[name=captcha]').on('keyup', function(e){
            if (e.keyCode == 13)
                $('#loginBtn').click();
        });

        $('#loginBtn').on('click', function(){
            if(lock || $(this).attr('disabled')) return;
            var userName = nameInput.val()
                    ,pwd = pwdInput.val();

            //RSA加密
            var encrypt = new JSEncrypt();
            encrypt.setPublicKey(keys);
            userName = encrypt.encrypt(userName);
            pwd = encrypt.encrypt(pwd);
            //登录
            login(userName, pwd);
        });

        var lock;
        function login(userName, pwd){
            lock = true;
            $('#loginBtn').attr('disabled', 'disabled');

            var params = {
                userName: userName,
                password: pwd,
                captcha: $('input[name=captcha]').val()
            };
            $.post('/user/login', params
                    ,function(rs){

                        $('#loginPanel').addClass('show_msg');
                        if(error(rs)){
                            lock = false;
                            $('#loginBtn').removeAttr('disabled');
                            msgAlert.html('<i class="fa fa-times-circle"> </i> ' + i18n('txt-2331') + rs.msg);

                            _captcha.refresh();
                            checkStatus();
                        }
                        else{
                            msgAlert.html('<i class="fa fa-check"> </i> ' + i18n('txt-3323'));
                            msgAlert.addClass('login-success');
                            window.location.href = '/';
                        }
                    });
        }

        function checkStatus(){
            var t = nameInput.val();
            if(!t){
                hide();
                return;
            }

            $.get('/user/login/captchaStatus', {userName: t}, function(rs){
                if(rs > 1)
                    _captcha.show();
                else
                    hide();
            });

            function hide(){
                if(!$("#captchaWrap").is(":hidden")){
                    _captcha.hide();
                    //隐藏提示消息
                    //msgAlert.html('');
                    //$('#loginPanel').removeClass('show_msg');
                }
            }
        }


        var _captcha = {
            show: function(){
                if($("#captchaWrap").is(":hidden")){
                    $('#captchaWrap').fadeIn(500);
                    _captcha.refresh();
                    checkBtnStatus();
                }
            },
            refresh: function(){
                if($("#captchaWrap").is(":hidden"))
                    return;
                $('#captchaWrap img.captcha-img').attr('src', '/captcha.jpg?t=' + Math.random());
            },
            hide: function(){
                $('#captchaWrap').hide();
                $('input[name=captcha]').val('');
            }
        };

        $('#captchaWrap img.captcha-img').on('click', function(){
            $(this).attr('src', '/captcha.jpg?t=' + Math.random());
        });

        function error(rs){
            return rs.status == 'ERROR' || rs.status == 500;
        }

        $.get('/i18n/login', function (data) {
            i18n4dom(data);
        })
    }();
</script>
</body>
</html>