1 changed files with 278 additions and 234 deletions
@ -1,251 +1,295 @@ |
|||||
<template> |
<template> |
||||
<div class="login"> |
<div class="login"> |
||||
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form"> |
<el-form |
||||
<h3 class="title">针灸后台管理系统</h3> |
ref="loginForm" |
||||
<el-form-item prop="username"> |
:model="loginForm" |
||||
<el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号"> |
:rules="loginRules" |
||||
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" /> |
class="login-form" |
||||
</el-input> |
> |
||||
</el-form-item> |
<h3 class="title">针灸后台管理系统</h3> |
||||
<el-form-item prop="password"> |
<el-form-item prop="username"> |
||||
<el-input v-model="loginForm.password" type="password" auto-complete="off" placeholder="密码" |
<el-input |
||||
@keyup.enter.native="handleLogin"> |
v-model="loginForm.username" |
||||
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /> |
type="text" |
||||
</el-input> |
auto-complete="off" |
||||
</el-form-item> |
placeholder="账号" |
||||
<el-form-item prop="code" v-if="captchaEnabled"> |
> |
||||
<el-input v-model="loginForm.code" auto-complete="off" placeholder="验证码" style="width: 63%" |
<svg-icon |
||||
@keyup.enter.native="handleLogin"> |
slot="prefix" |
||||
<svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" /> |
icon-class="user" |
||||
</el-input> |
class="el-input__icon input-icon" |
||||
<div class="login-code"> |
/> |
||||
<img :src="codeUrl" @click="getCode" class="login-code-img" /> |
</el-input> |
||||
</div> |
</el-form-item> |
||||
</el-form-item> |
<el-form-item prop="password"> |
||||
<el-checkbox v-model="loginForm.rememberMe" style="margin: 0px 0px 25px 0px">记住密码</el-checkbox> |
<el-input |
||||
<el-form-item style="width: 100%"> |
v-model="loginForm.password" |
||||
<el-button :loading="loading" size="medium" type="primary" style="width: 100%" |
type="password" |
||||
@click.native.prevent="handleLogin"> |
auto-complete="off" |
||||
<span v-if="!loading">登 录</span> |
placeholder="密码" |
||||
<span v-else>登 录 中...</span> |
@keyup.enter.native="handleLogin" |
||||
</el-button> |
> |
||||
<div style="float: right" v-if="register"> |
<svg-icon |
||||
<router-link class="link-type" :to="'/register'">立即注册</router-link> |
slot="prefix" |
||||
</div> |
icon-class="password" |
||||
</el-form-item> |
class="el-input__icon input-icon" |
||||
</el-form> |
/> |
||||
<!-- 底部 --> |
</el-input> |
||||
<div class="el-login-footer"> |
</el-form-item> |
||||
<span>Copyright © 2018-2025 ruoyi.vip All Rights Reserved.</span> |
<el-form-item prop="code" v-if="captchaEnabled"> |
||||
</div> |
<el-input |
||||
</div> |
v-model="loginForm.code" |
||||
|
auto-complete="off" |
||||
|
placeholder="验证码" |
||||
|
style="width: 63%" |
||||
|
@keyup.enter.native="handleLogin" |
||||
|
> |
||||
|
<svg-icon |
||||
|
slot="prefix" |
||||
|
icon-class="validCode" |
||||
|
class="el-input__icon input-icon" |
||||
|
/> |
||||
|
</el-input> |
||||
|
<div class="login-code"> |
||||
|
<img :src="codeUrl" @click="getCode" class="login-code-img" /> |
||||
|
</div> |
||||
|
</el-form-item> |
||||
|
<el-checkbox |
||||
|
v-model="loginForm.rememberMe" |
||||
|
style="margin: 0px 0px 25px 0px" |
||||
|
>记住密码</el-checkbox |
||||
|
> |
||||
|
<el-form-item style="width: 100%"> |
||||
|
<el-button |
||||
|
:loading="loading" |
||||
|
size="medium" |
||||
|
type="primary" |
||||
|
style="width: 100%" |
||||
|
@click.native.prevent="handleLogin" |
||||
|
> |
||||
|
<span v-if="!loading">登 录</span> |
||||
|
<span v-else>登 录 中...</span> |
||||
|
</el-button> |
||||
|
<div style="float: right" v-if="register"> |
||||
|
<router-link class="link-type" :to="'/register'" |
||||
|
>立即注册</router-link |
||||
|
> |
||||
|
</div> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
<!-- 底部 --> |
||||
|
<div class="el-login-footer"> |
||||
|
<span>Copyright © 2018-2025 ruoyi.vip All Rights Reserved.</span> |
||||
|
</div> |
||||
|
</div> |
||||
</template> |
</template> |
||||
|
|
||||
<script> |
<script> |
||||
import { |
import { getCodeImg } from "@/api/login"; |
||||
getCodeImg |
import Cookies from "js-cookie"; |
||||
} from "@/api/login"; |
import { encrypt, decrypt } from "@/utils/jsencrypt"; |
||||
import Cookies from "js-cookie"; |
import { commonQueue } from "@/api/followupFile"; |
||||
import { |
export default { |
||||
encrypt, |
name: "Login", |
||||
decrypt |
data() { |
||||
} from "@/utils/jsencrypt"; |
return { |
||||
import { |
codeUrl: "", |
||||
commonQueue |
loginForm: { |
||||
} from "@/api/followupFile"; |
username: "", |
||||
export default { |
password: "", |
||||
name: "Login", |
rememberMe: false, |
||||
data() { |
code: "", |
||||
return { |
uuid: "", |
||||
codeUrl: "", |
}, |
||||
loginForm: { |
loginRules: { |
||||
username: "", |
username: [ |
||||
password: "", |
{ |
||||
rememberMe: false, |
required: true, |
||||
code: "", |
trigger: "blur", |
||||
uuid: "", |
message: "请输入您的账号", |
||||
}, |
}, |
||||
loginRules: { |
], |
||||
username: [{ |
password: [ |
||||
required: true, |
{ |
||||
trigger: "blur", |
required: true, |
||||
message: "请输入您的账号" |
trigger: "blur", |
||||
}, ], |
message: "请输入您的密码", |
||||
password: [{ |
}, |
||||
required: true, |
], |
||||
trigger: "blur", |
code: [ |
||||
message: "请输入您的密码" |
{ |
||||
}, ], |
required: true, |
||||
code: [{ |
trigger: "change", |
||||
required: true, |
message: "请输入验证码", |
||||
trigger: "change", |
}, |
||||
message: "请输入验证码" |
], |
||||
}], |
}, |
||||
}, |
loading: false, |
||||
loading: false, |
// 验证码开关 |
||||
// 验证码开关 |
captchaEnabled: true, |
||||
captchaEnabled: true, |
// 注册开关 |
||||
// 注册开关 |
register: false, |
||||
register: false, |
redirect: undefined, |
||||
redirect: undefined, |
}; |
||||
}; |
}, |
||||
}, |
watch: { |
||||
watch: { |
$route: { |
||||
$route: { |
handler: function (route) { |
||||
handler: function(route) { |
this.redirect = route.query && route.query.redirect; |
||||
this.redirect = route.query && route.query.redirect; |
}, |
||||
}, |
immediate: true, |
||||
immediate: true, |
}, |
||||
}, |
}, |
||||
}, |
created() { |
||||
created() { |
this.getCode(); |
||||
this.getCode(); |
this.getCookie(); |
||||
this.getCookie(); |
}, |
||||
}, |
methods: { |
||||
methods: { |
getCode() { |
||||
getCode() { |
getCodeImg().then((res) => { |
||||
getCodeImg().then((res) => { |
this.captchaEnabled = |
||||
this.captchaEnabled = |
res.captchaEnabled === undefined ? true : res.captchaEnabled; |
||||
res.captchaEnabled === undefined ? true : res.captchaEnabled; |
if (this.captchaEnabled) { |
||||
if (this.captchaEnabled) { |
this.codeUrl = "data:image/gif;base64," + res.img; |
||||
this.codeUrl = "data:image/gif;base64," + res.img; |
this.loginForm.uuid = res.uuid; |
||||
this.loginForm.uuid = res.uuid; |
} |
||||
} |
}); |
||||
}); |
}, |
||||
}, |
getCookie() { |
||||
getCookie() { |
const username = Cookies.get("username"); |
||||
const username = Cookies.get("username"); |
const password = Cookies.get("password"); |
||||
const password = Cookies.get("password"); |
const rememberMe = Cookies.get("rememberMe"); |
||||
const rememberMe = Cookies.get("rememberMe"); |
this.loginForm = { |
||||
this.loginForm = { |
username: username === undefined ? this.loginForm.username : username, |
||||
username: username === undefined ? this.loginForm.username : username, |
password: |
||||
password: password === undefined ? this.loginForm.password : decrypt(password), |
password === undefined ? this.loginForm.password : decrypt(password), |
||||
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe), |
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe), |
||||
}; |
}; |
||||
}, |
}, |
||||
handleLogin() { |
handleLogin() { |
||||
this.$refs.loginForm.validate((valid) => { |
this.$refs.loginForm.validate((valid) => { |
||||
if (valid) { |
if (valid) { |
||||
this.loading = true; |
this.loading = true; |
||||
if (this.loginForm.rememberMe) { |
if (this.loginForm.rememberMe) { |
||||
Cookies.set("username", this.loginForm.username, { |
Cookies.set("username", this.loginForm.username, { |
||||
expires: 30 |
expires: 30, |
||||
}); |
}); |
||||
Cookies.set("password", encrypt(this.loginForm.password), { |
Cookies.set("password", encrypt(this.loginForm.password), { |
||||
expires: 30, |
expires: 30, |
||||
}); |
}); |
||||
Cookies.set("rememberMe", this.loginForm.rememberMe, { |
Cookies.set("rememberMe", this.loginForm.rememberMe, { |
||||
expires: 30, |
expires: 30, |
||||
}); |
}); |
||||
} else { |
} else { |
||||
Cookies.remove("username"); |
Cookies.remove("username"); |
||||
Cookies.remove("password"); |
Cookies.remove("password"); |
||||
Cookies.remove("rememberMe"); |
Cookies.remove("rememberMe"); |
||||
} |
} |
||||
this.$store |
this.$store |
||||
.dispatch("Login", this.loginForm) |
.dispatch("Login", this.loginForm) |
||||
.then(() => { |
.then(() => { |
||||
|
this.$router |
||||
this.$router.push({ |
.push({ |
||||
path: this.redirect || "/" |
path: this.redirect || "/", |
||||
}).catch(() => {}); |
}) |
||||
this.getCommonQueue() |
.catch(() => {}); |
||||
}) |
this.getCommonQueue(); |
||||
.catch(() => { |
}) |
||||
this.loading = false; |
.catch(() => { |
||||
if (this.captchaEnabled) { |
this.loading = false; |
||||
this.getCode(); |
if (this.captchaEnabled) { |
||||
} |
this.getCode(); |
||||
}); |
} |
||||
} |
}); |
||||
}); |
} |
||||
}, |
}); |
||||
// 公共队列 |
}, |
||||
getCommonQueue() { |
// 公共队列 |
||||
commonQueue({ |
getCommonQueue() { |
||||
pageNum: -1, |
commonQueue({ |
||||
param: { |
pageNum: -1, |
||||
status: 1 |
param: { |
||||
}, |
status: 1, |
||||
}).then((res) => { |
}, |
||||
res.data.list.forEach(i=>{ |
}).then((res) => { |
||||
i.type = 1 |
res.data.list.forEach((i) => { |
||||
}) |
i.type = 1; |
||||
localStorage.setItem('commonQueue', JSON.stringify(res.data.list)) |
}); |
||||
}); |
localStorage.setItem("commonQueue", JSON.stringify(res.data.list)); |
||||
}, |
}); |
||||
}, |
}, |
||||
}; |
}, |
||||
|
}; |
||||
</script> |
</script> |
||||
|
|
||||
<style rel="stylesheet/scss" lang="scss"> |
<style rel="stylesheet/scss" lang="scss"> |
||||
.login { |
.login { |
||||
display: flex; |
display: flex; |
||||
justify-content: center; |
justify-content: center; |
||||
align-items: center; |
align-items: center; |
||||
height: 100%; |
height: 100%; |
||||
background-image: url("../assets/images/login-background.jpg"); |
background-image: url("../assets/images/login-background.jpg"); |
||||
background-size: cover; |
background-size: cover; |
||||
} |
} |
||||
|
|
||||
.title { |
.title { |
||||
margin: 0px auto 30px auto; |
margin: 0px auto 30px auto; |
||||
text-align: center; |
text-align: center; |
||||
color: #707070; |
color: #707070; |
||||
} |
} |
||||
|
|
||||
.login-form { |
.login-form { |
||||
border-radius: 6px; |
border-radius: 6px; |
||||
background: #ffffff; |
background: #ffffff; |
||||
width: 400px; |
width: 400px; |
||||
padding: 25px 25px 5px 25px; |
padding: 25px 25px 5px 25px; |
||||
|
|
||||
.el-input { |
.el-input { |
||||
height: 38px; |
height: 38px; |
||||
|
|
||||
input { |
input { |
||||
height: 38px; |
height: 38px; |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
.input-icon { |
.input-icon { |
||||
height: 39px; |
height: 39px; |
||||
width: 14px; |
width: 14px; |
||||
margin-left: 2px; |
margin-left: 2px; |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
.login-tip { |
.login-tip { |
||||
font-size: 13px; |
font-size: 13px; |
||||
text-align: center; |
text-align: center; |
||||
color: #bfbfbf; |
color: #bfbfbf; |
||||
} |
} |
||||
|
|
||||
.login-code { |
.login-code { |
||||
width: 33%; |
width: 33%; |
||||
height: 38px; |
height: 38px; |
||||
float: right; |
float: right; |
||||
|
|
||||
img { |
img { |
||||
cursor: pointer; |
cursor: pointer; |
||||
vertical-align: middle; |
vertical-align: middle; |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
.el-login-footer { |
.el-login-footer { |
||||
height: 40px; |
height: 40px; |
||||
line-height: 40px; |
line-height: 40px; |
||||
position: fixed; |
position: fixed; |
||||
bottom: 0; |
bottom: 0; |
||||
width: 100%; |
width: 100%; |
||||
text-align: center; |
text-align: center; |
||||
color: #fff; |
color: #fff; |
||||
font-family: Arial; |
font-family: Arial; |
||||
font-size: 12px; |
font-size: 12px; |
||||
letter-spacing: 1px; |
letter-spacing: 1px; |
||||
} |
} |
||||
|
|
||||
.login-code-img { |
.login-code-img { |
||||
height: 38px; |
height: 38px; |
||||
} |
} |
||||
</style> |
</style> |
||||
|
Loading…
Reference in new issue