<template>
|
<div class="login-container">
|
<div class="header">
|
<img class="logo" src="../../assets/heard/logbg.jpg" alt="" />
|
</div>
|
<el-form
|
ref="loginForm"
|
:model="loginForm"
|
:rules="loginRules"
|
class="login-form"
|
autocomplete="on"
|
label-position="left"
|
>
|
<div class="title-container">
|
<h3 class="title">欢迎登录智能化立体库管理系统</h3>
|
</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"
|
autocomplete="on"
|
/>
|
</el-form-item>
|
|
<el-tooltip v-model="capsTooltip" content="Caps lock is On" placement="right" manual>
|
<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"
|
autocomplete="on"
|
@keyup.native="checkCapslock"
|
@blur="capsTooltip = false"
|
@keyup.enter.native="handleLogin"
|
/>
|
<span class="show-pwd" @click="showPwd">
|
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
|
</span>
|
</el-form-item>
|
</el-tooltip>
|
|
<el-button
|
:loading="loading"
|
type="primary"
|
style="width: 100%; margin-bottom: 30px"
|
@click.native.prevent="handleLogin"
|
>登录</el-button
|
>
|
</el-form>
|
</div>
|
</template>
|
|
<script>
|
import { validUsername } from '@/utils/validate';
|
import { getCache, setCache } from '@/utils/sessionStorage';
|
export default {
|
name: 'Login',
|
components: {},
|
data() {
|
return {
|
loginForm: {
|
username: '',
|
password: ''
|
},
|
loginRules: {
|
username: [{ required: true, message: '请输入账号', trigger: 'blur' }],
|
password: [{ required: true, trigger: 'blur', message: '请输入密码' }]
|
},
|
passwordType: 'password',
|
capsTooltip: false,
|
loading: false,
|
showDialog: false,
|
redirect: undefined,
|
otherQuery: {}
|
};
|
},
|
watch: {
|
$route: {
|
handler: function (route) {
|
const query = route.query;
|
if (query) {
|
this.redirect = query.redirect;
|
this.otherQuery = this.getOtherQuery(query);
|
}
|
},
|
immediate: true
|
}
|
},
|
created() {
|
// window.addEventListener('storage', this.afterQRScan)
|
},
|
mounted() {
|
if (this.loginForm.username === '') {
|
this.$refs.username.focus();
|
} else if (this.loginForm.password === '') {
|
this.$refs.password.focus();
|
}
|
},
|
destroyed() {
|
// window.removeEventListener('storage', this.afterQRScan)
|
},
|
methods: {
|
checkCapslock(e) {
|
const { key } = e;
|
this.capsTooltip = key && key.length === 1 && key >= 'A' && key <= 'Z';
|
},
|
showPwd() {
|
if (this.passwordType === 'password') {
|
this.passwordType = 'text';
|
} 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(res => {
|
// this.loading = false;
|
if (res.code == 0) {
|
let data = res.data[0];
|
setCache('userInfo', data);
|
this.$router.push({
|
path: '/Didproject'
|
});
|
} else {
|
this.$message({
|
type: 'warning',
|
message: res.msg
|
});
|
}
|
this.loading = false;
|
})
|
.catch(() => {
|
this.loading = false;
|
});
|
} else {
|
console.log('error submit!!');
|
return false;
|
}
|
});
|
},
|
getOtherQuery(query) {
|
return Object.keys(query).reduce((acc, cur) => {
|
if (cur !== 'redirect') {
|
acc[cur] = query[cur];
|
}
|
return acc;
|
}, {});
|
}
|
}
|
};
|
</script>
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
$bg: #fbfbfb;
|
$dark_gray: #889aa4;
|
$light_gray: #666;
|
$cursor: #666;
|
|
.header {
|
background-color: white;
|
position: relative;
|
display: table-cell;
|
display: -webkit-box;
|
-webkit-box-pack: center;
|
-webkit-box-orient: vertical;
|
height: 60px;
|
width: 100%;
|
padding: 10px 30px;
|
border-bottom: 1px solid #f3f3f3;
|
|
.logo {
|
height: 60px;
|
}
|
}
|
|
/* reset element-ui css */
|
.login-container {
|
/deep/ .el-input {
|
display: inline-block;
|
height: 47px;
|
width: 85%;
|
input {
|
background: transparent;
|
border: 0px;
|
-webkit-appearance: none;
|
border-radius: 0px;
|
padding: 12px 5px 12px 15px;
|
color: $light_gray;
|
height: 47px;
|
caret-color: $cursor;
|
&:-webkit-autofill {
|
box-shadow: 0 0 0px 1000px $bg inset !important;
|
-webkit-text-fill-color: $cursor !important;
|
}
|
}
|
}
|
/deep/ .el-form-item {
|
background: rgba(216, 216, 216, 0.05);
|
border: 1px solid #ddd;
|
border-radius: 4px;
|
|
color: #454545;
|
.el-form-item__content {
|
background-color: $bg;
|
border-radius: 4px;
|
}
|
}
|
}
|
|
.login-container {
|
height: 100%;
|
width: 100%;
|
overflow: hidden;
|
.login-form {
|
position: absolute;
|
left: 50%;
|
top: 50%;
|
transform: translate(-50%, -50%);
|
// right: 0;
|
width: 480px;
|
max-width: 100%;
|
padding: 30px 30px 10px 30px;
|
// margin: 110px auto;
|
|
border: 1px solid #eee;
|
border-radius: 4px;
|
overflow: hidden;
|
.btn-login {
|
width: 100%;
|
margin-bottom: 30px;
|
height: 46px;
|
}
|
.forget-pwd {
|
padding: 0 10px;
|
text-align: right;
|
a {
|
font-family: PingFangSC-Light;
|
font-size: 14px;
|
color: #0099ff;
|
letter-spacing: 0;
|
&:hover {
|
color: #71c6ff;
|
}
|
}
|
}
|
}
|
.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: #666;
|
margin: 0px auto 40px auto;
|
text-align: center;
|
font-weight: bold;
|
}
|
.set-language {
|
color: #666;
|
position: absolute;
|
top: 5px;
|
right: 0px;
|
}
|
}
|
.show-pwd {
|
position: absolute;
|
right: 10px;
|
top: 7px;
|
font-size: 16px;
|
color: $dark_gray;
|
cursor: pointer;
|
user-select: none;
|
}
|
.thirdparty-button {
|
position: absolute;
|
right: 35px;
|
bottom: 28px;
|
}
|
}
|
</style>
|
|
<style rel="stylesheet/scss" lang="scss">
|
html,
|
body {
|
background-color: #fff;
|
}
|
.vux-divider {
|
white-space: nowrap;
|
width: 100%;
|
text-align: center;
|
padding: 10px 0;
|
color: #666;
|
overflow: hidden;
|
position: relative;
|
.text {
|
display: inline-block;
|
padding: 0 10px;
|
position: relative;
|
z-index: 100;
|
background-color: #fff;
|
}
|
&::before {
|
content: ' ';
|
width: 50%;
|
border-top: 1px solid #e4e7ed;
|
height: 1px;
|
display: inline-block;
|
position: absolute;
|
top: 19px;
|
right: 0;
|
}
|
&::after {
|
content: ' ';
|
width: 50%;
|
border-top: 1px solid #e4e7ed;
|
height: 1px;
|
display: inline-block;
|
position: absolute;
|
top: 19px;
|
left: 0;
|
}
|
}
|
</style>
|