master
parent
2ab4d4ac9c
commit
3734638051
@ -1,233 +1,231 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="login-container">
|
<div class="login-container">
|
||||||
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
|
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on"
|
||||||
|
label-position="left">
|
||||||
<div class="title-container">
|
|
||||||
<h3 class="title">安全生产管理系统登录</h3>
|
<div class="title-container">
|
||||||
</div>
|
<h3 class="title">安全生产管理系统登录</h3>
|
||||||
|
</div>
|
||||||
<el-form-item prop="username">
|
|
||||||
<span class="svg-container">
|
<el-form-item prop="username">
|
||||||
<svg-icon icon-class="user" />
|
<span class="svg-container">
|
||||||
</span>
|
<svg-icon icon-class="user" />
|
||||||
<el-input
|
</span>
|
||||||
ref="username"
|
<el-input ref="username" v-model="loginForm.username" placeholder="请输入账号" name="username" type="text"
|
||||||
v-model="loginForm.username"
|
tabindex="1" auto-complete="off" />
|
||||||
placeholder="请输入账号"
|
</el-form-item>
|
||||||
name="username"
|
|
||||||
type="text"
|
<el-form-item prop="password">
|
||||||
tabindex="1"
|
<span class="svg-container">
|
||||||
auto-complete="off"
|
<svg-icon icon-class="password" />
|
||||||
/>
|
</span>
|
||||||
</el-form-item>
|
<el-input :key="passwordType" ref="password" v-model="loginForm.password" :type="passwordType"
|
||||||
|
placeholder="请输入密码" name="password" tabindex="2" auto-complete="off" @keyup.enter.native="handleLogin" />
|
||||||
<el-form-item prop="password">
|
<!-- <span class="show-pwd" @click="showPwd">
|
||||||
<span class="svg-container">
|
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
|
||||||
<svg-icon icon-class="password" />
|
</span> -->
|
||||||
</span>
|
</el-form-item>
|
||||||
<el-input
|
|
||||||
:key="passwordType"
|
<el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;"
|
||||||
ref="password"
|
@click.native.prevent="handleLogin">登录</el-button>
|
||||||
v-model="loginForm.password"
|
|
||||||
:type="passwordType"
|
</el-form>
|
||||||
placeholder="请输入密码"
|
</div>
|
||||||
name="password"
|
</template>
|
||||||
tabindex="2"
|
|
||||||
auto-complete="off"
|
<script>
|
||||||
@keyup.enter.native="handleLogin"
|
import {
|
||||||
/>
|
validUsername
|
||||||
<span class="show-pwd" @click="showPwd">
|
} from '@/utils/validate'
|
||||||
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
|
|
||||||
</span>
|
export default {
|
||||||
</el-form-item>
|
name: 'Login',
|
||||||
|
data() {
|
||||||
<el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">登录</el-button>
|
const validateUsername = (rule, value, callback) => {
|
||||||
|
if (false) {
|
||||||
</el-form>
|
callback(new Error('请正确输入登录名'))
|
||||||
</div>
|
} else {
|
||||||
</template>
|
callback()
|
||||||
|
}
|
||||||
<script>
|
}
|
||||||
import { validUsername } from '@/utils/validate'
|
const validatePassword = (rule, value, callback) => {
|
||||||
|
if (false) {
|
||||||
export default {
|
callback(new Error('请正确输入密码'))
|
||||||
name: 'Login',
|
} else {
|
||||||
data() {
|
callback()
|
||||||
const validateUsername = (rule, value, callback) => {
|
}
|
||||||
if (false) {
|
}
|
||||||
callback(new Error('请正确输入登录名'))
|
return {
|
||||||
} else {
|
loginForm: {
|
||||||
callback()
|
username: '',
|
||||||
}
|
password: ''
|
||||||
}
|
},
|
||||||
const validatePassword = (rule, value, callback) => {
|
loginRules: {
|
||||||
if (false) {
|
username: [{
|
||||||
callback(new Error('请正确输入密码'))
|
required: true,
|
||||||
} else {
|
trigger: 'blur',
|
||||||
callback()
|
validator: validateUsername
|
||||||
}
|
}],
|
||||||
}
|
password: [{
|
||||||
return {
|
required: true,
|
||||||
loginForm: {
|
trigger: 'blur',
|
||||||
username: '',
|
validator: validatePassword
|
||||||
password: ''
|
}]
|
||||||
},
|
},
|
||||||
loginRules: {
|
loading: false,
|
||||||
username: [{ required: true, trigger: 'blur', validator: validateUsername }],
|
passwordType: 'password',
|
||||||
password: [{ required: true, trigger: 'blur', validator: validatePassword }]
|
redirect: undefined
|
||||||
},
|
}
|
||||||
loading: false,
|
},
|
||||||
passwordType: 'password',
|
watch: {
|
||||||
redirect: undefined
|
$route: {
|
||||||
}
|
handler: function(route) {
|
||||||
},
|
this.redirect = route.query && route.query.redirect
|
||||||
watch: {
|
},
|
||||||
$route: {
|
immediate: true
|
||||||
handler: function(route) {
|
}
|
||||||
this.redirect = route.query && route.query.redirect
|
},
|
||||||
},
|
methods: {
|
||||||
immediate: true
|
showPwd() {
|
||||||
}
|
if (this.passwordType === 'password') {
|
||||||
},
|
this.passwordType = ''
|
||||||
methods: {
|
} else {
|
||||||
showPwd() {
|
this.passwordType = 'password'
|
||||||
if (this.passwordType === 'password') {
|
}
|
||||||
this.passwordType = ''
|
this.$nextTick(() => {
|
||||||
} else {
|
this.$refs.password.focus()
|
||||||
this.passwordType = 'password'
|
})
|
||||||
}
|
},
|
||||||
this.$nextTick(() => {
|
handleLogin() {
|
||||||
this.$refs.password.focus()
|
this.$refs.loginForm.validate(valid => {
|
||||||
})
|
if (valid) {
|
||||||
},
|
this.loading = true
|
||||||
handleLogin() {
|
this.$store.dispatch('user/login', this.loginForm).then(() => {
|
||||||
this.$refs.loginForm.validate(valid => {
|
console.log(this.redirect)
|
||||||
if (valid) {
|
this.$router.push({
|
||||||
this.loading = true
|
path: this.redirect || '/'
|
||||||
this.$store.dispatch('user/login', this.loginForm).then(() => {
|
})
|
||||||
console.log(this.redirect)
|
this.loading = false
|
||||||
this.$router.push({ path: this.redirect || '/' })
|
}).catch(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}).catch(() => {
|
})
|
||||||
this.loading = false
|
} else {
|
||||||
})
|
console.log('error submit!!')
|
||||||
} else {
|
return false
|
||||||
console.log('error submit!!')
|
}
|
||||||
return false
|
})
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
</script>
|
||||||
}
|
|
||||||
</script>
|
<style lang="scss">
|
||||||
|
/* 修复input 背景不协调 和光标变色 */
|
||||||
<style lang="scss">
|
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
|
||||||
/* 修复input 背景不协调 和光标变色 */
|
|
||||||
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
|
$bg:#283443;
|
||||||
|
$light_gray:#fff;
|
||||||
$bg:#283443;
|
$cursor: #fff;
|
||||||
$light_gray:#fff;
|
|
||||||
$cursor: #fff;
|
@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
|
||||||
|
.login-container .el-input input {
|
||||||
@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
|
color: $cursor;
|
||||||
.login-container .el-input input {
|
}
|
||||||
color: $cursor;
|
}
|
||||||
}
|
|
||||||
}
|
/* reset element-ui css */
|
||||||
|
.login-container {
|
||||||
/* reset element-ui css */
|
.el-input {
|
||||||
.login-container {
|
display: inline-block;
|
||||||
.el-input {
|
height: 47px;
|
||||||
display: inline-block;
|
width: 85%;
|
||||||
height: 47px;
|
|
||||||
width: 85%;
|
input {
|
||||||
|
background: transparent;
|
||||||
input {
|
border: 0px;
|
||||||
background: transparent;
|
-webkit-appearance: none;
|
||||||
border: 0px;
|
border-radius: 0px;
|
||||||
-webkit-appearance: none;
|
padding: 12px 5px 12px 15px;
|
||||||
border-radius: 0px;
|
color: $light_gray;
|
||||||
padding: 12px 5px 12px 15px;
|
height: 47px;
|
||||||
color: $light_gray;
|
caret-color: $cursor;
|
||||||
height: 47px;
|
|
||||||
caret-color: $cursor;
|
&:-webkit-autofill {
|
||||||
|
box-shadow: 0 0 0px 1000px $bg inset !important;
|
||||||
&:-webkit-autofill {
|
-webkit-text-fill-color: $cursor !important;
|
||||||
box-shadow: 0 0 0px 1000px $bg inset !important;
|
}
|
||||||
-webkit-text-fill-color: $cursor !important;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
.el-form-item {
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
.el-form-item {
|
background: rgba(0, 0, 0, 0.1);
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
border-radius: 5px;
|
||||||
background: rgba(0, 0, 0, 0.1);
|
color: #454545;
|
||||||
border-radius: 5px;
|
}
|
||||||
color: #454545;
|
}
|
||||||
}
|
</style>
|
||||||
}
|
|
||||||
</style>
|
<style lang="scss" scoped>
|
||||||
|
$bg:#2d3a4b;
|
||||||
<style lang="scss" scoped>
|
$dark_gray:#889aa4;
|
||||||
$bg:#2d3a4b;
|
$light_gray:#eee;
|
||||||
$dark_gray:#889aa4;
|
|
||||||
$light_gray:#eee;
|
.login-container {
|
||||||
|
min-height: 100%;
|
||||||
.login-container {
|
width: 100%;
|
||||||
min-height: 100%;
|
background-color: $bg;
|
||||||
width: 100%;
|
overflow: hidden;
|
||||||
background-color: $bg;
|
|
||||||
overflow: hidden;
|
.login-form {
|
||||||
|
position: relative;
|
||||||
.login-form {
|
width: 520px;
|
||||||
position: relative;
|
max-width: 100%;
|
||||||
width: 520px;
|
padding: 160px 35px 0;
|
||||||
max-width: 100%;
|
margin: 0 auto;
|
||||||
padding: 160px 35px 0;
|
overflow: hidden;
|
||||||
margin: 0 auto;
|
}
|
||||||
overflow: hidden;
|
|
||||||
}
|
.tips {
|
||||||
|
font-size: 14px;
|
||||||
.tips {
|
color: #fff;
|
||||||
font-size: 14px;
|
margin-bottom: 10px;
|
||||||
color: #fff;
|
|
||||||
margin-bottom: 10px;
|
span {
|
||||||
|
&:first-of-type {
|
||||||
span {
|
margin-right: 16px;
|
||||||
&:first-of-type {
|
}
|
||||||
margin-right: 16px;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
.svg-container {
|
||||||
|
padding: 6px 5px 6px 15px;
|
||||||
.svg-container {
|
color: $dark_gray;
|
||||||
padding: 6px 5px 6px 15px;
|
vertical-align: middle;
|
||||||
color: $dark_gray;
|
width: 30px;
|
||||||
vertical-align: middle;
|
display: inline-block;
|
||||||
width: 30px;
|
}
|
||||||
display: inline-block;
|
|
||||||
}
|
.title-container {
|
||||||
|
position: relative;
|
||||||
.title-container {
|
|
||||||
position: relative;
|
.title {
|
||||||
|
font-size: 26px;
|
||||||
.title {
|
color: $light_gray;
|
||||||
font-size: 26px;
|
margin: 0px auto 40px auto;
|
||||||
color: $light_gray;
|
text-align: center;
|
||||||
margin: 0px auto 40px auto;
|
font-weight: bold;
|
||||||
text-align: center;
|
}
|
||||||
font-weight: bold;
|
}
|
||||||
}
|
|
||||||
}
|
.show-pwd {
|
||||||
|
position: absolute;
|
||||||
.show-pwd {
|
right: 10px;
|
||||||
position: absolute;
|
top: 7px;
|
||||||
right: 10px;
|
font-size: 16px;
|
||||||
top: 7px;
|
color: $dark_gray;
|
||||||
font-size: 16px;
|
cursor: pointer;
|
||||||
color: $dark_gray;
|
user-select: none;
|
||||||
cursor: pointer;
|
}
|
||||||
user-select: none;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
Reference in new issue