From 55902aa8b6b3ab96b1d7e9cfb9a79d1448aa7c7d Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Mon, 27 Apr 2026 11:31:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=A0=81=E5=8A=9F=E8=83=BD=EF=BC=88=E6=9A=82=E6=97=B6=E9=9A=90?= =?UTF-8?q?=E8=97=8F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除验证码输入框和发送验证码按钮 - 移除验证码验证逻辑 - 保留手机号格式验证(11位中国手机号) - 保留手机号唯一性检查 - 注册字段:用户名、手机号(必填)、邮箱(可选)、密码 --- www/app.js | 95 ++------------------------------------------------ www/index.html | 6 ++-- 2 files changed, 5 insertions(+), 96 deletions(-) diff --git a/www/app.js b/www/app.js index 9606a3d..617ba04 100644 --- a/www/app.js +++ b/www/app.js @@ -1391,7 +1391,7 @@ function renderProfilePage() { @@ -1562,14 +1562,7 @@ function showRegisterPage() {
-
- - -
-
-
- - +
@@ -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(); diff --git a/www/index.html b/www/index.html index 084ef91..a4516b4 100644 --- a/www/index.html +++ b/www/index.html @@ -8,12 +8,12 @@ AI助手 - +
- - + + \ No newline at end of file