|
|
|
@ -3,17 +3,17 @@
|
|
|
|
|
<h2>登录</h2>
|
|
|
|
|
<form @submit.prevent="handleLogin">
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label for="username">用户名</label>
|
|
|
|
|
<label for="username">username</label>
|
|
|
|
|
<input type="text" id="username" v-model="username" required />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label for="password">密码</label>
|
|
|
|
|
<label for="password">secret code</label>
|
|
|
|
|
<input type="password" id="password" v-model="password" required />
|
|
|
|
|
</div>
|
|
|
|
|
<button type="submit">登录</button>
|
|
|
|
|
<button type="submit">login</button>
|
|
|
|
|
<div class="action-buttons">
|
|
|
|
|
<button type="button" @click="handleForgotPassword">找回密码</button>
|
|
|
|
|
<button type="button" @click="handleRegister">注册</button>
|
|
|
|
|
<button type="button" @click="handleForgotPassword">get the code back</button>
|
|
|
|
|
<button type="button" @click="handleRegister">register</button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
@ -31,8 +31,8 @@ const password = ref('');
|
|
|
|
|
const store = useLoginStore();
|
|
|
|
|
const handleLogin = async () => {
|
|
|
|
|
// 这里可以添加登录逻辑,例如调用 API 进行验证
|
|
|
|
|
console.log('用户名:', username.value);
|
|
|
|
|
console.log('密码:', password.value);
|
|
|
|
|
console.log('username:', username.value);
|
|
|
|
|
console.log('secret passward:', password.value);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 后端检查账号密码是否正确
|
|
|
|
@ -49,7 +49,7 @@ const handleLogin = async () => {
|
|
|
|
|
console.log(response.data.code);
|
|
|
|
|
if (response.data.code === 1) {
|
|
|
|
|
// 登录成功
|
|
|
|
|
console.log('登录成功');
|
|
|
|
|
console.log('Success');
|
|
|
|
|
store.userInfo.token = response.data.data;
|
|
|
|
|
store.userInfo.username = username.value;
|
|
|
|
|
router.push('/home');
|
|
|
|
@ -57,10 +57,10 @@ const handleLogin = async () => {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
// 登录失败
|
|
|
|
|
alert('用户名或密码错误');
|
|
|
|
|
alert('error');
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('登录请求失败:', error);
|
|
|
|
|
console.error('defected:', error);
|
|
|
|
|
// 处理登录失败的逻辑
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -71,7 +71,7 @@ const handleLogin = async () => {
|
|
|
|
|
|
|
|
|
|
const handleForgotPassword = () => {
|
|
|
|
|
// 处理找回密码逻辑
|
|
|
|
|
console.log('找回密码');
|
|
|
|
|
console.log('get the code back');
|
|
|
|
|
// 例如重定向到找回密码页面
|
|
|
|
|
router.push('/retrievePassword');
|
|
|
|
|
};
|
|
|
|
|