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