-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.html
80 lines (73 loc) · 3.13 KB
/
login.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.10.15/themes/ui-cupertino/easyui.css">
<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.10.15/themes/icon.css">
<link rel="stylesheet" type="text/css" href="css/layout.css">
<script type="text/javascript" src="/js/jquery-easyui-1.10.15/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery-easyui-1.10.15/jquery.easyui.min.js"></script>
<style>
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.form {
width: 400px;
height: auto;
}
</style>
</head>
<body>
<div class="container">
<div class="form">
<div class="easyui-panel" title="Login" style="width:350px;padding:30px 60px;">
<form id="login-form" method="post">
<div style="margin-bottom:20px">
<input class="easyui-textbox" type="text" name="login" label="login:" style="width:100%;"
required>
</div>
<div style="margin-bottom:20px">
<input class="easyui-passwordbox" type="password" name="password" label="Password:"
style="width:100%;" required>
</div>
<div style="text-align:center;padding:5px 0;">
<button type="button" class="easyui-linkbutton" style="width:80px"
onclick="doLogin()">Login</button>
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript">
function doLogin() {
const form = document.querySelector('#login-form');
//const messageDiv = document.createElement('div');
//e.preventDefault();
const formData = new FormData(form);
fetch('http://localhost:8084/api/v1/public/login', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(result => {
console.log(result)
if (result.code == "SUCCESS") {
localStorage.setItem("token",result.token)
localStorage.setItem("users",JSON.stringify(result.rows))
localStorage.setItem("user",JSON.stringify(result.user))
location.href = '/?token='+result.token; // ganti dengan URL yang benar
} else {
$.messager.alert('Error', result.message, 'error');
}
})
.catch(error => console.error(error));
}
</script>
</body>
</html>