fix: 移除验证码功能(暂时隐藏)
- 移除验证码输入框和发送验证码按钮 - 移除验证码验证逻辑 - 保留手机号格式验证(11位中国手机号) - 保留手机号唯一性检查 - 注册字段:用户名、手机号(必填)、邮箱(可选)、密码
This commit is contained in:
95
www/app.js
95
www/app.js
@@ -1391,7 +1391,7 @@ function renderProfilePage() {
|
||||
</div>
|
||||
|
||||
<div class="profile-footer">
|
||||
<p>AI助手 v3.4.0</p>
|
||||
<p>AI助手 v3.4.1</p>
|
||||
<p>基于智谱 GLM-4.5-Air</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1562,14 +1562,7 @@ function showRegisterPage() {
|
||||
</div>
|
||||
<div class="auth-input-group">
|
||||
<label>手机号 <span class="required">*</span></label>
|
||||
<div class="phone-input-wrapper">
|
||||
<input type="tel" id="registerPhone" placeholder="请输入手机号" maxlength="11" autocomplete="tel">
|
||||
<button class="send-code-btn" id="sendCodeBtn">获取验证码</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="auth-input-group">
|
||||
<label>验证码 <span class="required">*</span></label>
|
||||
<input type="text" id="registerCode" placeholder="请输入验证码" maxlength="6" autocomplete="one-time-code">
|
||||
<input type="tel" id="registerPhone" placeholder="请输入手机号" maxlength="11" autocomplete="tel">
|
||||
</div>
|
||||
<div class="auth-input-group">
|
||||
<label>邮箱 <span class="optional">(可选)</span></label>
|
||||
@@ -1615,12 +1608,6 @@ function showRegisterPage() {
|
||||
});
|
||||
}
|
||||
|
||||
// 发送验证码按钮
|
||||
const sendCodeBtn = document.getElementById('sendCodeBtn');
|
||||
if (sendCodeBtn) {
|
||||
sendCodeBtn.addEventListener('click', handleSendCode);
|
||||
}
|
||||
|
||||
// 回车注册
|
||||
document.getElementById('registerPasswordConfirm')?.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') handleRegister();
|
||||
@@ -1635,57 +1622,6 @@ function showRegisterPage() {
|
||||
}
|
||||
}
|
||||
|
||||
// 验证码状态
|
||||
let verifyCode = null;
|
||||
let verifyCodePhone = null;
|
||||
let verifyCodeExpire = null;
|
||||
|
||||
// 发送验证码(模拟)
|
||||
function handleSendCode() {
|
||||
const phoneInput = document.getElementById('registerPhone');
|
||||
const phone = phoneInput?.value.trim();
|
||||
const sendCodeBtn = document.getElementById('sendCodeBtn');
|
||||
|
||||
// 验证手机号格式
|
||||
if (!validatePhone(phone)) {
|
||||
showToast('请输入正确的手机号');
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查手机号是否已注册
|
||||
const users = JSON.parse(localStorage.getItem('registeredUsers') || '[]');
|
||||
if (users.find(u => u.phone === phone)) {
|
||||
showToast('该手机号已注册');
|
||||
return;
|
||||
}
|
||||
|
||||
// 生成6位验证码
|
||||
const code = Math.floor(100000 + Math.random() * 900000).toString();
|
||||
verifyCode = code;
|
||||
verifyCodePhone = phone;
|
||||
verifyCodeExpire = Date.now() + 5 * 60 * 1000; // 5分钟有效期
|
||||
|
||||
// 显示验证码(模拟,实际应发送短信)
|
||||
console.log('验证码:', code); // 调试用
|
||||
showToast(`验证码已发送:${code}`); // 实际项目中应隐藏
|
||||
|
||||
// 禁用按钮60秒
|
||||
if (sendCodeBtn) {
|
||||
sendCodeBtn.disabled = true;
|
||||
let countdown = 60;
|
||||
const timer = setInterval(() => {
|
||||
countdown--;
|
||||
if (countdown > 0) {
|
||||
sendCodeBtn.textContent = `${countdown}s`;
|
||||
} else {
|
||||
clearInterval(timer);
|
||||
sendCodeBtn.disabled = false;
|
||||
sendCodeBtn.textContent = '获取验证码';
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// 验证手机号格式
|
||||
function validatePhone(phone) {
|
||||
// 中国手机号:11位,以1开头
|
||||
@@ -1703,7 +1639,6 @@ function validateEmail(email) {
|
||||
function handleRegister() {
|
||||
const username = document.getElementById('registerUsername')?.value.trim();
|
||||
const phone = document.getElementById('registerPhone')?.value.trim();
|
||||
const code = document.getElementById('registerCode')?.value.trim();
|
||||
const email = document.getElementById('registerEmail')?.value.trim();
|
||||
const password = document.getElementById('registerPassword')?.value;
|
||||
const passwordConfirm = document.getElementById('registerPasswordConfirm')?.value;
|
||||
@@ -1720,27 +1655,6 @@ function handleRegister() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证验证码
|
||||
if (!code) {
|
||||
showToast('请输入验证码');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!verifyCode || verifyCodePhone !== phone) {
|
||||
showToast('请先获取验证码');
|
||||
return;
|
||||
}
|
||||
|
||||
if (code !== verifyCode) {
|
||||
showToast('验证码错误');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Date.now() > verifyCodeExpire) {
|
||||
showToast('验证码已过期,请重新获取');
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证邮箱(可选)
|
||||
if (!validateEmail(email)) {
|
||||
showToast('请输入正确的邮箱格式');
|
||||
@@ -1783,11 +1697,6 @@ function handleRegister() {
|
||||
users.push(newUser);
|
||||
localStorage.setItem('registeredUsers', JSON.stringify(users));
|
||||
|
||||
// 清除验证码
|
||||
verifyCode = null;
|
||||
verifyCodePhone = null;
|
||||
verifyCodeExpire = null;
|
||||
|
||||
// 自动登录
|
||||
currentUser = { username: newUser.username, phone: newUser.phone, registeredAt: newUser.registeredAt };
|
||||
saveCurrentUser();
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Expires" content="0">
|
||||
<title>AI助手</title>
|
||||
<link rel="stylesheet" href="style.css?v=3.4.0">
|
||||
<link rel="stylesheet" href="style.css?v=3.4.1">
|
||||
<link rel="manifest" href="manifest.json">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="marked.min.js?v=3.4.0"></script>
|
||||
<script src="app.js?v=3.4.0"></script>
|
||||
<script src="marked.min.js?v=3.4.1"></script>
|
||||
<script src="app.js?v=3.4.1"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user