fix(): 增加注册
parent
ebb12f9686
commit
65dc3085bb
|
@ -4,7 +4,14 @@ export function login(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/auth/login',
|
url: '/system/auth/login',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export function reg(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/auth/reg',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,17 +13,11 @@
|
||||||
<el-dropdown-menu slot="dropdown" class="user-dropdown">
|
<el-dropdown-menu slot="dropdown" class="user-dropdown">
|
||||||
<router-link to="/">
|
<router-link to="/">
|
||||||
<el-dropdown-item>
|
<el-dropdown-item>
|
||||||
Home
|
主页
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</router-link>
|
</router-link>
|
||||||
<a target="_blank" href="https://github.com/PanJiaChen/vue-admin-template/">
|
|
||||||
<el-dropdown-item>Github</el-dropdown-item>
|
|
||||||
</a>
|
|
||||||
<a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/">
|
|
||||||
<el-dropdown-item>Docs</el-dropdown-item>
|
|
||||||
</a>
|
|
||||||
<el-dropdown-item divided @click.native="logout">
|
<el-dropdown-item divided @click.native="logout">
|
||||||
<span style="display:block;">Log Out</span>
|
<span style="display:block;">退出登录</span>
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
<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">
|
<div class="title-container">
|
||||||
<h3 class="title">车辆模拟</h3>
|
<h3 class="title">智能车联-车机模拟器</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-form-item prop="userName">
|
<el-form-item prop="userName">
|
||||||
<span class="svg-container">
|
<span class="svg-container">
|
||||||
<svg-icon icon-class="user" />
|
<svg-icon icon-class="user"/>
|
||||||
</span>
|
</span>
|
||||||
<el-input
|
<el-input
|
||||||
ref="userName"
|
ref="userName"
|
||||||
|
@ -23,7 +24,7 @@
|
||||||
|
|
||||||
<el-form-item prop="password">
|
<el-form-item prop="password">
|
||||||
<span class="svg-container">
|
<span class="svg-container">
|
||||||
<svg-icon icon-class="password" />
|
<svg-icon icon-class="password"/>
|
||||||
</span>
|
</span>
|
||||||
<el-input
|
<el-input
|
||||||
ref="password"
|
ref="password"
|
||||||
|
@ -37,15 +38,68 @@
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-button :loading="loading" type="primary" style="width:48%;margin-bottom:30px;" @click.native.prevent="handleLogin">登录系统</el-button>
|
<el-button :loading="loading" type="primary" style="width:48%;margin-bottom:30px;"
|
||||||
<el-button :loading="loading" type="primary" style="width:48%;margin-bottom:30px; margin-left: 4%" @click.native.prevent="handleLogin">注册系统</el-button>
|
@click.native.prevent="handleLogin">登录系统
|
||||||
|
</el-button>
|
||||||
|
<el-button :loading="loading" type="primary" style="width:48%;margin-bottom:30px; margin-left: 4%"
|
||||||
|
@click="regUser">注册系统
|
||||||
|
</el-button>
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
|
<el-dialog
|
||||||
|
:visible.sync="regUserStatus"
|
||||||
|
width="30%">
|
||||||
|
<el-form ref="regForm" :model="regForm" :rules="loginRules" class="login-form" auto-complete="on"
|
||||||
|
style="padding: 0 30px 0"
|
||||||
|
label-position="left">
|
||||||
|
|
||||||
|
<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
|
||||||
|
ref="userName"
|
||||||
|
v-model="regForm.userName"
|
||||||
|
placeholder="用户登录名称"
|
||||||
|
name="userName"
|
||||||
|
type="text"
|
||||||
|
tabindex="1"
|
||||||
|
auto-complete="on"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item prop="password">
|
||||||
|
<span class="svg-container">
|
||||||
|
<svg-icon icon-class="password"/>
|
||||||
|
</span>
|
||||||
|
<el-input
|
||||||
|
ref="password"
|
||||||
|
v-model="regForm.password"
|
||||||
|
type="password"
|
||||||
|
placeholder="用户登录密码"
|
||||||
|
name="password"
|
||||||
|
tabindex="2"
|
||||||
|
auto-complete="on"
|
||||||
|
@keyup.enter.native="handleLogin"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<span slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="regUserStatus = false">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="doRegUser">确 定</el-button>
|
||||||
|
</span>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
import {reg} from "@/api/user";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Login',
|
name: 'Login',
|
||||||
data() {
|
data() {
|
||||||
|
@ -54,9 +108,14 @@ export default {
|
||||||
userName: '',
|
userName: '',
|
||||||
password: ''
|
password: ''
|
||||||
},
|
},
|
||||||
|
regForm: {
|
||||||
|
userName: '',
|
||||||
|
password: ''
|
||||||
|
},
|
||||||
|
regUserStatus: false,
|
||||||
loginRules: {
|
loginRules: {
|
||||||
userName: [{ required: true, trigger: 'blur' }],
|
userName: [{required: true, trigger: 'blur',message: '请输入用户名称'}],
|
||||||
password: [{ required: true, trigger: 'blur' }]
|
password: [{required: true, trigger: 'blur',message: '请输入用户密码'}]
|
||||||
},
|
},
|
||||||
loading: false,
|
loading: false,
|
||||||
passwordType: 'password',
|
passwordType: 'password',
|
||||||
|
@ -65,24 +124,45 @@ export default {
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
$route: {
|
$route: {
|
||||||
handler: function(route) {
|
handler: function (route) {
|
||||||
this.redirect = route.query && route.query.redirect
|
this.redirect = route.query && route.query.redirect
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 注册用户
|
||||||
|
doRegUser() {
|
||||||
|
this.$refs.regForm.validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
reg(this.regForm).then(response => {
|
||||||
|
this.$message({
|
||||||
|
message: '注册成功',
|
||||||
|
type: 'success'
|
||||||
|
})
|
||||||
|
this.regUserStatus = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
regUser() {
|
||||||
|
this.regUserStatus = true
|
||||||
|
this.regForm = {
|
||||||
|
userName: '',
|
||||||
|
password: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
handleLogin() {
|
handleLogin() {
|
||||||
this.$refs.loginForm.validate(valid => {
|
this.$refs.loginForm.validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.$store.dispatch('user/login', this.loginForm).then(() => {
|
this.$store.dispatch('user/login', this.loginForm).then(() => {
|
||||||
this.$router.push({ path: this.redirect || '/' })
|
this.$router.push({path: this.redirect || '/'})
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
this.$router.push({ path: this.redirect || '/' })
|
this.$router.push({path: this.redirect || '/'})
|
||||||
} else {
|
} else {
|
||||||
console.log('error submit!!')
|
console.log('error submit!!')
|
||||||
return false
|
return false
|
||||||
|
@ -97,10 +177,12 @@ export default {
|
||||||
/* 修复input 背景不协调 和光标变色 */
|
/* 修复input 背景不协调 和光标变色 */
|
||||||
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
|
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
|
||||||
|
|
||||||
$bg:#283443;
|
$bg: #283443;
|
||||||
$light_gray:#fff;
|
$light_gray: #fff;
|
||||||
$cursor: #fff;
|
$cursor: #fff;
|
||||||
|
.el-dialog{
|
||||||
|
background-color: #2d3a4b;
|
||||||
|
}
|
||||||
@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
|
@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
|
||||||
.login-container .el-input input {
|
.login-container .el-input input {
|
||||||
color: $cursor;
|
color: $cursor;
|
||||||
|
@ -141,9 +223,9 @@ $cursor: #fff;
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
$bg:#2d3a4b;
|
$bg: #2d3a4b;
|
||||||
$dark_gray:#889aa4;
|
$dark_gray: #889aa4;
|
||||||
$light_gray:#eee;
|
$light_gray: #eee;
|
||||||
|
|
||||||
.login-container {
|
.login-container {
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
|
|
Loading…
Reference in New Issue