diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
index c0d4981..d0f4336 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
@@ -48,6 +48,8 @@ public class SysLoginController
@PostMapping("/login")
public AjaxResult login(@RequestBody LoginBody loginBody)
{
+ System.out.println("==============="+loginBody.getUuid());
+
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
index fe16427..24d5a90 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
@@ -63,6 +63,7 @@ public class SysLoginService
*/
public String login(String username, String password, String code, String uuid)
{
+ System.out.println("======"+uuid);
// 验证码校验
validateCaptcha(username, code, uuid);
// 登录前置校验
diff --git a/vue2/vue/src/components/Login.vue b/vue2/vue/src/components/Login.vue
index d547dc8..68e9eb9 100644
--- a/vue2/vue/src/components/Login.vue
+++ b/vue2/vue/src/components/Login.vue
@@ -13,7 +13,7 @@
@@ -33,8 +33,9 @@ export default {
return {
username: '',
password: '',
- captcha: '', // 存储用户输入的验证码
- captchaUrl: '' // 验证码图片的 URL
+ code: '', // 存储用户输入的验证码
+ captchaUrl: '' ,// 验证码图片的 URL
+ uuid: ''
};
},
methods: {
@@ -45,6 +46,7 @@ export default {
if (data.code === 200) {
// 将 Base64 编码的图像转换为数据 URL
this.captchaUrl = `data:image/jpeg;base64,${data.img}`;
+ this.uuid = data.uuid; // 存储 uuid
} else {
console.error('获取验证码失败:', data.msg);
}
@@ -54,20 +56,35 @@ export default {
});
},
async login() {
- try {
- const response = await axios.post('http://localhost:8081/login', {
- username: this.username,
- password: this.password,
- captcha: this.captcha // 将验证码传递给后端
- });
- // 处理成功登录的逻辑,比如存储 token
- console.log('登录成功', response.data);
- } catch (error) {
- console.error('登录失败', error);
- // 登录失败时可以选择刷新验证码
- this.refreshCaptcha();
- }
- },
+ 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(); // 登录失败时刷新验证码
+ }
+ } catch (error) {
+ console.error('登录失败', error);
+ // 登录失败时可以选择刷新验证码
+ this.refreshCaptcha();
+ }
+ },
// 刷新验证码
refreshCaptcha() {
this.fetchCaptcha();