You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
317 lines
8.4 KiB
317 lines
8.4 KiB
<!-- |
|
* @author: fu_li_wei |
|
* @since: 2025-04-16 |
|
* login.vue |
|
--> |
|
<template> |
|
<div class="container" @keyup.enter="handleLogin"> |
|
<div class="loginBox"> |
|
<div class="loginDiv" :style="{ height: captchaEnabled ? '445px' : '370px'}"> |
|
<div class="loginname">积分管理系统</div> |
|
<el-input v-model="loginForm.username" class="username" type="text" placeholder="请输入用户名"> |
|
<template #prepend style="padding: 0;"> |
|
<i class="el-icon-user" style="color: #fff; font-size: 25px;"></i> |
|
</template> |
|
</el-input> |
|
<el-input show-password v-model="loginForm.password" id="psd" class="password" type="password" placeholder="请输入密码"> |
|
<template #prepend> |
|
<i class="el-icon-lock" style="color: #fff; font-size: 25px;"></i> |
|
</template> |
|
</el-input> |
|
<div v-if="captchaEnabled" class="code"> |
|
<el-input |
|
v-model="loginForm.code" |
|
auto-complete="off" |
|
placeholder="验证码" |
|
style="width: 63%; height: 50px; margin-right: 10px" |
|
@keyup.enter.native="handleLogin" |
|
> |
|
<svg-icon slot="prefix" icon-class="validCode" style="line-height: 40px" class="el-input__icon input-icon" /> |
|
</el-input> |
|
<div class="login-code"> |
|
<img :src="codeUrl" @click="getCode" class="login-code-img"/> |
|
</div> |
|
</div> |
|
|
|
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px; color: #fff;">记住密码</el-checkbox> |
|
|
|
<el-button :loading="loading" @click="handleLogin" class="login_btn" type="primary" round size="large">登 录</el-button> |
|
|
|
<div class="loginguang"></div> |
|
</div> |
|
</div> |
|
</div> |
|
</template> |
|
|
|
<script> |
|
import { getCodeImg } from "@/api/login"; |
|
import Cookies from "js-cookie"; |
|
import { encrypt, decrypt } from '@/utils/jsencrypt' |
|
|
|
export default { |
|
name: 'Login', |
|
components: {}, |
|
data() { |
|
return { |
|
loginForm: { |
|
username: "", |
|
password: "", |
|
rememberMe: false, |
|
code: "", |
|
uuid: "" |
|
}, |
|
loading: false, |
|
captchaEnabled: false, |
|
codeUrl: '', |
|
// 注册开关 |
|
register: false, |
|
redirect: undefined |
|
} |
|
}, |
|
watch: { |
|
$route: { |
|
handler: function(route) { |
|
this.redirect = route.query && route.query.redirect; |
|
}, |
|
immediate: true |
|
} |
|
}, |
|
created() { |
|
this.getCode(); |
|
this.getCookie(); |
|
/*if (process.env.NODE_ENV == 'development') { |
|
this.loginForm.username = 'admin' |
|
this.loginForm.password = 'admin123' |
|
this.handleLogin() |
|
}*/ |
|
}, |
|
methods: { |
|
getCode() { |
|
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; |
|
} |
|
}); |
|
}, |
|
getCookie() { |
|
const username = Cookies.get("username"); |
|
const password = Cookies.get("password"); |
|
|
|
const rememberMe = Cookies.get('rememberMe') |
|
if (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() { |
|
if (this.loginForm.username === '' || this.loginForm.password === '') { |
|
this.$message.warning('用户名和密码不能为空') |
|
return |
|
} |
|
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 }); |
|
} else { |
|
Cookies.remove("username"); |
|
Cookies.remove("password"); |
|
Cookies.remove('rememberMe'); |
|
} |
|
this.$store.dispatch("Login", this.loginForm).then(() => { |
|
const redirectPath = this.redirect && this.redirect.split('?')[0] |
|
const invalidRedirects = ['/index', '/404', '/login'] |
|
const targetPath = redirectPath && !invalidRedirects.includes(redirectPath) |
|
? this.redirect |
|
: '/hazard/ledger' |
|
this.$router.replace({ path: targetPath }).catch(() => {}) |
|
}).catch(() => { |
|
this.loading = false; |
|
if (this.captchaEnabled) { |
|
this.getCode(); |
|
} |
|
}); |
|
} |
|
} |
|
} |
|
</script> |
|
|
|
|
|
<style lang="scss" scoped> |
|
.container { |
|
width: 100%; |
|
height: 100%; |
|
min-height: 100vh; |
|
overflow: auto; |
|
background: #061354 url('../assets/images/loginbg.jpg') no-repeat center; |
|
background-size: cover; |
|
} |
|
|
|
.loginBox { |
|
background: url("../assets/images/loginbox.png") no-repeat center bottom; |
|
width: 100%; |
|
min-height: 100%; |
|
padding: 24px 16px; |
|
display: flex; |
|
align-items: center; |
|
justify-content: center; |
|
z-index: 1; |
|
background-size: cover; |
|
|
|
.loginDiv { |
|
width: 550px; |
|
max-width: 100%; |
|
flex: 0 0 auto; |
|
height: 370px; |
|
color: #fff; |
|
background: #07226f; |
|
position: relative; |
|
border-radius: 15px; |
|
background: |
|
radial-gradient(circle at 100% 100%, transparent 13px, #2dfdff 0) top left, |
|
radial-gradient(circle at 0% 100%, transparent 13px, #2dfdff 0) top right, |
|
radial-gradient(circle at 0% 0%, transparent 13px, #2dfdff 0) right bottom, |
|
radial-gradient(circle at 100% 0%, transparent 13px, #2dfdff 0) left bottom; |
|
background-size: 15px 15px; |
|
background-repeat: no-repeat; |
|
// background: |
|
// linear-gradient(to bottom, #33cdfa 0px, #33cdfa 2px, transparent 3px, transparent 100%) left top no-repeat, |
|
// linear-gradient(to right, #33cdfa 0px, #33cdfa 2px, transparent 3px, transparent 100%) left top no-repeat, |
|
// linear-gradient(to bottom, #33cdfa 0px, #33cdfa 2px, transparent 3px, transparent 100%) right top no-repeat, |
|
// linear-gradient(to left, #33cdfa 0px, #33cdfa 2px, transparent 3px, transparent 100%) right top no-repeat, |
|
// linear-gradient(to top, #33cdfa 0px, #33cdfa 2px, transparent 3px, transparent 100%) left bottom no-repeat, |
|
// linear-gradient(to right, #33cdfa 0px, #33cdfa 2px, transparent 3px, transparent 100%) left bottom no-repeat, |
|
// linear-gradient(to top, #33cdfa 0px, #33cdfa 2px, transparent 3px, transparent 100%) right bottom no-repeat, |
|
// linear-gradient(to left, #33cdfa 0px, #33cdfa 2px, transparent 3px, transparent 100%) right bottom no-repeat; |
|
// background-size: 1.5rem 1.5rem; |
|
background-color: #07226f; |
|
|
|
padding: 0 50px; |
|
|
|
.loginguang { |
|
content: ""; |
|
width: 100%; |
|
height: 100%; |
|
position: absolute; |
|
top: 0; |
|
left: 5%; |
|
background: url('../assets/images/loginguang.png') no-repeat; |
|
background-position: 100% -21px; |
|
z-index: -1; |
|
} |
|
|
|
.loginname { |
|
font-size: 36px; |
|
width: 100%; |
|
text-align: center; |
|
padding-top: 13px; |
|
|
|
background: linear-gradient(to bottom, #ddfbff, #2fa9ff); |
|
-webkit-background-clip: text; |
|
color: transparent; |
|
display: block; |
|
margin-bottom: 25px; |
|
} |
|
} |
|
|
|
.login_btn { |
|
width: 80%; |
|
font-size: 24px; |
|
margin: 0 auto; |
|
display: block; |
|
height: auto; |
|
} |
|
|
|
} |
|
|
|
.login-code-img { |
|
display: block; |
|
width: 100%; |
|
height: 50px; |
|
object-fit: fill; |
|
cursor: pointer; |
|
} |
|
.login-code { |
|
min-width: 0; |
|
flex: 1; |
|
} |
|
.code { |
|
display: flex; |
|
align-items: center; |
|
justify-content: space-between; |
|
margin-bottom: 20px; |
|
|
|
::v-deep .el-input__inner { |
|
height: 100%; |
|
} |
|
} |
|
::v-deep .el-input__prefix{ |
|
line-height: 50px; |
|
font-size: 25px; |
|
} |
|
|
|
::v-deep .el-input-group__prepend { |
|
border: none; |
|
padding: 0 13px; |
|
} |
|
|
|
::v-deep .el-input__inner { |
|
height: 100%; |
|
font-size: 18px; |
|
} |
|
|
|
::v-deep .username { |
|
margin-bottom: 30px; |
|
height: 50px; |
|
|
|
.el-input__inner{ |
|
height: 50px; |
|
} |
|
|
|
.el-input-group__prepend { |
|
background: #397cf6; |
|
} |
|
|
|
.el-input__inner{ |
|
height: 50px; |
|
} |
|
} |
|
|
|
::v-deep .password { |
|
margin-bottom: 30px; |
|
height: 50px; |
|
|
|
.el-input__inner{ |
|
height: 50px; |
|
} |
|
|
|
.el-input-group__prepend { |
|
background: #f09253; |
|
} |
|
} |
|
|
|
@media (max-width: 600px) { |
|
.loginBox { |
|
padding: 16px; |
|
|
|
.loginDiv { |
|
padding-right: 24px; |
|
padding-left: 24px; |
|
|
|
.loginname { |
|
margin-bottom: 20px; |
|
font-size: 28px; |
|
} |
|
} |
|
|
|
.login_btn { |
|
width: 100%; |
|
} |
|
} |
|
} |
|
</style>
|
|
|