|
|
|
@ -40,7 +40,7 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
fetchCaptcha() {
|
|
|
|
|
fetch('http://localhost:8081/captchaImage')
|
|
|
|
|
fetch('http://localhost:8080/captchaImage')
|
|
|
|
|
.then(response => response.json()) // 将响应解析为 JSON
|
|
|
|
|
.then(data => {
|
|
|
|
|
if (data.code === 200) {
|
|
|
|
@ -56,35 +56,35 @@ export default {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
async login() {
|
|
|
|
|
try {
|
|
|
|
|
const response = await axios.post('http://localhost:8081/login', {
|
|
|
|
|
username: this.username,
|
|
|
|
|
password: this.password,
|
|
|
|
|
code: this.code,// 将验证码传递给后端
|
|
|
|
|
uuid: this.uuid
|
|
|
|
|
}, {
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json' // 指定内容类型为 JSON
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
console.log('用户名',this.username);
|
|
|
|
|
console.log('密码',this.password);
|
|
|
|
|
console.log('验证码',this.code);
|
|
|
|
|
console.log('uuid',this.uuid);
|
|
|
|
|
|
|
|
|
|
if (response.data.code === 200) {
|
|
|
|
|
console.log('登录成功', response.data);
|
|
|
|
|
window.location.href = 'http://localhost:8080'; // 登录成功后跳转
|
|
|
|
|
} else {
|
|
|
|
|
console.error('登录失败', response.data.msg);
|
|
|
|
|
this.refreshCaptcha(); // 登录失败时刷新验证码
|
|
|
|
|
try {
|
|
|
|
|
const response = await axios.post('http://localhost:8080/login', {
|
|
|
|
|
username: this.username,
|
|
|
|
|
password: this.password,
|
|
|
|
|
code: this.code,// 将验证码传递给后端
|
|
|
|
|
uuid: this.uuid
|
|
|
|
|
}, {
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json' // 指定内容类型为 JSON
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('登录失败', error);
|
|
|
|
|
// 登录失败时可以选择刷新验证码
|
|
|
|
|
this.refreshCaptcha();
|
|
|
|
|
});
|
|
|
|
|
console.log('用户名',this.username);
|
|
|
|
|
console.log('密码',this.password);
|
|
|
|
|
console.log('验证码',this.code);
|
|
|
|
|
console.log('uuid',this.uuid);
|
|
|
|
|
|
|
|
|
|
if (response.data.code === 200) {
|
|
|
|
|
console.log('登录成功', response.data);
|
|
|
|
|
window.location.href = 'http://localhost:8081'; // 登录成功后跳转
|
|
|
|
|
} else {
|
|
|
|
|
console.error('登录失败', response.data.msg);
|
|
|
|
|
this.refreshCaptcha(); // 登录失败时刷新验证码
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('登录失败', error);
|
|
|
|
|
// 登录失败时可以选择刷新验证码
|
|
|
|
|
this.refreshCaptcha();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 刷新验证码
|
|
|
|
|
refreshCaptcha() {
|
|
|
|
|
this.fetchCaptcha();
|
|
|
|
|