<template>
|
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" :inline="false" class="loginForm" @keydown.enter.native="handleSubmit">
|
<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
|
v-model="loginForm.username"
|
placeholder="请输入用户名"
|
name="username"
|
type="text"
|
auto-complete="on"
|
/>
|
</el-form-item>
|
<el-form-item prop="password">
|
<span class="svg-container">
|
<svg-icon icon-class="password" />
|
</span>
|
<el-input
|
v-model="loginForm.password"
|
:type="loginPasswordType"
|
placeholder="请输入密码"
|
name="password"
|
auto-complete="on"
|
@keyup.enter.native="handleSubmit"
|
/>
|
<span class="show-pwd" @click="showLoginPwd">
|
<svg-icon :icon-class="loginPasswordType === 'password' ? 'eye' : 'eye-open'" />
|
</span>
|
</el-form-item>
|
<div style="text-align:center;">
|
<el-button :loading="logingLoading" class="login-button" type="primary" @click.native.prevent="handleSubmit">
|
登录
|
</el-button>
|
<br>
|
</div>
|
</el-form>
|
</template>
|
<script>
|
import Cookies from "js-cookie";
|
|
export default {
|
name: 'LoginForm',
|
props: {
|
logingLoading: {
|
type: Boolean,
|
default: false
|
}
|
},
|
watch:{
|
// loginForm: {
|
// handler(newName, oldName) {
|
// debugger
|
// let store = localStorage.getItem('loginForm')
|
// if(store === undefined || store === null){
|
// }else{
|
// if(newName.username === JSON.parse(store).username && newName.password === JSON.parse(store).password){
|
// this.loginForm.authcode = JSON.parse(localStorage.getItem('loginForm')).authcode
|
// }else{
|
// // this.loginForm.authcode = ''
|
// }
|
// }
|
// },
|
// immediate:true,
|
// deep:true
|
// }
|
},
|
data() {
|
return {
|
loginForm: {
|
username: '',
|
password: '',
|
},
|
loginRules: {
|
username: [{ required: true, trigger: 'blur', message: '用户名不能为空' }],
|
password: [{ required: true, trigger: 'blur', message: '登录密码不能为空' }],
|
},
|
loginPasswordType: 'password'
|
}
|
},
|
computed: {
|
|
},
|
created(){
|
this.test()
|
},
|
methods: {
|
showLoginPwd() {
|
if (this.loginPasswordType === 'password') {
|
this.loginPasswordType = ''
|
} else {
|
this.loginPasswordType = 'password'
|
}
|
},
|
handleSubmit() {
|
this.$refs.loginForm.validate((valid) => {
|
if (valid) {
|
this.$emit('on-success-valid', this.loginForm)
|
}
|
})
|
},
|
initLoginDataForm() {
|
this.loginForm = {
|
username: '',
|
password: ''
|
}
|
},
|
handleChangeToRegister() {
|
this.initLoginDataForm()
|
// this.$nextTick(() => {
|
// this.$refs['loginForm'].clearValidate()
|
// })
|
this.$emit('on-register-handle')
|
},
|
// giveKey(){
|
// let login = JSON.parse(Cookies.get('loginForm'))
|
// this.loginForm.authcode = login.authcode
|
// }
|
}
|
}
|
</script>
|
|
<style rel="stylesheet/scss" lang="scss">
|
$cursor: #fff;
|
$bg:#2d3a4b;
|
$dark_gray:#889aa4;
|
$light_gray:#eee;
|
.loginForm {
|
.el-input {
|
display: inline-block;
|
height: 47px;
|
width: 85%;
|
input {
|
background: transparent;
|
background-color: #eee;
|
border: 0px;
|
-webkit-appearance: none;
|
border-radius: 0px;
|
padding: 12px 5px 12px 15px;
|
color: #333333;
|
height: 47px;
|
caret-color:#333333;
|
&:-webkit-autofill {
|
-webkit-box-shadow: 0 0 0px 1000px #cfd5da inset !important;
|
-webkit-text-fill-color: #fff !important;
|
}
|
}
|
}
|
.el-form-item {
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
background: rgba(0, 0, 0, 0.1);
|
border-radius: 5px;
|
color: #454545;
|
}
|
.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: #333333;
|
margin: 0px auto 40px auto;
|
text-align: center;
|
font-weight: bold;
|
}
|
.set-language {
|
color: #fff;
|
position: absolute;
|
top: 3px;
|
font-size:18px;
|
right: 0px;
|
cursor: pointer;
|
}
|
}
|
.show-pwd {
|
position: absolute;
|
right: 10px;
|
top: 7px;
|
font-size: 16px;
|
color: $dark_gray;
|
cursor: pointer;
|
user-select: none;
|
}
|
.thirdparty-button {
|
position: absolute;
|
right: 0;
|
bottom: 6px;
|
}
|
.login-button {
|
height:36px;
|
margin-bottom:30px;
|
margin-top:10px;
|
width:100px;
|
border-radius:25px;
|
background-color: #034EA2;
|
}
|
}
|
|
</style>
|