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