From ba5a0fb6de8048367cea7e7917cbcc61407703ea Mon Sep 17 00:00:00 2001 From: smallchill Date: Wed, 4 Nov 2020 09:12:30 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E9=87=87=E7=94=A8=E6=96=B0=E7=89=88API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/const/user/info.js | 23 +++++++++++------------ src/views/system/userinfo.vue | 31 ++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/const/user/info.js b/src/const/user/info.js index 18060ff..58077e9 100644 --- a/src/const/user/info.js +++ b/src/const/user/info.js @@ -1,9 +1,10 @@ export default { - column: [{ - label: '个人信息', - prop: 'info', - option: { - submitText: '修改', + tabs: true, + tabsActive: 1, + group: [ + { + label: '个人信息', + prop: 'info', column: [{ label: '头像', type: 'upload', @@ -42,12 +43,10 @@ export default { span: 12, row: true, }] - } - }, { - label: '修改密码', - prop: 'password', - option: { - submitText: '修改', + }, + { + label: '修改密码', + prop: 'password', column: [{ label: '原密码', span: 12, @@ -68,5 +67,5 @@ export default { prop: 'newPassword1' }] } - }] + ], } diff --git a/src/views/system/userinfo.vue b/src/views/system/userinfo.vue index aae42a9..8547ac1 100644 --- a/src/views/system/userinfo.vue +++ b/src/views/system/userinfo.vue @@ -1,10 +1,10 @@ @@ -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(); } }