|
|
|
@ -1,7 +1,10 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="login">
|
|
|
|
|
<div class="loginleft">
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
|
|
|
|
|
<h3 class="title">若依后台管理系统</h3>
|
|
|
|
|
<h3 class="title">工业园区工业上楼项目</h3>
|
|
|
|
|
<el-form-item prop="username">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="loginForm.username"
|
|
|
|
@ -54,7 +57,7 @@
|
|
|
|
|
</div>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<!-- 底部 -->
|
|
|
|
|
<!-- 底部 -->
|
|
|
|
|
<div class="el-login-footer">
|
|
|
|
|
<span>Copyright © 2018-2025 ruoyi.vip All Rights Reserved.</span>
|
|
|
|
|
</div>
|
|
|
|
@ -62,30 +65,29 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { getCodeImg } from "@/api/login";
|
|
|
|
|
import Cookies from "js-cookie";
|
|
|
|
|
import { getCodeImg } from '@/api/login'
|
|
|
|
|
import Cookies from 'js-cookie'
|
|
|
|
|
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "Login",
|
|
|
|
|
name: 'Login',
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
codeUrl: "",
|
|
|
|
|
codeUrl: '',
|
|
|
|
|
loginForm: {
|
|
|
|
|
username: "admin",
|
|
|
|
|
password: "admin123",
|
|
|
|
|
username: 'admin',
|
|
|
|
|
password: 'admin123',
|
|
|
|
|
rememberMe: false,
|
|
|
|
|
code: "",
|
|
|
|
|
uuid: ""
|
|
|
|
|
code: '',
|
|
|
|
|
uuid: ''
|
|
|
|
|
},
|
|
|
|
|
loginRules: {
|
|
|
|
|
username: [
|
|
|
|
|
{ required: true, trigger: "blur", message: "请输入您的账号" }
|
|
|
|
|
{ required: true, trigger: 'blur', message: '请输入您的账号' }
|
|
|
|
|
],
|
|
|
|
|
password: [
|
|
|
|
|
{ required: true, trigger: "blur", message: "请输入您的密码" }
|
|
|
|
|
{ required: true, trigger: 'blur', message: '请输入您的密码' }
|
|
|
|
|
],
|
|
|
|
|
code: [{ required: true, trigger: "change", message: "请输入验证码" }]
|
|
|
|
|
code: [{ required: true, trigger: 'change', message: '请输入验证码' }]
|
|
|
|
|
},
|
|
|
|
|
loading: false,
|
|
|
|
|
// 验证码开关
|
|
|
|
@ -93,66 +95,66 @@ export default {
|
|
|
|
|
// 注册开关
|
|
|
|
|
register: false,
|
|
|
|
|
redirect: undefined
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
$route: {
|
|
|
|
|
handler: function(route) {
|
|
|
|
|
this.redirect = route.query && route.query.redirect;
|
|
|
|
|
},
|
|
|
|
|
immediate: true
|
|
|
|
|
$route(route) {
|
|
|
|
|
this.redirect = route.query && route.query.redirect
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.getCode();
|
|
|
|
|
this.getCookie();
|
|
|
|
|
this.getCode()
|
|
|
|
|
this.getCookie()
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
getCode() {
|
|
|
|
|
getCodeImg().then(res => {
|
|
|
|
|
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled;
|
|
|
|
|
getCodeImg().then((res) => {
|
|
|
|
|
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
|
|
|
|
|
if (this.captchaEnabled) {
|
|
|
|
|
this.codeUrl = "data:image/gif;base64," + res.img;
|
|
|
|
|
this.loginForm.uuid = res.uuid;
|
|
|
|
|
this.codeUrl = `data:image/gif;base64,${res.img}`
|
|
|
|
|
this.loginForm.uuid = res.uuid
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.error('获取验证码失败:', error)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getCookie() {
|
|
|
|
|
const username = Cookies.get("username");
|
|
|
|
|
const password = Cookies.get("password");
|
|
|
|
|
const username = Cookies.get('username')
|
|
|
|
|
const password = Cookies.get('password')
|
|
|
|
|
const rememberMe = Cookies.get('rememberMe')
|
|
|
|
|
this.loginForm = {
|
|
|
|
|
username: username === undefined ? this.loginForm.username : username,
|
|
|
|
|
password: password === undefined ? this.loginForm.password : decrypt(password),
|
|
|
|
|
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleLogin() {
|
|
|
|
|
this.$refs.loginForm.validate(valid => {
|
|
|
|
|
this.$refs.loginForm.validate((valid) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
this.loading = true;
|
|
|
|
|
this.loading = true
|
|
|
|
|
if (this.loginForm.rememberMe) {
|
|
|
|
|
Cookies.set("username", this.loginForm.username, { expires: 30 });
|
|
|
|
|
Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 });
|
|
|
|
|
Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 });
|
|
|
|
|
Cookies.set('username', this.loginForm.username, { expires: 30 })
|
|
|
|
|
Cookies.set('password', encrypt(this.loginForm.password), { expires: 30 })
|
|
|
|
|
Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 })
|
|
|
|
|
} else {
|
|
|
|
|
Cookies.remove("username");
|
|
|
|
|
Cookies.remove("password");
|
|
|
|
|
Cookies.remove('rememberMe');
|
|
|
|
|
Cookies.remove('username')
|
|
|
|
|
Cookies.remove('password')
|
|
|
|
|
Cookies.remove('rememberMe')
|
|
|
|
|
}
|
|
|
|
|
this.$store.dispatch("Login", this.loginForm).then(() => {
|
|
|
|
|
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
this.loading = false;
|
|
|
|
|
this.$store.dispatch('Login', this.loginForm).then(() => {
|
|
|
|
|
this.$router.push({ path: this.redirect || '/' }).catch(() => {})
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
this.loading = false
|
|
|
|
|
if (this.captchaEnabled) {
|
|
|
|
|
this.getCode();
|
|
|
|
|
this.getCode()
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
console.error('登录失败:', error)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style rel="stylesheet/scss" lang="scss">
|
|
|
|
@ -161,11 +163,18 @@ export default {
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
height: 100%;
|
|
|
|
|
background-image: url("../assets/images/login-background.jpg");
|
|
|
|
|
background-image: url('../assets/images/loginbackground.png');
|
|
|
|
|
background-size: cover;
|
|
|
|
|
}
|
|
|
|
|
.loginleft{
|
|
|
|
|
width: 35rem ;
|
|
|
|
|
height: 23rem;
|
|
|
|
|
background-image: url('../assets/images/loginleft.jpg');
|
|
|
|
|
background-size: 100% 100%;
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
}
|
|
|
|
|
.title {
|
|
|
|
|
margin: 0px auto 30px auto;
|
|
|
|
|
margin: 0 auto 30px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
color: #707070;
|
|
|
|
|
}
|
|
|
|
@ -174,7 +183,7 @@ export default {
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
width: 400px;
|
|
|
|
|
padding: 25px 25px 5px 25px;
|
|
|
|
|
padding: 25px;
|
|
|
|
|
.el-input {
|
|
|
|
|
height: 38px;
|
|
|
|
|
input {
|
|
|
|
|