login.html
5.47 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>调派系统 -登录</title>
<link href="/assets/uikit-3.0.0/css/uikit.min.css" rel="stylesheet" type="text/css"/>
<style>
html, body, .ct-container {
height: 100%;
}
.ct-container {
}
.login_form_panel {
width: 450px;
height: 420px;
position: absolute;
top: 50%;
left: 50%;
margin-left: -225px;
margin-top: -300px;
text-align: center;
color: #333;
padding-bottom: 56px;
transition: all .3s ease;
overflow: hidden;
}
.login_form_panel .uk-card-title {
font-family: 华文楷体, 华文细黑;
font-size: 28px;
font-weight: 600;
color: #4a4a4a;
margin-bottom: 15px;
}
.login-form {
margin-top: 40px;
}
.login-form .uk-margin {
margin-bottom: 30px;
}
.login-form .uk-margin .uk-inline {
width: 90%;
}
input::-webkit-input-placeholder {
font-size: 13px;
color: #9c9898 !important;
}
.ct_desc_info {
font-size: 13px;
color: #f74d4d;
transition: all .3s ease;
position: absolute;
bottom: -20px;
left: 0;
width: 100%;
}
.ct_desc_info.show {
bottom: 10px;
}
.ct_desc_info.show.success{
color: #2196F3;
}
</style>
</head>
<body>
<div class="ct-container">
<div class="uk-card uk-card-default uk-card-body login_form_panel">
<h3 class="uk-card-title">智能场站调派系统</h3>
<small style="color: #909090;">高科西路停车场</small>
<form class="login-form">
<div class="uk-margin">
<div class="uk-inline">
<span class="uk-form-icon" uk-icon="icon: user"></span>
<input class="uk-input" type="text" placeholder="输入用户名" name="userName" autofocus>
</div>
</div>
<div class="uk-margin">
<div class="uk-inline">
<span class="uk-form-icon" uk-icon="icon: lock"></span>
<input class="uk-input" type="password" name="password" placeholder="输入密码">
</div>
</div>
<div class="uk-margin">
<button type="submit" class="uk-button uk-button-primary uk-button-large uk-width-1-1 ">登录</button>
</div>
<span class="ct_desc_info"></span>
</form>
</div>
</div>
<script src="/assets/plugins/jquery.min.js"></script>
<script src="/assets/uikit-3.0.0/js/uikit.min.js"></script>
<script src="/assets/uikit-3.0.0/js/uikit-icons.min.js"></script>
<script src="/assets/plugins/jquery.serializejson.js"></script>
<script src="/assets/plugins/jsencrypt.min.js"></script>
<script>
(function () {
var $loginBtn = $('[type=submit]', '.login-form');
$('form').on('submit', function () {
return false;
});
var keys;
$.get('/user/login/jCryptionKey?t=' + Math.random(), function (data) {
keys = data.publickey;
});
//登录
$loginBtn.on('click', function () {
//前端数据校验
if (checkIn()) {
$(this).attr('disabled', 'disabled');
var data = $('.login-form').serializeJSON();
//RSA加密
var encrypt = new JSEncrypt();
encrypt.setPublicKey(keys);
data.userName = encrypt.encrypt(data.userName);
data.password = encrypt.encrypt(data.password);
//登录
login(data);
}
});
var lock;
function login(data) {
lock = true;
$('#loginBtn').attr('disabled', 'disabled');
$.post('/user/login', data, function (rs) {
if (error(rs)) {
lock = false;
showMsg('登录失败,' + rs.msg);
$loginBtn.removeAttr('disabled');
}
else {
showMsg('登录成功', true);
window.location.href = '/';
}
});
}
var checkIn = function () {
var data = $('.login-form').serializeJSON();
if (!data.userName) {
shakeInput('userName');
return false;
}
else if (!data.password) {
shakeInput('password');
return false;
}
return true;
};
var shakeInput = function (name) {
$('[name=' + name + ']', '.login-form').addClass('uk-animation-shake');
}
$('input', '.login-form').on('webkitAnimationEnd', function () {
$(this).removeClass('uk-animation-shake');
});
var showMsg = function (t, success) {
if(success)
$('.ct_desc_info').addClass('success');
else
$('.ct_desc_info').removeClass('success');
$('.ct_desc_info').addClass('show').text(t);
};
function error(rs){
return rs.status == 'ERROR' || rs.status == 500;
}
})();
</script>
</body>
</html>