login.js
1.2 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
/**
* login page
*/
$("#verifyCode").keydown(function(event) {
if (event.which == 13) {
onLoginAction();
}
});
function onLoginAction() {
var username = $("#username").val();
var password = $("#password").val();
var verifyCode = $("#verifyCode").val();
if (isEmpty(username)) {
$("#tipView").html("请输入账号");
$("#tipDialog").modal('show');
} else if (isEmpty(password)) {
$("#tipView").html("请输入密码");
$("#tipDialog").modal('show');
} else if (isEmpty(verifyCode)) {
$("#tipView").html("请输入验证码");
$("#tipDialog").modal('show');
} else {
var encryPasswd = sha256_digest(password);
login(username, encryPasswd, verifyCode);
}
}
function login(username, password, verifyCode) {
var params = "username=" + username + "&password=" + password
+ "&verifyCode=" + verifyCode;
$.post(CONTEXT_PATH + "/sysUser/login", params, function(response, status) {
console.log(JSON.stringify(response));
try {
if (response.code == HTTP_OK) {
location.href = CONTEXT_PATH + "/";
} else {
$("#tipView").html(response.msg);
$("#tipDialog").modal('show');
// 刷新验证码
var codeImage = document.getElementById('codeImage');
codeImage.click();
}
} catch (e) {
}
});
}