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,9 +1,10 @@
|
||||||
<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">
|
||||||
|
@ -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',
|
||||||
|
@ -72,6 +131,27 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
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) {
|
||||||
|
@ -100,7 +180,9 @@ export default {
|
||||||
$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;
|
||||||
|
|
Loading…
Reference in New Issue