注册修复

This commit is contained in:
qing committed 2026-07-21 22:08:56 +08:00
1 parent 1d57502fa2
commit 8364607d7b
2 files changed
+19 -21

No files matched your search

+3 -5
View File
@@ -183,11 +183,8 @@ form.addEventListener('submit', async function (e) {
throw new Error(result.message || `注册失败(HTTP ${res.status})`); throw new Error(result.message || `注册失败(HTTP ${res.status})`);
} }
if (result.code === 0) { if (result.success) {
if (!result.data || !result.data.username) { alert('注册成功');
throw new Error('注册成功,但服务器返回的数据不完整');
}
alert(`${result.message},账号:${result.data.username}`);
form.reset(); form.reset();
sendCode = ''; sendCode = '';
codeTarget = ''; codeTarget = '';
@@ -196,6 +193,7 @@ form.addEventListener('submit', async function (e) {
} }
alert(result.message || '注册失败'); alert(result.message || '注册失败');
} catch (err) { } catch (err) {
console.error('注册请求异常:', err); console.error('注册请求异常:', err);
alert(err.message || '接口请求失败,请检查后端服务是否启动'); alert(err.message || '接口请求失败,请检查后端服务是否启动');
+16 -16
View File
@@ -1,32 +1,32 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"> <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<title>注册页面</title> <title>注册页面</title>
<style> <style>
.tip-red {color:red;} .tip-red {color:red;}
.tip-yellow {color: orange;} .tip-yellow {color: orange;}
.tip-green {color: greenyellow;} .tip-green {color: greenyellow;}
</style> </style>
</head> </head>
<body> <body>
<h2>注册页面</h2> <h2>注册页面</h2>
<form id="form"> <form id="form">
<div> <div>
<label>用户名/推荐邮箱:</label> <label>用户名/推荐邮箱:</label>
<input type="text" id="regusername" placeholder="请输入用户名"> <input type="text" id="regusername" placeholder="请输入用户名">
<span id="msgTip" ></span> <span id="msgTip" ></span>
<br> <br>
<label>邮箱号:</label> <label>邮箱号:</label>
<input type="email" id="regemail" placeholder="请输入邮箱号"> <input type="email" id="regemail" placeholder="请输入邮箱号">
<div class="code-box">验证码: <div class="code-box">验证码:
<input type="text" id="code" placeholder="请输入6位验证码" inputmode="numeric" maxlength="6"> <input type="text" id="code" placeholder="请输入6位验证码" inputmode="numeric" maxlength="6">
<input type="button" id="getCode" value="获取验证码"> <input type="button" id="getCode" value="获取验证码">
<span id="codeTip"></span> <span id="codeTip"></span>
</div> </div>
<span id="emlTip"></span> <span id="emlTip"></span>
<br> <br>
<label>密码:</label> <label>密码:</label>
<input type="password" id="regpsw" placeholder="密码至少6位"> <input type="password" id="regpsw" placeholder="密码至少6位">
<label>验证密码:</label> <label>验证密码:</label>