2018-07-16 22:22:55 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="login-page">
|
|
|
|
|
|
<div class="layer bg" id="login"></div>
|
|
|
|
|
|
<div class="layer flex-center">
|
|
|
|
|
|
<!-- logo部分 -->
|
|
|
|
|
|
<div class="logo-group">
|
2018-07-17 16:38:59 +08:00
|
|
|
|
<img src="./image/logo.png" alt="logo">
|
2018-07-16 22:22:55 +08:00
|
|
|
|
</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>
|
|
|
|
|
|
<el-form-item prop="code">
|
|
|
|
|
|
<el-input type="text" v-model="formLogin.code" placeholder="- - - -">
|
|
|
|
|
|
<template slot="prepend">验证码</template>
|
|
|
|
|
|
<template slot="append">
|
2018-07-17 15:44:31 +08:00
|
|
|
|
<img class="login-code" src="./image/login-code.png">
|
2018-07-16 22:22:55 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-button @click="submit" type="primary" class="button-login">登录</el-button>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
</div>
|
2018-07-18 13:57:52 +08:00
|
|
|
|
<!-- 快速登陆按钮 -->
|
|
|
|
|
|
<el-button type="info" class="button-help" @click="dialogVisible = true">
|
|
|
|
|
|
快速选择用户(测试功能)
|
2018-07-16 22:22:55 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
2018-07-18 13:57:52 +08:00
|
|
|
|
<el-dialog
|
|
|
|
|
|
title="快速选择用户"
|
|
|
|
|
|
:visible.sync="dialogVisible"
|
|
|
|
|
|
width="400px">
|
|
|
|
|
|
<el-row :gutter="10" style="margin: -20px 0px -10px 0px;">
|
|
|
|
|
|
<el-col v-for="(user, index) in users" :key="index" :span="8">
|
|
|
|
|
|
<div class="user-btn" @click="handleUserBtnClick(user)">
|
|
|
|
|
|
<d2-icon name="user-circle-o"/>
|
|
|
|
|
|
<span>{{user.name}}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</el-dialog>
|
2018-07-16 22:22:55 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
/* eslint-disable */
|
|
|
|
|
|
require('particles.js')
|
|
|
|
|
|
import config from './config/default'
|
2018-07-20 11:00:28 +08:00
|
|
|
|
import { mapActions } from 'vuex'
|
2018-07-16 22:22:55 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2018-07-18 13:57:52 +08:00
|
|
|
|
// 快速选择用户
|
|
|
|
|
|
dialogVisible: false,
|
|
|
|
|
|
users: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '管理员',
|
|
|
|
|
|
username: 'admin',
|
|
|
|
|
|
password: 'admin'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '编辑',
|
|
|
|
|
|
username: 'editor',
|
|
|
|
|
|
password: 'editor'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2018-07-19 17:00:45 +08:00
|
|
|
|
name: '用户1',
|
|
|
|
|
|
username: 'user1',
|
|
|
|
|
|
password: 'user1'
|
2018-07-18 13:57:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
],
|
|
|
|
|
|
// 表单
|
2018-07-16 22:22:55 +08:00
|
|
|
|
formLogin: {
|
|
|
|
|
|
username: 'admin',
|
|
|
|
|
|
password: 'admin',
|
|
|
|
|
|
code: 'v9am'
|
|
|
|
|
|
},
|
2018-07-18 13:57:52 +08:00
|
|
|
|
// 校验
|
2018-07-16 22:22:55 +08:00
|
|
|
|
rules: {
|
|
|
|
|
|
username: [
|
|
|
|
|
|
{ required: true, message: '请输入用户名', trigger: 'blur' }
|
|
|
|
|
|
],
|
|
|
|
|
|
password: [
|
|
|
|
|
|
{ required: true, message: '请输入密码', trigger: 'blur' }
|
|
|
|
|
|
],
|
|
|
|
|
|
code: [
|
|
|
|
|
|
{ required: true, message: '请输入验证码', trigger: 'blur' }
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
// 初始化例子插件
|
|
|
|
|
|
particlesJS('login', config)
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2018-08-09 14:12:34 +08:00
|
|
|
|
...mapActions('d2admin/account', [
|
2018-08-08 09:19:11 +08:00
|
|
|
|
'login'
|
2018-07-20 10:39:24 +08:00
|
|
|
|
]),
|
2018-07-18 13:57:52 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @description 接收选择一个用户快速登陆的事件
|
2018-07-22 20:34:36 +08:00
|
|
|
|
* @param {Object} user 用户信息
|
2018-07-18 13:57:52 +08:00
|
|
|
|
*/
|
|
|
|
|
|
handleUserBtnClick (user) {
|
|
|
|
|
|
this.formLogin.username = user.username
|
|
|
|
|
|
this.formLogin.password = user.password
|
|
|
|
|
|
this.submit()
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @description 提交表单
|
|
|
|
|
|
*/
|
2018-07-16 22:22:55 +08:00
|
|
|
|
// 提交登陆信息
|
|
|
|
|
|
submit () {
|
|
|
|
|
|
this.$refs.loginForm.validate((valid) => {
|
|
|
|
|
|
if (valid) {
|
2018-07-20 11:00:28 +08:00
|
|
|
|
// 登陆
|
|
|
|
|
|
// 注意 这里的演示没有传验证码
|
|
|
|
|
|
// 具体需要传递的数据请自行修改代码
|
2018-08-08 09:19:11 +08:00
|
|
|
|
this.login({
|
2018-07-20 10:39:24 +08:00
|
|
|
|
vm: this,
|
|
|
|
|
|
username: this.formLogin.username,
|
|
|
|
|
|
password: this.formLogin.password
|
2018-07-16 22:22:55 +08:00
|
|
|
|
})
|
|
|
|
|
|
} else {
|
2018-07-20 11:00:28 +08:00
|
|
|
|
// 登陆表单校验失败
|
2018-07-20 10:57:55 +08:00
|
|
|
|
this.$message.error('表单校验失败')
|
2018-07-16 22:22:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
@import './style.scss';
|
|
|
|
|
|
</style>
|