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