帮我生成一个html页面,页面元素有两个输入框,一个显示输入接收验证码的邮箱账号,一个显示输入验证码,两个按钮,一个获取验证码,一个登录,然后就是使用ajax向后端发送数据要求发送方式都是post,点击获取验证码后按钮变为不可使用并显示在60秒后重试,整个页面参考qq邮箱登录界面,然后就是整个元素采用左右布局,上面的元素需要显示在屏幕右边,字体是楷体,然后能自动适应手机等页面
时间: 2023-09-24 13:02:23 浏览: 46
好的,以下是一个基本的HTML页面代码:
```
<!DOCTYPE html>
<html>
<head>
<title>登录页面</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: "楷体";
}
.container {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.form {
display: flex;
flex-direction: column;
align-items: center;
margin-right: 50px;
}
.form label {
margin-bottom: 10px;
}
input[type="text"],
input[type="password"] {
padding: 5px;
border-radius: 5px;
border: 1px solid #ccc;
margin-bottom: 10px;
width: 250px;
}
button {
padding: 10px;
border-radius: 5px;
border: none;
background-color: #4285F4;
color: #fff;
cursor: pointer;
margin-bottom: 10px;
width: 250px;
}
button:disabled {
background-color: #ccc;
cursor: not-allowed;
}
.message {
display: flex;
flex-direction: column;
align-items: center;
margin-left: 50px;
}
.message p {
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<div class="form">
<label for="email">邮箱账号:</label>
<input type="text" id="email" name="email">
<label for="code">验证码:</label>
<input type="text" id="code" name="code">
<button id="getCode">获取验证码</button>
<button id="login">登录</button>
</div>
<div class="message">
<p>验证码已发送至邮箱:</p>
<p id="emailAddress"></p>
<p>请在下方输入验证码:</p>
<p id="timeLeft"></p>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
var secondsLeft = 60;
$("#getCode").on("click", function() {
var email = $("#email").val();
$.ajax({
url: "backend.php",
type: "POST",
data: {action: "sendCode", email: email},
success: function(response) {
console.log(response);
$("#emailAddress").html(email);
$("#code").focus();
$("#getCode").prop("disabled", true);
var intervalId = setInterval(function() {
secondsLeft--;
$("#timeLeft").html("重新发送:" + secondsLeft + "秒");
if (secondsLeft === 0) {
clearInterval(intervalId);
$("#getCode").prop("disabled", false);
$("#timeLeft").html("");
secondsLeft = 60;
}
}, 1000);
},
error: function(xhr, status, error) {
console.log(xhr);
console.log(status);
console.log(error);
}
});
});
$("#login").on("click", function() {
var email = $("#email").val();
var code = $("#code").val();
$.ajax({
url: "backend.php",
type: "POST",
data: {action: "login", email: email, code: code},
success: function(response) {
console.log(response);
// Redirect to home page or show success message
},
error: function(xhr, status, error) {
console.log(xhr);
console.log(status);
console.log(error);
// Show error message
}
});
});
});
</script>
</body>
</html>
```
请注意,在上面的代码中,我使用了jQuery库来处理AJAX请求,所以需要在页面中添加jQuery的引用。此外,上述代码只是一个基本示例,需要在后端编写逻辑来处理发送验证码和登录的功能。在这里,我把后端处理程序的文件名定义为“backend.php”,因此AJAX请求的URL为“backend.php”。