|
|
@ -86,7 +86,8 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
created() { |
|
|
|
this.options.img = this.picHeader + '/' + JSON.parse(localStorage.getItem("userInfo")).avatar |
|
|
|
this.options.img = this.picHeader + '/' + JSON.parse(localStorage.getItem("userInfo")).avatar; |
|
|
|
this.previews.url=this.options.img; |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 重新获取登录信息 |
|
|
@ -109,7 +110,7 @@ export default { |
|
|
|
}, |
|
|
|
// 编辑头像 |
|
|
|
editCropper() { |
|
|
|
this.open = true |
|
|
|
this.open = true; |
|
|
|
}, |
|
|
|
// 覆盖默认的上传行为 |
|
|
|
requestUpload() { |
|
|
@ -129,18 +130,22 @@ export default { |
|
|
|
}, |
|
|
|
// 上传图片 |
|
|
|
uploadImg() { |
|
|
|
var formData = new FormData() |
|
|
|
formData.append('upload', this.newFile) |
|
|
|
put('/admin/base/user/updatepic',formData).then(res => { |
|
|
|
if (res.code === 200) { |
|
|
|
this.open = false |
|
|
|
this.options.img = `${this.picHeader}/${res.data}` |
|
|
|
this.updateHeadPic() |
|
|
|
this.msgSuccess('修改成功') |
|
|
|
} else { |
|
|
|
this.msgError(res.msg) |
|
|
|
} |
|
|
|
}) |
|
|
|
if(cropper.getBlob()){ |
|
|
|
var formData = new FormData(); |
|
|
|
formData.append('upload', cropper.getBlob(), this.newFile.name) |
|
|
|
put('/admin/base/user/updatepic',formData).then(res => { |
|
|
|
if (res.code === 200) { |
|
|
|
this.open = false |
|
|
|
this.options.img = `${this.picHeader}/${res.data}` |
|
|
|
this.updateHeadPic() |
|
|
|
this.msgSuccess('修改成功') |
|
|
|
} else { |
|
|
|
this.msgError(res.msg) |
|
|
|
} |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
this.open = false |
|
|
|
} |
|
|
|
}, |
|
|
|
// 实时预览 |
|
|
|
realTime(data) { |
|
|
@ -155,4 +160,9 @@ export default { |
|
|
|
width: auto; |
|
|
|
} |
|
|
|
} |
|
|
|
.vue--picture-cropper__img{ |
|
|
|
width: 100%; |
|
|
|
height: 100%; |
|
|
|
object-fit: contain; |
|
|
|
} |
|
|
|
</style> |