-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path许可-20311044.html
193 lines (174 loc) · 5.87 KB
/
许可-20311044.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>美团实践个人作业</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 100px;
padding: 20px;
background-color: #F5DEB3;
}
h1 {
color: #333;
}
.login-options {
margin-top: 20px;
}
.login-option {
display: inline-block;
margin-right: 20px;
font-size: 20px;
color: #333;
cursor: pointer;
border: 2px solid #E8AA56;
border-radius: 5px;
padding: 10px;
background-color: #E8AA56;
color: #FFFFFF;
}
.login-form {
margin-top: 50px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: inline-block;
width: 100px;
text-align: right;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="submit"] {
width: 200px;
padding: 5px;
font-size: 16px;
border: 2px solid #000000; /* 黑色 */
border-radius: 5px;
background-color: #FFFFFF; /* 白色 */
}
.form-group input[type="submit"] {
margin-top: 10px;
background-color: #000000; /* 黑色 */
color: #FFFFFF; /* 白色 */
cursor: pointer;
}
.popup {
display: none; /* 页面加载时隐藏弹窗 */
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #fff;
border: 2px solid #333;
padding: 20px;
z-index: 9999;
border-radius: 5px;
}
.popup-message {
margin-bottom: 10px;
color: green;
}
.popup-button {
padding: 5px 10px;
background-color: #333;
color: #fff;
border: none;
cursor: pointer;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>美团实践个人作业</h1>
<div class="login-options">
<div class="login-option" onclick="showLogin('account')">账号登录</div>
<div class="login-option" onclick="showLogin('phone')">手机登录</div>
</div>
<div class="login-form">
<form id="account-login" onsubmit="return checkAccountLogin()">
<div class="form-group">
<label>用户名:</label>
<input type="text" id="username">
</div>
<div class="form-group">
<label>密码:</label>
<input type="password" id="password">
</div>
<div class="form-group">
<input type="submit" value="登录">
</div>
</form>
<form id="phone-login" style="display:none;" onsubmit="return checkPhoneLogin()">
<div class="form-group">
<label>手机号:</label>
<input type="text" id="phone-number">
</div>
<div class="form-group">
<label>验证码:</label>
<input type="text" id="verification-code">
</div>
<div class="form-group">
<input type="submit" value="登录">
</div>
</form>
</div>
<div class="popup" id="success-popup">
<div class="popup-message">登录成功</div>
<button class="popup-button" onclick="hidePopup()">关闭</button>
</div>
<script>
// 预设的用户名和密码,手机号和验证码
var validUsername = "xuke";
var validPassword = "20311044";
var validPhoneNumber = "1234567890";
var validVerificationCode = "1234";
// 页面加载时直接显示账号登录的输入
document.getElementById("account-login").style.display = "block";
function showLogin(option) {
if (option === 'account') {
document.getElementById("account-login").style.display = "block";
document.getElementById("phone-login").style.display = "none";
} else if (option === 'phone') {
document.getElementById("account-login").style.display = "none";
document.getElementById("phone-login").style.display = "block";
}
}
function checkAccountLogin() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if (username === validUsername && password === validPassword) {
showPopup("success-popup");
return false;
} else {
alert("用户名或密码不正确");
return false;
}
}
function checkPhoneLogin() {
var phoneNumber = document.getElementById("phone-number").value;
var verificationCode = document.getElementById("verification-code").value;
if (phoneNumber === validPhoneNumber && verificationCode === validVerificationCode) {
showPopup("success-popup");
return false;
} else {
alert("手机号或验证码不正确");
return false;
}
}
function showPopup(popupId) {
var popup = document.getElementById(popupId);
popup.style.display = "block";
}
function hidePopup() {
var popups = document.getElementsByClassName("popup");
for (var i = 0; i < popups.length; i++) {
popups[i].style.display = "none";
}
}
</script>
</body>
</html>