update 退出登录/修改密码
This commit is contained in:
parent
33a83027aa
commit
d8c6a24290
@ -5,6 +5,16 @@ export const apiLogin = data => {
|
||||
return http({ url: '/renren-fast-server/sys/login', method: 'post', data })
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
export const apiLogout = data => {
|
||||
return http({ url: '/renren-fast-server/sys/logout', method: 'post', data })
|
||||
}
|
||||
|
||||
// 修改密码
|
||||
export const apiSysUserPassword = data => {
|
||||
return http({ url: '/renren-fast-server/sys/user/password', method: 'post', data })
|
||||
}
|
||||
|
||||
// 获取用户相关
|
||||
export const apiGetUserInfo = (params, id) => {
|
||||
return http({ url: `/renren-fast-server/sys/user/info${id}`, method: 'get', params })
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// 站点主色
|
||||
// tips: 要达到整站主题修改效果, 请确保[$--color-primary]站点主色与[/src/element-ui-theme/index.js]文件中[import './element-[#17B3A3]/index.css']当前主题色一致
|
||||
$--color-primary: #17B3A3;
|
||||
$--color-primary: #3E8EF7;
|
||||
|
||||
// Navbar
|
||||
$navbar--background-color: $--color-primary;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* 1. 此处只包含element-ui组件主题
|
||||
* 2. 要达到整站主题修改效果, 请确保[import './element-[#17B3A3]/index.css']当前主题色与[/src/assets/scss/_variables.scss]文件中[$--color-primary]属性值一致
|
||||
*/
|
||||
import './element-#17B3A3/index.css' // 当前主题色
|
||||
import './element-#3E8EF7/index.css' // 当前主题色
|
||||
export default {
|
||||
list: [
|
||||
'#0BB2D4', // 青色
|
||||
|
||||
@ -107,9 +107,11 @@ function fnAddDynamicMenuRoutes (menuList = [], routes = []) {
|
||||
} else if (menuList[i].url && /\S/.test(menuList[i].url)) {
|
||||
menuList[i].url = menuList[i].url.replace(/^\//, '')
|
||||
var route = {
|
||||
path: menuList[i].url.replace('/', '-'),
|
||||
// path: menuList[i].url.replace('/', '-'),
|
||||
path: menuList[i].url,
|
||||
component: null,
|
||||
name: menuList[i].url.replace('/', '-'),
|
||||
// name: menuList[i].url.replace('/', '-'),
|
||||
name: menuList[i].url,
|
||||
meta: {
|
||||
menuId: menuList[i].menuId,
|
||||
title: menuList[i].name,
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<!-- <p class="brand-info__intro">renren-fast-vue基于vue、element-ui构建开发,实现renren-fast后台管理前端功能,提供一套更优的前端解决方案。</p> -->
|
||||
</div>
|
||||
<div class="login-main">
|
||||
<h3 class="login-title">管理员登录</h3>
|
||||
<h3 class="login-title">用户登录</h3>
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="handleLogin()" status-icon>
|
||||
<el-form-item prop="username">
|
||||
<el-input v-model="dataForm.username" placeholder="帐号"></el-input>
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="修改密码"
|
||||
:visible.sync="visible"
|
||||
:visible.sync="dialogVisible"
|
||||
:append-to-body="true">
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="handleSubmit()" label-width="80px">
|
||||
<el-form-item label="账号">
|
||||
<span>{{ userName }}</span>
|
||||
</el-form-item>
|
||||
@ -18,14 +18,16 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit()">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { clearLoginInfo } from '@/utils'
|
||||
import { apiSysUserPassword } from '@/api/api_user'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
var validateConfirmPassword = (rule, value, callback) => {
|
||||
@ -36,19 +38,15 @@
|
||||
}
|
||||
}
|
||||
return {
|
||||
visible: false,
|
||||
dialogVisible: false,
|
||||
dataForm: {
|
||||
password: '',
|
||||
newPassword: '',
|
||||
confirmPassword: ''
|
||||
},
|
||||
dataRule: {
|
||||
password: [
|
||||
{ required: true, message: '原密码不能为空', trigger: 'blur' }
|
||||
],
|
||||
newPassword: [
|
||||
{ required: true, message: '新密码不能为空', trigger: 'blur' }
|
||||
],
|
||||
password: [{ required: true, message: '原密码不能为空', trigger: 'blur' }],
|
||||
newPassword: [{ required: true, message: '新密码不能为空', trigger: 'blur' }],
|
||||
confirmPassword: [
|
||||
{ required: true, message: '确认密码不能为空', trigger: 'blur' },
|
||||
{ validator: validateConfirmPassword, trigger: 'blur' }
|
||||
@ -68,30 +66,26 @@
|
||||
methods: {
|
||||
// 初始化
|
||||
init () {
|
||||
this.visible = true
|
||||
this.dialogVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit () {
|
||||
handleSubmit () {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/sys/user/password'),
|
||||
method: 'post',
|
||||
data: this.$http.adornData({
|
||||
'password': this.dataForm.password,
|
||||
'newPassword': this.dataForm.newPassword
|
||||
})
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
apiSysUserPassword({
|
||||
'password': this.dataForm.password,
|
||||
'newPassword': this.dataForm.newPassword
|
||||
}).then(res => {
|
||||
if (res && res.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.dialogVisible = false
|
||||
this.$nextTick(() => {
|
||||
this.mainTabs = []
|
||||
clearLoginInfo()
|
||||
@ -100,7 +94,7 @@
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.error(data.msg)
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -41,8 +41,8 @@
|
||||
<img src="~@/assets/img/login/avatar.png" :alt="userName">{{ userName }}
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item @click.native="updatePasswordHandle()">修改密码</el-dropdown-item>
|
||||
<el-dropdown-item @click.native="logoutHandle()">退出</el-dropdown-item>
|
||||
<el-dropdown-item @click.native="handleUpdatePassword()">修改密码</el-dropdown-item>
|
||||
<el-dropdown-item @click.native="handleLogout()">退出</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</el-menu-item>
|
||||
@ -56,6 +56,8 @@
|
||||
<script>
|
||||
import UpdatePassword from './main-navbar-update-password'
|
||||
import { clearLoginInfo } from '@/utils'
|
||||
import { apiLogout } from '@/api/api_user'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
@ -83,25 +85,21 @@
|
||||
},
|
||||
methods: {
|
||||
// 修改密码
|
||||
updatePasswordHandle () {
|
||||
handleUpdatePassword () {
|
||||
this.updatePassowrdVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.updatePassowrd.init()
|
||||
})
|
||||
},
|
||||
// 退出
|
||||
logoutHandle () {
|
||||
// 退出登录
|
||||
handleLogout () {
|
||||
this.$confirm(`确定进行[退出]操作?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/sys/logout'),
|
||||
method: 'post',
|
||||
data: this.$http.adornData()
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
apiLogout({}).then(res => {
|
||||
if (res && res.code === 0) {
|
||||
clearLoginInfo()
|
||||
this.$router.push({ name: 'login' })
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user