|
|
@ -79,6 +79,7 @@ const options = reactive({
|
|
|
|
autoCropHeight: 200, // 默认生成截图框高度
|
|
|
|
autoCropHeight: 200, // 默认生成截图框高度
|
|
|
|
fixedBox: true, // 固定截图框大小 不允许改变
|
|
|
|
fixedBox: true, // 固定截图框大小 不允许改变
|
|
|
|
outputType: "png", // 默认生成截图为PNG格式
|
|
|
|
outputType: "png", // 默认生成截图为PNG格式
|
|
|
|
|
|
|
|
filename: 'avatar', // 文件名称
|
|
|
|
previews: {} //预览数据
|
|
|
|
previews: {} //预览数据
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -114,6 +115,7 @@ function beforeUpload(file) {
|
|
|
|
reader.readAsDataURL(file);
|
|
|
|
reader.readAsDataURL(file);
|
|
|
|
reader.onload = () => {
|
|
|
|
reader.onload = () => {
|
|
|
|
options.img = reader.result;
|
|
|
|
options.img = reader.result;
|
|
|
|
|
|
|
|
options.filename = file.name;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -121,7 +123,7 @@ function beforeUpload(file) {
|
|
|
|
function uploadImg() {
|
|
|
|
function uploadImg() {
|
|
|
|
proxy.$refs.cropper.getCropBlob(data => {
|
|
|
|
proxy.$refs.cropper.getCropBlob(data => {
|
|
|
|
let formData = new FormData();
|
|
|
|
let formData = new FormData();
|
|
|
|
formData.append("avatarfile", data);
|
|
|
|
formData.append("avatarfile", data, options.filename);
|
|
|
|
uploadAvatar(formData).then(response => {
|
|
|
|
uploadAvatar(formData).then(response => {
|
|
|
|
open.value = false;
|
|
|
|
open.value = false;
|
|
|
|
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl;
|
|
|
|
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl;
|
|
|
|