|
|
@ -39,11 +39,27 @@ class ChangeHeaderPicModal extends Component{
|
|
|
|
URL.revokeObjectURL(uploadedImageURL);
|
|
|
|
URL.revokeObjectURL(uploadedImageURL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const image = document.getElementById( imageId );
|
|
|
|
const image = document.getElementById( imageId );
|
|
|
|
image.src = uploadedImageURL = URL.createObjectURL(file);
|
|
|
|
|
|
|
|
that.refs['cropper'].renew(image)
|
|
|
|
// base64
|
|
|
|
// cropper.destroy();
|
|
|
|
var reader = new FileReader();
|
|
|
|
// cropper = new Cropper(image, options);
|
|
|
|
reader.readAsBinaryString(file);
|
|
|
|
inputImage.value = null;
|
|
|
|
|
|
|
|
|
|
|
|
reader.onload = () => {
|
|
|
|
|
|
|
|
let base64_content = btoa(reader.result);
|
|
|
|
|
|
|
|
console.log();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
image.src = `data:${file.type};base64,${base64_content}` // uploadedImageURL = URL.createObjectURL(file);
|
|
|
|
|
|
|
|
that.fileUploaded = true;
|
|
|
|
|
|
|
|
that.refs['cropper'].renew(image)
|
|
|
|
|
|
|
|
// cropper.destroy();
|
|
|
|
|
|
|
|
// cropper = new Cropper(image, options);
|
|
|
|
|
|
|
|
inputImage.value = null;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
reader.onerror = function() {
|
|
|
|
|
|
|
|
console.log('there are some problems');
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.props.showNotification && this.props.showNotification("请选择一个图片格式的文件")
|
|
|
|
this.props.showNotification && this.props.showNotification("请选择一个图片格式的文件")
|
|
|
|
// window.alert('Please choose an image file.');
|
|
|
|
// window.alert('Please choose an image file.');
|
|
|
@ -57,6 +73,8 @@ class ChangeHeaderPicModal extends Component{
|
|
|
|
|
|
|
|
|
|
|
|
this.refs['modalWrapper'].setVisible(visible)
|
|
|
|
this.refs['modalWrapper'].setVisible(visible)
|
|
|
|
if (visible) {
|
|
|
|
if (visible) {
|
|
|
|
|
|
|
|
this.fileUploaded = false;
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.init()
|
|
|
|
this.init()
|
|
|
|
}, 500)
|
|
|
|
}, 500)
|
|
|
@ -69,7 +87,12 @@ class ChangeHeaderPicModal extends Component{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onOk = () => {
|
|
|
|
onOk = () => {
|
|
|
|
|
|
|
|
if (this.fileUploaded != true) {
|
|
|
|
|
|
|
|
this.props.showNotification("请先上传图片")
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
var img_lg = document.getElementById(previewId);
|
|
|
|
var img_lg = document.getElementById(previewId);
|
|
|
|
|
|
|
|
// https://github.com/niklasvh/html2canvas/issues/1908
|
|
|
|
// 截图小的显示框内的内容
|
|
|
|
// 截图小的显示框内的内容
|
|
|
|
window.html2canvas(img_lg).then((canvas) => {
|
|
|
|
window.html2canvas(img_lg).then((canvas) => {
|
|
|
|
var dataUrl = canvas.toDataURL("image/jpeg");
|
|
|
|
var dataUrl = canvas.toDataURL("image/jpeg");
|
|
|
|