mirror of
https://gitee.com/ssssssss-team/magic-boot.git
synced 2026-05-15 00:00:02 +08:00
个人中心,data挪目录
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
</i>
|
||||
</el-upload>
|
||||
</vuedraggable>
|
||||
<mb-dialog :visible.sync="cropperDialogVisible" @confirm-click="cropper">
|
||||
<mb-dialog ref="cropperDialog" @confirm-click="cropper">
|
||||
<template #content>
|
||||
<div class="cropper-content">
|
||||
<div class="cropper" style="text-align:center">
|
||||
@@ -128,7 +128,6 @@ export default {
|
||||
disabled: false,
|
||||
isUploading: false,
|
||||
cropperOption: {},
|
||||
cropperDialogVisible: false,
|
||||
urls: [],
|
||||
fileList: []
|
||||
}
|
||||
@@ -221,7 +220,7 @@ export default {
|
||||
beforeCropper(url) {
|
||||
this.cropperOption.img = this.$filePrefix + url
|
||||
this.cropperOption.relativeImg = url
|
||||
this.cropperDialogVisible = true
|
||||
this.$refs.cropperDialog.show()
|
||||
},
|
||||
cropper() {
|
||||
this.$refs.cropper.getCropBlob((data) => {
|
||||
@@ -237,7 +236,7 @@ export default {
|
||||
this.urls.forEach((it, i) => {
|
||||
if (this.cropperOption.img.indexOf(it) !== -1) {
|
||||
this.$set(this.urls, i, res.data.url)
|
||||
this.cropperDialogVisible = false
|
||||
this.$refs.cropperDialog.hide()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
<router-link to="/">
|
||||
<el-dropdown-item>首页</el-dropdown-item>
|
||||
</router-link>
|
||||
<router-link to="/user-center">
|
||||
<el-dropdown-item>个人中心</el-dropdown-item>
|
||||
</router-link>
|
||||
<el-dropdown-item divided @click.native="logout">
|
||||
<span style="display:block;">退出</span>
|
||||
</el-dropdown-item>
|
||||
|
||||
@@ -18,6 +18,7 @@ export const constantRoutes = [
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
path: '/',
|
||||
component: Layout,
|
||||
@@ -30,6 +31,19 @@ export const constantRoutes = [
|
||||
}]
|
||||
},
|
||||
|
||||
{
|
||||
path: '/user-center',
|
||||
redirect: '/system/user/user-center',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [{
|
||||
path: '/system/user/user-center',
|
||||
name: '个人中心',
|
||||
component: () => import('@/views/system/user/user-center'),
|
||||
meta: { title: '个人中心' }
|
||||
}]
|
||||
},
|
||||
|
||||
{
|
||||
path: '/login',
|
||||
component: () => import('@/views/login/index'),
|
||||
|
||||
@@ -124,11 +124,13 @@ common.uuid = () => {
|
||||
return uuidv4().replace(/-/g, '')
|
||||
}
|
||||
|
||||
common.objAssign = (obj1, obj2) => {
|
||||
common.objAssign = (obj1, obj2, exclude) => {
|
||||
for (var o1 in obj1) {
|
||||
for (var o2 in obj2) {
|
||||
if (o1 === o2) {
|
||||
obj1[o1] = obj2[o2]
|
||||
if(exclude.indexOf(o1) == -1){
|
||||
obj1[o1] = obj2[o2]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ const getters = {
|
||||
avatar: state => state.user.avatar,
|
||||
name: state => state.user.name,
|
||||
username: state => state.user.username,
|
||||
userInfo: state => state.user.info,
|
||||
roles: state => state.user.roles,
|
||||
permission_routes: state => state.permission.routes,
|
||||
errorLogs: state => state.errorLog.logs
|
||||
|
||||
@@ -25,6 +25,9 @@ const mutations = {
|
||||
},
|
||||
SET_USERNAME: (state, username) => {
|
||||
state.username = username
|
||||
},
|
||||
SET_INFO: (state, info) => {
|
||||
state.info = info
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +60,7 @@ const actions = {
|
||||
authorities_.push(data.authorities[i])
|
||||
}
|
||||
Vue.prototype.$authorities = authorities_
|
||||
commit('SET_INFO', data)
|
||||
commit('SET_NAME', data.name)
|
||||
commit('SET_USERNAME', data.username)
|
||||
resolve()
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form ref="dataForm" :rules="rules" :model="temp" label-position="right" label-width="80px" style="width: 800px">
|
||||
<el-form-item label="头像" prop="headPortrait">
|
||||
<mb-upload-image v-model="temp.headPortrait" />
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名/昵称" prop="name">
|
||||
<el-input v-model="temp.name" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model.integer="temp.phone" maxlength="11" autocomplete="new-password" />
|
||||
</el-form-item>
|
||||
<el-form-item label="原密码" prop="password">
|
||||
<el-input v-model="temp.password" type="password" autocomplete="new-password" />
|
||||
</el-form-item>
|
||||
<el-form-item label="新密码" prop="newPassword">
|
||||
<el-input v-model="temp.newPassword" type="password" autocomplete="new-password" />
|
||||
</el-form-item>
|
||||
<el-form-item label="确认密码" prop="confirmPassword">
|
||||
<el-input v-model="temp.confirmPassword" type="password" autocomplete="new-password" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button class="filter-item" type="primary" @click="save">
|
||||
提交
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'UserCenter',
|
||||
data() {
|
||||
var validatePass2 = (rule, value, callback) => {
|
||||
if(this.temp.newPassword){
|
||||
if (value === '') {
|
||||
callback(new Error('请再次输入密码'));
|
||||
} else if (value !== this.temp.newPassword) {
|
||||
callback(new Error('两次输入密码不一致!'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}else{
|
||||
callback();
|
||||
}
|
||||
}
|
||||
return {
|
||||
rules: {
|
||||
password: [{ required: true, message: '请输入原密码', trigger: 'change' }, { min: 6, message: '密码不少于6位' }],
|
||||
phone: [{ min: 11, message: '请输入11位手机号', trigger: 'change' }],
|
||||
newPassword: [{ min: 6, message: '密码不少于6位' }],
|
||||
confirmPassword: [{ min: 6, message: '密码不少于6位' }, { validator: validatePass2 }],
|
||||
},
|
||||
temp: this.getTemp()
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$common.objAssign(this.temp, this.$store.getters.userInfo, ['password'])
|
||||
},
|
||||
methods: {
|
||||
getTemp() {
|
||||
return {
|
||||
id: '',
|
||||
name: '',
|
||||
password: '',
|
||||
phone: '',
|
||||
headPortrait: '',
|
||||
newPassword: '',
|
||||
confirmPassword: ''
|
||||
}
|
||||
},
|
||||
resetTemp() {
|
||||
this.temp = this.getTemp()
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
save() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.$request({
|
||||
url: 'user/center/update',
|
||||
method: 'post',
|
||||
params: this.temp
|
||||
}).then((response) => {
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '修改成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user