You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

189 lines
6.6 KiB

4 years ago
<template>
<div class="wrap">
<vHead></vHead>
<div class="login">
<div class="names">
<img class="logo" src="../../../assets/img/three.png" alt="">
<p class="text">或然数据网</p>
</div>
<div class="form">
<div class="title"><span>登录</span></div>
<el-form :model="loginForm" :rules="loginRules" ref="login" label-width="0px">
4 years ago
<el-form-item prop="account">
4 years ago
<label class="account"></label>
4 years ago
<el-input v-model="loginForm.account" placeholder="请输入账号/手机号" @keyup.enter.native="submitForm"></el-input>
4 years ago
</el-form-item>
<el-form-item prop="password">
<label class="password"></label>
4 years ago
<el-input type="password" placeholder="请输入密码" v-model="loginForm.password" @keyup.enter.native="submitForm"></el-input>
</el-form-item>
<el-form-item prop="code">
<label class="code"></label>
<el-input placeholder="请输入验证码" v-model="loginForm.code" @keyup.enter.native="submitForm"></el-input>
<img @click="getVerImg" :src="verificationIMG" class="ver-img" alt="">
4 years ago
</el-form-item>
<el-button class="submit" type="primary" @click="submitForm">登录</el-button>
</el-form>
</div>
</div>
</div>
</template>
<script>
import { mapActions } from 'vuex'
import vHead from '@/layouts/header'
4 years ago
import util from '@/libs/util'
4 years ago
export default {
data: function() {
return {
4 years ago
verificationIMG: '',
4 years ago
loginForm: {
4 years ago
account: 'admin',
password: '111aaa',
random: '',
code: ''
4 years ago
},
loginRules: {
4 years ago
account: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
4 years ago
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
4 years ago
code: [{ required: true, message: '请输入验证码', trigger: 'blur' }],
4 years ago
},
};
},
components: {vHead},
4 years ago
mounted(){
this.getVerImg()
},
4 years ago
methods: {
...mapActions('user', [
'login'
]),
submitForm() {
this.$refs.login.validate(valid => {
if (valid) {
4 years ago
this.login(this.loginForm).then(() => {
4 years ago
let redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : '/index'
this.$router.replace(redirect)
4 years ago
}).catch(res => {
this.getVerImg()
this.loginForm.code = ''
})
4 years ago
}
})
},
4 years ago
getVerImg(){
if(!this.loginForm.account){
return this.verificationIMG = ''
}
this.loginForm.random = Math.floor(Math.random()*999999999)
this.verificationIMG = this.api.verification+'?random='+`${this.loginForm.random}`
}
4 years ago
},
};
</script>
<style scoped lang="scss">
.wrap {
min-height: 100%;
background: url(../../../assets/img/login-bg.png) 0 0/100% 100% no-repeat;
overflow: hidden;
.login{
width: 500px;
margin: 0 auto;
text-align: center;
.names{
margin: 70px 0;
.text{
margin-top: 10px;
font-size: 20px;
color: #fff;
}
}
.form{
padding: 30px;
margin-top: 30px;
border-radius: 10px;
background-color: #fff;
.title{
position: relative;
margin-bottom: 30px;
text-align: center;
span{
display: inline-block;
padding: 9px 20px;
color: #555;
border-bottom: 2px solid $main-color;
}
&:after{
content: '';
position: absolute;
left: 0;
bottom: -1px;
width: 100%;
height: 1px;
background-color: #e0e0e0;
}
}
.el-form{
padding: 0 70px;
}
.label{
margin-bottom: 10px;
color: #105CB2;
}
/deep/.el-input__inner{
position: relative;
height: 46px;
padding: 0 20px 0 40px;
line-height: 46px;
border: 0;
border-bottom: 1px solid #e4e4e4;
border-radius: 0 !important;
}
4 years ago
.account,.password,.code{
4 years ago
z-index: 10;
position: absolute;
top: 11px;
left: 8px;
width: 24px;
height: 28px;
background: url(../../../assets/img/account.png) 0 0/100% 100% no-repeat;
}
.password{
width: 22px;
height: 24px;
background-image: url(../../../assets/img/password.png);
}
4 years ago
.code{
width: 22px;
height: 24px;
background-image: url(../../../assets/img/code.png);
}
.ver-img{
position: absolute;
top: -10px;
right: 0;
4 years ago
}
/deep/.el-form-item__error{
top: 105%;
left: auto;
right: 0;
color: #FFA94E;
}
.submit{
width: 100%;
height: 48px;
margin-top: 30px;
line-height: 48px;
padding: 0;
font-size: 20px;
background-color: $main-color;
border-radius: 8px;
border: 0;
}
}
}
}
</style>