<template>
<div class="login-container">
<div class="title-logo">
<img src="@/assets/img/comlogo.png" class="image" />
</div>
<div class="login-form">
<el-form
ref="loginForm"
:model="loginForm"
:rules="loginRules"
auto-complete="on"
label-position="left"
class="form"
>
<div class="milky">
<div style="text-align:center">VTE防治管理系统</div>
</div>
<el-form-item prop="username">
<span class="svg-container">
<svg-icon icon-class="user" />
</span>
<el-input
ref="username"
v-model="loginForm.username"
placeholder="用户名"
name="username"
type="text"
tabindex="1"
auto-complete="on"
/>
</el-form-item>
<el-form-item prop="password">
<span class="svg-container">
<svg-icon icon-class="password" />
</span>
<el-input
:key="passwordType"
ref="password"
v-model="loginForm.password"
:type="passwordType"
placeholder="密码"
name="password"
tabindex="2"
auto-complete="on"
@keyup.enter.native="handleLogin"
/>
<span class="show-pwd" @click="showPwd">
<svg-icon
:icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"
/>
</span>
</el-form-item>
<el-button
:loading="loading"
type="primary"
style="width: 100%; margin-top: 50px"
@click.native.prevent="handleLogin"
>登 录</el-button
>
</el-form>
</div>
<div class="logo">
<img class="logo-image" src="@/assets/img/comlogo.png" />
<h4 class="logo-title">| 莱博泰克(大连)科技有限公司</h4>
</div>
</div>
</template>
<script>
import { validUsername } from "@/utils/validate";
export default {
name: "Login",
data() {
const validateUsername = (rule, value, callback) => {
if (validUsername(value)) {
callback(new Error("请输入用户名"));
} else {
callback();
}
};
const validatePassword = (rule, value, callback) => {
if (value.length <= 0) {
callback(new Error("请输入密码"));
} else {
callback();
}
};
return {
loginForm: {
username: "",
password: ""
},
loginRules: {
username: [
{ required: true, trigger: "blur", validator: validateUsername }
],
password: [
{ required: true, trigger: "blur", validator: validatePassword }
]
},
loading: false,
passwordType: "password",
redirect: undefined
};
},
watch: {
$route: {
handler: function(route) {
this.redirect = route.query && route.query.redirect;
},
immediate: true
}
},
methods: {
showPwd() {
if (this.passwordType === "password") {
this.passwordType = "";
} else {
this.passwordType = "password";
}
this.$nextTick(() => {
this.$refs.password.focus();
});
},
handleLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
this.loading = true;
this.$store
.dispatch("user/login", this.loginForm)
.then(() => {
// this.$router.push({ path: this.redirect || '/' })
this.$router.push({ path: "/" });
this.loading = false;
// this.$router.go(0);
})
.catch(() => {
this.loading = false;
});
} else {
console.log("提交错误!!");
return false;
}
});
}
}
};
</script>
<style lang="scss">
.milky {
display: block;
font-size: 25px;
font-weight: bold;
text-align: center;
width: 100%;
line-height: 80px;
margin-bottom: 30px;
}
.el-form-item__content {
line-height: 30px;
}
/* 修复input 背景不协调 和光标变色 */
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
$bg: #283443;
$light_gray: #fff;
$cursor: #fff;
@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
.login-container .el-input input {
color: #000;
}
}
/* reset element-ui css */
.login-container {
.el-input {
display: inline-block;
height: 47px;
width: 85%;
input {
border: 0px;
-webkit-appearance: none;
border-radius: 0px;
padding: 12px 5px 12px 15px;
height: 47px;
caret-color: #000;
&:-webkit-autofill {
box-shadow: 0 0 0px 1000px $bg inset !important;
-webkit-text-fill-color: $cursor !important;
}
}
// 输入框背景透明
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
-webkit-text-fill-color: #000 !important;
-webkit-box-shadow: 0 0 0px 1000px transparent inset !important;
background-color: transparent;
background-image: none;
transition: background-color 50000s ease-in-out 0s; //背景色透明 生效时长 过渡效果 启用时延迟的时间
}
}
.el-form-item {
border: 2px solid rgba(0, 0, 0, 0.1);
border-radius: 5px;
color: #454545;
}
}
</style>
<style lang="scss" scoped>
$bg: #2d3a4b;
$dark_gray: #889aa4;
$light_gray: #eee;
#particles-js {
width: 100%;
height: calc(100% - 100px);
position: absolute;
}
.login-form {
background-color: #fff;
border-radius: 20px;
position: absolute;
left: 50%;
top: 50%;
width: 400px;
height: 440px;
margin-left: -200px;
margin-top: -220px;
// width: 520px;
// max-width: 100%;
// padding: 15% 35px 0;
// margin: 0 auto;
overflow: hidden;
}
.login-container {
position: relative;
min-height: 100%;
width: 100%;
background-image: url("../../assets/img/background.jpg");
background-repeat: no-repeat;
background-size: 100%;
overflow: hidden;
.tips {
font-size: 14px;
color: #fff;
margin-bottom: 10px;
span {
&:first-of-type {
margin-right: 16px;
}
}
}
.svg-container {
padding: 6px 5px 6px 15px;
color: $dark_gray;
vertical-align: middle;
width: 30px;
display: inline-block;
}
.title-container {
position: relative;
.title {
font-size: 26px;
color: $light_gray;
margin: 0px auto 40px auto;
text-align: center;
font-weight: bold;
}
}
.show-pwd {
position: absolute;
right: 10px;
top: 7px;
font-size: 16px;
color: $dark_gray;
cursor: pointer;
user-select: none;
}
.title-container {
position: relative;
.title {
font-size: 40px;
color: $light_gray;
margin: 0px auto 40px auto;
text-align: center;
font-weight: bold;
// font-family: "STXingkai";
}
.set-language {
color: #fff;
position: absolute;
top: 3px;
font-size: 18px;
right: 0px;
cursor: pointer;
}
}
}
.el-form {
padding: 40px;
}
// 左右布局
.logo {
// background: red;
position: absolute;
bottom: 2%;
left: 50%;
width: 400px;
height: 30px;
line-height: 30px;
margin-left: -200px;
align-content: center;
text-align: center;
font-size: 18px;
color: #eee;
overflow: hidden;
}
.logo-title {
display: inline;
position: relative;
top: 2px;
margin: 0;
}
.title-text {
// display: inline-block;
float: right;
line-height: 30px;
height: 30px;
}
.title-logo {
position: absolute;
top: 4%;
left: 3%;
}
.image {
width: 150px;
}
.logo-image {
vertical-align: middle;
width: 100px;
}
</style>
login页面
最新推荐文章于 2024-06-08 12:24:57 发布