|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
<div class="user-info-head" @click="editCropper()">
|
|
|
- <img :src="isImgUrl ? (imgUrlPrefix + options.img) : options.img" title="点击上传头像" class="img-circle img-lg" />
|
|
|
+ <img :src="options.img" title="点击上传头像" class="img-circle img-lg" />
|
|
|
</div>
|
|
|
<el-dialog
|
|
|
:title="title"
|
|
@@ -15,7 +15,7 @@
|
|
|
<el-col :xs="24" :md="12" style="height: 350px;">
|
|
|
<vue-cropper
|
|
|
ref="cropper"
|
|
|
- :img="isImgUrl ? (imgUrlPrefix + options.img) : options.img"
|
|
|
+ :img="options.img"
|
|
|
:info="true"
|
|
|
:autoCrop="options.autoCrop"
|
|
|
:autoCropWidth="options.autoCropWidth"
|
|
@@ -94,7 +94,6 @@ export default {
|
|
|
fixedBox: true // 固定截图框大小 不允许改变
|
|
|
},
|
|
|
previews: {},
|
|
|
- isImgUrl: false,
|
|
|
imgUrlPrefix: `${window.origin}${process.env.VUE_APP_FILE_VIEW_API}`
|
|
|
};
|
|
|
},
|
|
@@ -131,7 +130,6 @@ export default {
|
|
|
const reader = new FileReader();
|
|
|
reader.readAsDataURL(file);
|
|
|
reader.onload = () => {
|
|
|
- this.isImgUrl = false;
|
|
|
this.options.img = reader.result;
|
|
|
};
|
|
|
}
|
|
@@ -143,8 +141,7 @@ export default {
|
|
|
formData.append("avatarfile", data);
|
|
|
uploadAvatar(formData).then(response => {
|
|
|
this.open = false;
|
|
|
- this.isImgUrl = true;
|
|
|
- this.options.img = response.imgUrl;
|
|
|
+ this.options.img = this.imgUrlPrefix + response.imgUrl;
|
|
|
store.commit('SET_AVATAR', this.options.img);
|
|
|
this.msgSuccess("修改成功");
|
|
|
this.visible = false;
|
|
@@ -157,7 +154,6 @@ export default {
|
|
|
},
|
|
|
// 关闭窗口
|
|
|
closeDialog() {
|
|
|
- this.isImgUrl = false;
|
|
|
this.options.img = store.getters.avatar
|
|
|
this.visible = false;
|
|
|
}
|