个人信息采用新版API

dev
smallchill 5 years ago
parent f1e28cd893
commit ba5a0fb6de
  1. 15
      src/const/user/info.js
  2. 31
      src/views/system/userinfo.vue

@ -1,9 +1,10 @@
export default {
column: [{
tabs: true,
tabsActive: 1,
group: [
{
label: '个人信息',
prop: 'info',
option: {
submitText: '修改',
column: [{
label: '头像',
type: 'upload',
@ -42,12 +43,10 @@ export default {
span: 12,
row: true,
}]
}
}, {
},
{
label: '修改密码',
prop: 'password',
option: {
submitText: '修改',
column: [{
label: '原密码',
span: 12,
@ -68,5 +67,5 @@ export default {
prop: 'newPassword1'
}]
}
}]
],
}

@ -1,10 +1,10 @@
<template>
<div>
<basic-container>
<avue-tabs :option="option"
<avue-form :option="option"
v-model="form"
@change="handleChange"
@submit="handleSubmit"></avue-tabs>
@tab-click="handleTabClick"
@submit="handleSubmit"></avue-form>
</basic-container>
</div>
</template>
@ -13,12 +13,13 @@
import option from "@/const/user/info";
import {getUserInfo, updateInfo, updatePassword} from "@/api/system/user";
import md5 from 'js-md5';
import func from "@/util/func";
export default {
data() {
return {
type: "info",
index: 0,
option: option,
form: {}
};
@ -27,9 +28,9 @@
this.handleWitch();
},
methods: {
handleSubmit() {
if (this.type === "info") {
updateInfo(this.form).then(res => {
handleSubmit(form, done) {
if (this.index === 0) {
updateInfo(form).then(res => {
if (res.data.success) {
this.$message({
type: "success",
@ -41,9 +42,13 @@
message: res.data.msg
});
}
done();
}, error => {
window.console.log(error);
done();
})
} else {
updatePassword(md5(this.form.oldPassword), md5(this.form.newPassword), md5(this.form.newPassword1)).then(res => {
updatePassword(md5(form.oldPassword), md5(form.newPassword), md5(form.newPassword1)).then(res => {
if (res.data.success) {
this.$message({
type: "success",
@ -55,11 +60,15 @@
message: res.data.msg
});
}
done();
}, error => {
window.console.log(error);
done();
})
}
},
handleWitch() {
if (this.type === "info") {
if (this.index === 0) {
getUserInfo().then(res => {
const user = res.data.data;
this.form = {
@ -73,8 +82,8 @@
});
}
},
handleChange(item) {
this.type = item.prop;
handleTabClick(tabs) {
this.index = func.toInt(tabs.index);
this.handleWitch();
}
}

Loading…
Cancel
Save