@@ -56,7 +52,7 @@
icon="check"
type="primary"
>确认
-
取消
+
取消
@@ -172,7 +168,6 @@ export default {
form: {},
avatar: {
- key: Date.now(),
cropper: false,
img: '',
autoWidth: 200,
@@ -223,6 +218,10 @@ export default {
return false;
},
+ onAvatarStart() {
+ this.avatar.cropper = true;
+ },
+
onAvatarOk() {
this.avatar.uploading = true;
this.$refs.cropper.getCropBlob(async (data) => {
@@ -233,17 +232,35 @@ export default {
const { data: fileId } = await this.$api.sysFileInfoUpload(fd);
this.form.avatar = fileId;
- this.avatar.cropper = false;
+ this.onAvatarCancel();
} finally {
this.avatar.uploading = false;
}
});
},
+ onAvatarCancel() {
+ this.avatar = {
+ ...this.avatar,
+ ...{
+ cropper: false,
+ img: '',
+ preview: {},
+ file: null,
+ },
+ };
+ },
+
async onSaveInfo() {
this.saving = true;
try {
- await this.$api.sysUserUpdateInfo(this.form);
+ await this.$api.sysUserUpdateInfo({
+ avatar: this.form.avatar,
+ nickName: this.form.nickName,
+ birthday: this.form.birthday,
+ sex: this.form.sex,
+ tel: this.form.tel,
+ });
await this.onRefreshInfo();
this.$message.success('更新个人信息成功');
} finally {