Commit 91888066 by 姜雷

添加修改手机号方法

parent a45e068f
...@@ -485,7 +485,8 @@ export default { ...@@ -485,7 +485,8 @@ export default {
this.updateUserCellphone(entity) this.updateUserCellphone(entity)
.then(res => { .then(res => {
this.resetCellphoneForm(); this.resetCellphoneForm();
console.log(res); this.$message.success(res.msg || '修改成功');
this.cancelCellphoneUpdate();
}) })
.catch(err => { .catch(err => {
console.log(err); console.log(err);
......
import { login, logout, changePwd } from '@/api/user/login'; import { login, logout, changePwd } from '@/api/user/login';
import { getToken, setToken, removeToken } from '@/utils/auth'; import { getToken, setToken, removeToken } from '@/utils/auth';
import { SET_TOKEN, UPDATE_USERINFO } from './mutation-types'; import { SET_TOKEN, UPDATE_USERINFO } from './mutation-types';
import { updateUserinfo, updateUserCellphone } from '@/api/user/update';
import md5 from 'blueimp-md5'; import md5 from 'blueimp-md5';
const state = { const state = {
...@@ -85,6 +86,37 @@ const actions = { ...@@ -85,6 +86,37 @@ const actions = {
dispatch('getAsyncRoute', userRoles); dispatch('getAsyncRoute', userRoles);
}); });
}, },
// 修改资料
updateUserinfo({ commit, dispatch }, { name, newPwd, oldPwd }) {
return updateUserinfo({
data: newPwd
? {
name,
newPwd: md5(newPwd),
oldPwd: md5(oldPwd),
}
: {
name,
},
}).then(res => {
const {
data: { userRoles, userInfo },
} = res;
commit(UPDATE_USERINFO, userInfo);
dispatch('getAsyncRoute', userRoles);
return res;
});
},
// 修改电话
updateUserCellphone({ commit }, entity) {
return updateUserCellphone({
params: entity,
}).then(res => {
console.log(res);
commit(UPDATE_USERINFO, entity);
return res;
});
},
}; };
const mutations = { const mutations = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment