-
Notifications
You must be signed in to change notification settings - Fork 5
/
admin.html
53 lines (49 loc) · 1.64 KB
/
admin.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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>梁同桌的博客</title>
</head>
<body>
<!-- 大盒子 -->
<div class="layout">
<input id="password" type="password" />
<input id="login" type="submit" value="登陆" />
<input id="zhuce" type="submit" value="注册" />
</div>
<!-- /大盒子 -->
<script src="lib/av.js"></script>
<script src="js/config.js"></script>
<script>
var password = document.getElementById('password');
document.getElementById('login').addEventListener('click', function() {
if (AV.User.current()) {
window.location.href = "index.html";
return;
}
//注册过登陆
AV.User.logIn('admin', password.value).then(function(loginedUser) {
window.location.href = "index.html";
}, function(error) {
alert('登陆失败');
});
}, false);
document.getElementById('zhuce').addEventListener('click', function() {
if (AV.User.current()) {
window.location.href = "index.html";
return;
}
var user = new AV.User();
// 设置用户名
user.setUsername('admin');
user.setPassword(password.value);
user.signUp().then(function(loginedUser) {
window.location.href = "index.html";
}, function(error) {
alert('注册失败');
});
}, false);
</script>
</body>
</html>