<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>找回密码 - QSZ</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<style>
:root {
--primary-color: #4f46e5;
--secondary-color: #818cf8;
--success-color: #10b981;
--error-color: #ef4444;
--text-color: #1f2937;
--bg-color: #f3f4f6;
--white: #ffffff;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
}
.container {
background: var(--white);
border-radius: 1rem;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 450px;
position: relative;
overflow: hidden;
}
.steps {
display: flex;
justify-content: center;
margin: 2rem 0;
padding: 0 2rem;
}
.step {
display: flex;
align-items: center;
flex: 1;
position: relative;
}
.step:not(:last-child)::after {
content: '';
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
width: 100%;
height: 2px;
background: #e5e7eb;
z-index: 1;
}
.step-circle {
width: 2rem;
height: 2rem;
background: var(--white);
border: 2px solid #e5e7eb;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.875rem;
color: #6b7280;
position: relative;
z-index: 2;
}
.step.active .step-circle {
background: var(--primary-color);
border-color: var(--primary-color);
color: var(--white);
}
.step.completed .step-circle {
background: var(--success-color);
border-color: var(--success-color);
color: var(--white);
}
.form-section {
padding: 2rem;
}
.form-header {
text-align: center;
margin-bottom: 2rem;
}
.form-title {
font-size: 1.5rem;
color: var(--text-color);
margin-bottom: 0.5rem;
}
.form-subtitle {
color: #6b7280;
font-size: 0.875rem;
}
.form-group {
margin-bottom: 1.5rem;
position: relative;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
color: var(--text-color);
font-size: 0.875rem;
font-weight: 500;
}
.form-group input {
width: 100%;
padding: 0.75rem 1rem;
padding-left: 2.5rem;
border: 1px solid #e5e7eb;
border-radius: 0.5rem;
font-size: 1rem;
transition: all 0.3s ease;
}
.form-group input:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.form-group .icon {
position: absolute;
left: 1rem;
top: 2.3rem;
color: #9ca3af;
}
.verification-code {
display: flex;
gap: 0.5rem;
}
.verification-code input {
width: 3rem;
height: 3rem;
text-align: center;
font-size: 1.25rem;
border: 1px solid #e5e7eb;
border-radius: 0.5rem;
}
.btn {
width: 100%;
padding: 0.75rem 1.5rem;
background: var(--primary-color);
color: var(--white);
border: none;
border-radius: 0.5rem;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
transition: background-color 0.3s ease;
}
.btn:hover {
background: var(--secondary-color);
}
.btn-outline {
background: transparent;
border: 1px solid var(--primary-color);
color: var(--primary-color);
}
.btn-outline:hover {
background: var(--bg-color);
}
.form-footer {
text-align: center;
margin-top: 1.5rem;
}
.form-footer a {
color: var(--primary-color);
text-decoration: none;
font-size: 0.875rem;
}
.form-footer a:hover {
text-decoration: underline;
}
.hidden {
display: none;
}
@media (max-width: 640px) {
.container {
margin: 1rem;
}
}
</style>
</head>
<body>
<div class="container">
<div class="steps">
<div class="step active" id="step1">
<div class="step-circle">1</div>
</div>
<div class="step" id="step2">
<div class="step-circle">2</div>
</div>
<div class="step" id="step3">
<div class="step-circle">3</div>
</div>
</div>
<!-- 步骤1:输入邮箱 -->
<div class="form-section" id="email-section">
<div class="form-header">
<h2 class="form-title">找回密码</h2>
<p class="form-subtitle">请输入您的注册邮箱,我们将向您发送验证码</p>
</div>
<form onsubmit="return sendVerificationCode(event)">
<div class="form-group">
<label for="email">邮箱地址</label>
<i class="fas fa-envelope icon"></i>
<input type="email" id="email" required placeholder="请输入邮箱">
</div>
<button type="submit" class="btn">发送验证码</button>
<div class="form-footer">
<a href="login.html">返回登录</a>
</div>
</form>
</div>
<!-- 步骤2:输入验证码 -->
<div class="form-section hidden" id="verification-section">
<div class="form-header">
<h2 class="form-title">输入验证码</h2>
<p class="form-subtitle">请输入发送到您邮箱的6位验证码</p>
</div>
<form onsubmit="return verifyCode(event)">
<div class="form-group">
<div class="verification-code">
<input type="text" maxlength="1" pattern="[0-9]" required>
<input type="text" maxlength="1" pattern="[0-9]" required>
<input type="text" maxlength="1" pattern="[0-9]" required>
<input type="text" maxlength="1" pattern="[0-9]" required>
<input type="text" maxlength="1" pattern="[0-9]" required>
<input type="text" maxlength="1" pattern="[0-9]" required>
</div>
</div>
<button type="submit" class="btn">验证</button>
<div class="form-footer">
<a href="#" id="resend-code">重新发送验证码</a>
</div>
</form>
</div>
<!-- 步骤3:重置密码 -->
<div class="form-section hidden" id="reset-section">
<div class="form-header">
<h2 class="form-title">重置密码</h2>
<p class="form-subtitle">请设置您的新密码</p>
</div>
<form onsubmit="return resetPassword(event)">
<div class="form-group">
<label for="new-password">新密码</label>
<i class="fas fa-lock icon"></i>
<input type="password" id="new-password" required placeholder="请输入新密码">
</div>
<div class="form-group">
<label for="confirm-password">确认密码</label>
<i class="fas fa-lock icon"></i>
<input type="password" id="confirm-password" required placeholder="请再次输入密码">
</div>
<button type="submit" class="btn">重置密码</button>
</form>
</div>
</div>
<script>
// 验证码输入框自动跳转
const verificationInputs = document.querySelectorAll('.verification-code input');
verificationInputs.forEach((input, index) => {
input.addEventListener('input', function() {
if (this.value.length === 1) {
if (index < verificationInputs.length - 1) {
verificationInputs[index + 1].focus();
}
}
});
input.addEventListener('keydown', function(e) {
if (e.key === 'Backspace' && !this.value) {
if (index > 0) {
verificationInputs[index - 1].focus();
}
}
});
});
// 显示指定步骤
function showStep(stepNumber) {
document.querySelectorAll('.form-section').forEach(section => {
section.classList.add('hidden');
});
document.querySelectorAll('.step').forEach((step, index) => {
if (index + 1 < stepNumber) {
step.classList.add('completed');
step.classList.remove('active');
} else if (index + 1 === stepNumber) {
step.classList.add('active');
step.classList.remove('completed');
} else {
step.classList.remove('active', 'completed');
}
});
switch(stepNumber) {
case 1:
document.getElementById('email-section').classList.remove('hidden');
break;
case 2:
document.getElementById('verification-section').classList.remove('hidden');
break;
case 3:
document.getElementById('reset-section').classList.remove('hidden');
break;
}
}
// 发送验证码
function sendVerificationCode(event) {
event.preventDefault();
// 这里添加发送验证码的逻辑
showStep(2);
return false;
}
// 验证验证码
function verifyCode(event) {
event.preventDefault();
// 这里添加验证码验证逻辑
showStep(3);
return false;
}
// 重置密码
function resetPassword(event) {
event.preventDefault();
const password = document.getElementById('new-password').value;
const confirmPassword = document.getElementById('confirm-password').value;
if (password !== confirmPassword) {
alert('两次输入的密码不一致!');
return false;
}
// 这里添加重置密码的逻辑
alert('密码重置成功!');
window.location.href = 'login.html';
return false;
}
</script>
</body>
</html>
本文来自QSZ学习网站,作者:北边村的富少,转载请注明原文链接:https://www.cnblogs.com/qsz666/p/18552524