-
Notifications
You must be signed in to change notification settings - Fork 5
/
刘嘉鹏-20281319.html
205 lines (185 loc) · 6.98 KB
/
刘嘉鹏-20281319.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
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
<!DOCTYPE html>
<!-- 刘嘉鹏 20281319 -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login and Register</title>
</head>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: Arial, sans-serif;
background: white url(https://remilia-bucket01.oss-cn-beijing.aliyuncs.com/my_pic/background.png);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.container {
width: 400px;
background-color: white;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 0 10px rgb(21, 255, 0);
}
.tabs {
display: flex;
}
.tabs button {
flex: 1;
padding: 15px;
text-align: center;
cursor: pointer;
transition: background-color 0.3s ease;
}
.tabs button:hover {
background-color: #f1f1f1;
}
.tabs button.active {
background-color: #ccc;
}
.content {
padding: 20px;
}
.register-form {
display: none;
}
.form-control {
display: flex;
margin-bottom: 20px;
}
.form-control label {
width: 50px;
display: block;
margin-top: 5px;
margin-left: 5px;
font-weight: bold;
}
.form-control input {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-control input[type="submit"] {
background-color: #4CAF50;
color: white;
cursor: pointer;
}
.login_icon {
width: 20px;
}
</style>
<body>
<div class="container">
<div class="tabs">
<button id="loginButton" class="active">账号登录</button>
<button id="registerButton">注册</button>
</div>
<div class="content">
<form id="loginForm" class="login-form">
<div class="form-control">
<label for="loginUsername">
<img class="login_icon" src="https://remilia-bucket01.oss-cn-beijing.aliyuncs.com/my_pic/user_icon.svg" alt="用户名">
</label>
<input type="text" name="username" id="loginUsername" placeholder="请输入用户名" required>
</div>
<div class="form-control">
<label for="loginPassword">
<img class="login_icon" src="https://remilia-bucket01.oss-cn-beijing.aliyuncs.com/my_pic/password_icon.svg" alt="密码">
</label>
<input type="password" name="password" id="loginPassword" placeholder="请输入密码" required
autocomplete="off">
</div>
<div class="form-control">
<input type="submit" value="登录" onclick="loginCheck()">
<input type="reset" value="重置">
</div>
</form>
<form id="registerForm" class="register-form">
<div class="form-control">
<label for="registerName">
<img class="login_icon" src="https://remilia-bucket01.oss-cn-beijing.aliyuncs.com/my_pic/user_icon.svg" alt="用户名">
</label>
<input type="text" name="username" id="registerName" required placeholder="输入用户名">
</div>
<div class="form-control">
<label for="registerEmail">
<img class="login_icon" src="https://remilia-bucket01.oss-cn-beijing.aliyuncs.com/my_pic/email_icon.svg" alt="邮箱">
</label>
<input type="email" name="email" id="registerEmail" required placeholder="输入邮箱">
</div>
<div class="form-control">
<label for="registerPassword">
<img class="login_icon" src="https://remilia-bucket01.oss-cn-beijing.aliyuncs.com/my_pic/password_icon.svg" alt="密码">
</label>
<input type="password" name="password" id="registerPassword" required autocomplete="off"
placeholder="输入密码">
</div>
<!-- <div class="form-control">
<label for="registerPasswordCheck">
<img class="login_icon" src="images/password_icon.svg" alt="密码">
</label>
<input type="password" name="passwordCheck" id="registerPasswordCheck" required autocomplete="off"
placeholder="确认密码">
</div>-->
<div class="form-control">
<input type="submit" value="注册" onclick="registerCheck()">
</div>
</form>
</div>
</div>
<script>
const my_username = "20281319";
const my_password = "123456";
function loginCheck() {
const form = document.querySelector('#loginForm');
const formData = new FormData(form);
const username = formData.get('username');
const password = formData.get('password');
console.log(username + ": " + password);
if (username === my_username && password === my_password) {
window.alert("用户名密码校验成功!");
} else {
window.alert("用户名或密码错误!")
}
}
function registerCheck() {
const form = document.querySelector('#registerForm');
const formData = new FormData(form);
const username = formData.get('username');
const password = formData.get('password');
const passwordCheck = password;
// const passwordCheck = formData.get('passwordCheck');
const email = formData.get('email');
console.log(username + " " + email + " " + password + " " + passwordCheck);
if (password !== passwordCheck) {
window.alert("两次输入的密码不一致,请核对后输入");
} else {
window.alert("注册信息如下:\n" + "用户名: " + username + "\n邮箱: " + email + "\n密码: " + password);
}
}
const loginButton = document.getElementById('loginButton');
const registerButton = document.getElementById('registerButton');
const loginForm = document.getElementById('loginForm');
const registerForm = document.getElementById('registerForm');
loginButton.addEventListener('click', () => {
loginButton.classList.add('active');
registerButton.classList.remove('active');
loginForm.style.display = 'block';
registerForm.style.display = 'none';
});
registerButton.addEventListener('click', () => {
registerButton.classList.add('active');
loginButton.classList.remove('active');
registerForm.style.display = 'block';
loginForm.style.display = 'none';
});
</script>
</body>
</html>