个人信息采用新版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 { export default {
column: [{ tabs: true,
tabsActive: 1,
group: [
{
label: '个人信息', label: '个人信息',
prop: 'info', prop: 'info',
option: {
submitText: '修改',
column: [{ column: [{
label: '头像', label: '头像',
type: 'upload', type: 'upload',
@ -42,12 +43,10 @@ export default {
span: 12, span: 12,
row: true, row: true,
}] }]
} },
}, { {
label: '修改密码', label: '修改密码',
prop: 'password', prop: 'password',
option: {
submitText: '修改',
column: [{ column: [{
label: '原密码', label: '原密码',
span: 12, span: 12,
@ -68,5 +67,5 @@ export default {
prop: 'newPassword1' prop: 'newPassword1'
}] }]
} }
}] ],
} }

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

Loading…
Cancel
Save