2018-01-20 10:17:35 +08:00
|
|
|
<template>
|
2018-01-21 23:30:01 +08:00
|
|
|
<div class="login-page">
|
|
|
|
|
<div class="layer bg" id="login"></div>
|
2018-01-22 00:04:39 +08:00
|
|
|
<div class="layer flex-center">
|
|
|
|
|
<div class="logo-group">
|
|
|
|
|
<img src="@/assets/image/logo/w500.png" alt="logo">
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<el-card>
|
|
|
|
|
<el-form
|
|
|
|
|
ref="loginForm"
|
|
|
|
|
label-position="top"
|
|
|
|
|
:rules="rules"
|
|
|
|
|
:model="formLogin">
|
|
|
|
|
<el-form-item prop="username">
|
|
|
|
|
<el-input
|
|
|
|
|
type="text"
|
|
|
|
|
v-model="formLogin.username"
|
|
|
|
|
placeholder="用户名">
|
|
|
|
|
<i slot="prepend" class="fa fa-user-circle-o"></i>
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item prop="password">
|
|
|
|
|
<el-input
|
|
|
|
|
type="password"
|
|
|
|
|
v-model="formLogin.password"
|
|
|
|
|
placeholder="密码">
|
|
|
|
|
<i slot="prepend" class="fa fa-keyboard-o"></i>
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
2018-01-22 16:56:57 +08:00
|
|
|
<el-button
|
|
|
|
|
@click="submit"
|
|
|
|
|
type="primary"
|
|
|
|
|
class="button-login">
|
|
|
|
|
登陆
|
|
|
|
|
</el-button>
|
2018-01-22 00:04:39 +08:00
|
|
|
</el-form>
|
|
|
|
|
</el-card>
|
|
|
|
|
<el-button type="info" class="button-help">
|
|
|
|
|
需要帮助
|
|
|
|
|
<i class="fa fa-question-circle"></i>
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
2018-01-21 23:30:01 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2018-01-20 10:17:35 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
/* eslint-disable */
|
|
|
|
|
require('particles.js')
|
|
|
|
|
// 配置地址
|
|
|
|
|
// https://vincentgarreau.com/particles.js/#default
|
2018-01-21 23:03:28 +08:00
|
|
|
import config from './config/default'
|
2018-01-20 10:17:35 +08:00
|
|
|
export default {
|
2018-01-22 00:04:39 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
formLogin: {
|
|
|
|
|
username: '',
|
|
|
|
|
password: ''
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
username: [
|
|
|
|
|
{ required: true, message: '请输入用户名', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
password: [
|
|
|
|
|
{ required: true, message: '请输入密码', trigger: 'blur' }
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-01-20 10:17:35 +08:00
|
|
|
mounted () {
|
2018-01-22 16:56:57 +08:00
|
|
|
// 初始化例子插件
|
2018-01-20 10:17:35 +08:00
|
|
|
particlesJS('login', config)
|
2018-01-22 00:04:39 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2018-01-22 16:56:57 +08:00
|
|
|
// 提交登陆信息
|
2018-01-22 00:04:39 +08:00
|
|
|
submit () {
|
|
|
|
|
this.$refs.loginForm.validate((valid) => {
|
|
|
|
|
if (valid) {
|
2018-01-22 13:49:11 +08:00
|
|
|
this.$axios({
|
|
|
|
|
method: 'post',
|
|
|
|
|
url: '/login',
|
|
|
|
|
data: {
|
|
|
|
|
username: this.formLogin.username,
|
|
|
|
|
password: this.formLogin.password
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.then (res => {
|
|
|
|
|
if (res.data.code === 0) {
|
|
|
|
|
this.$message.success(res.data.msg)
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.$router.push('index')
|
|
|
|
|
}, 300);
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(res.data.msg)
|
|
|
|
|
}
|
|
|
|
|
})
|
2018-01-22 00:04:39 +08:00
|
|
|
} else {
|
2018-01-22 13:49:11 +08:00
|
|
|
return false
|
2018-01-22 00:04:39 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2018-01-20 10:17:35 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2018-01-21 23:19:19 +08:00
|
|
|
<style lang="scss">
|
2018-01-22 13:10:10 +08:00
|
|
|
@import '~@/assets/style/public.scss';
|
2018-01-21 23:30:01 +08:00
|
|
|
.login-page {
|
2018-01-21 23:19:19 +08:00
|
|
|
background-color: #EDF4FA;
|
2018-01-20 10:17:35 +08:00
|
|
|
height: 100%;
|
2018-01-21 23:30:01 +08:00
|
|
|
position: relative;
|
|
|
|
|
// 层
|
|
|
|
|
.layer {
|
|
|
|
|
position: absolute;
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
2018-01-22 00:04:39 +08:00
|
|
|
&.flex-center {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// logo
|
|
|
|
|
.logo-group {
|
|
|
|
|
margin-top: -100px;
|
|
|
|
|
img {
|
|
|
|
|
width: 100px;
|
|
|
|
|
}
|
2018-01-21 23:30:01 +08:00
|
|
|
}
|
|
|
|
|
// 登陆表单
|
|
|
|
|
.form-group {
|
2018-01-22 00:04:39 +08:00
|
|
|
width: 300px;
|
|
|
|
|
.el-card {
|
|
|
|
|
box-shadow: 0 0 8px 0 rgba(232,237,250,.6), 0 2px 4px 0 rgba(232,237,250,.5);
|
|
|
|
|
}
|
|
|
|
|
.button-login {
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-22 16:56:57 +08:00
|
|
|
// 帮助按钮
|
2018-01-22 00:04:39 +08:00
|
|
|
.button-help {
|
2018-01-22 13:10:10 +08:00
|
|
|
width: 100%;
|
|
|
|
|
margin-top: $margin;
|
2018-01-21 23:30:01 +08:00
|
|
|
}
|
|
|
|
|
// 背景
|
|
|
|
|
.bg {
|
|
|
|
|
canvas {
|
|
|
|
|
display: block;
|
|
|
|
|
margin: 0px;
|
|
|
|
|
padding: 0px;
|
|
|
|
|
}
|
2018-01-21 23:19:19 +08:00
|
|
|
}
|
2018-01-20 10:17:35 +08:00
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|