From d153986f3d7d4bddc9a435d7f4324526c9dec84c Mon Sep 17 00:00:00 2001
From: hubian <908234780@qq.com>
Date: Mon, 27 Apr 2026 17:56:46 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E9=9A=90=E8=97=8F=E6=B3=A8=E5=86=8C?=
=?UTF-8?q?=E9=A1=B5=E9=9D=A2=E9=AA=8C=E8=AF=81=E7=A0=81=E5=8A=9F=E8=83=BD?=
=?UTF-8?q?=EF=BC=88=E6=9A=82=E6=97=B6=E8=B7=B3=E8=BF=87=E9=AA=8C=E8=AF=81?=
=?UTF-8?q?=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
www/app.js | 76 +++---------------------------------------------------
1 file changed, 3 insertions(+), 73 deletions(-)
diff --git a/www/app.js b/www/app.js
index f328b55..d304b99 100644
--- a/www/app.js
+++ b/www/app.js
@@ -2499,15 +2499,6 @@ function showRegisterPage() {
-
@@ -2552,12 +2543,6 @@ function showRegisterPage() {
});
}
- // 获取验证码按钮
- const getCodeBtn = document.getElementById('getCodeBtn');
- if (getCodeBtn) {
- getCodeBtn.addEventListener('click', handleGetCode);
- }
-
// 回车注册
document.getElementById('registerPasswordConfirm')?.addEventListener('keydown', (e) => {
if (e.key === 'Enter') handleRegister();
@@ -2570,50 +2555,6 @@ function showRegisterPage() {
e.target.value = e.target.value.replace(/\D/g, '');
});
}
-
- // 验证码输入限制(只允许数字)
- const codeInput = document.getElementById('registerCode');
- if (codeInput) {
- codeInput.addEventListener('input', (e) => {
- e.target.value = e.target.value.replace(/\D/g, '');
- });
- }
-}
-
-// 获取验证码(模拟)
-let verifyCode = '';
-let codeExpireTime = 0;
-
-function handleGetCode() {
- const phone = document.getElementById('registerPhone')?.value.trim();
-
- if (!validatePhone(phone)) {
- showToast('请先输入正确的手机号');
- return;
- }
-
- // 生成6位随机验证码
- verifyCode = Math.floor(100000 + Math.random() * 900000).toString();
- codeExpireTime = Date.now() + 5 * 60 * 1000; // 5分钟有效
-
- // 模拟发送(实际项目中应调用短信API)
- showToast(`验证码已发送: ${verifyCode}(演示)`);
-
- // 60秒倒计时
- const getCodeBtn = document.getElementById('getCodeBtn');
- if (getCodeBtn) {
- getCodeBtn.disabled = true;
- let countdown = 60;
- const timer = setInterval(() => {
- getCodeBtn.textContent = `${countdown}s`;
- countdown--;
- if (countdown <= 0) {
- clearInterval(timer);
- getCodeBtn.disabled = false;
- getCodeBtn.textContent = '获取验证码';
- }
- }, 1000);
- }
}
// 验证手机号格式
@@ -2634,7 +2575,6 @@ function handleRegister() {
const username = document.getElementById('registerUsername')?.value.trim();
const phone = document.getElementById('registerPhone')?.value.trim();
const email = document.getElementById('registerEmail')?.value.trim();
- const code = document.getElementById('registerCode')?.value.trim();
const password = document.getElementById('registerPassword')?.value;
const passwordConfirm = document.getElementById('registerPasswordConfirm')?.value;
@@ -2650,18 +2590,6 @@ function handleRegister() {
return;
}
- // 验证验证码
- if (!code || code.length !== 6) {
- showToast('请输入6位验证码');
- return;
- }
-
- // 检查验证码是否正确(模拟)
- if (code !== verifyCode || Date.now() > codeExpireTime) {
- showToast('验证码不正确或已过期');
- return;
- }
-
// 验证邮箱(可选)
if (email && !validateEmail(email)) {
showToast('请输入正确的邮箱格式');
@@ -2679,7 +2607,9 @@ function handleRegister() {
return;
}
- // 调用后台注册API
+ // 调用后台注册API(验证码暂时跳过,传随机值)
+ const code = Math.floor(100000 + Math.random() * 900000).toString();
+
fetch('/api/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },