diff --git a/src/views/ebiz/generateImg/generateImg.vue b/src/views/ebiz/generateImg/generateImg.vue index b2de905e9..8b7c49320 100644 --- a/src/views/ebiz/generateImg/generateImg.vue +++ b/src/views/ebiz/generateImg/generateImg.vue @@ -77,37 +77,33 @@ export default { }, // 分享 fenxiang() { - if(this.$refs.xingdownLoad != this.$refs.xingdownLoad) { - return - } // const element = document.getElementById('capture') // const canvas = await html2canvas(element) - html2canvas(this.$refs.xingdownLoad, { - width: this.$refs.xingdownLoad.offsetWidth, - height: this.$refs.xingdownLoad.offsetHeight, - backgroundColor: '#fff', - scale: 2, - dpi: 300 - }).then((canvas) => { - console.log('分享'); - // 将 canvas 转换为 Blob - canvas.toBlob((blob) => { - this.blobToBase64(blob).then((base64String) => { - let base64Manane = base64String.split(',')[1] - console.log(base64Manane); - EWebBridge.webCallAppInJs('bridge', { - flag: 'share', - extra: { - shareType: '1', - base64: base64Manane - } - }) + html2canvas(this.$refs.xingdownLoad, { + width: this.$refs.xingdownLoad.offsetWidth, + height: this.$refs.xingdownLoad.offsetHeight, + backgroundColor: '#fff', + scale: 2, + dpi: 300, + useCORS: true, + allowTaint: true, + }).then((canvas) => { + console.log('分享'); + // 将 canvas 转换为 Blob + canvas.toBlob((blob) => { + this.blobToBase64(blob).then((base64String) => { + let base64Manane = base64String.split(',')[1] + console.log(base64Manane); + EWebBridge.webCallAppInJs('bridge', { + flag: 'share', + extra: { + shareType: '1', + base64: base64Manane + } }) - }, 'image/png') - }) - setTimeout(() => { - this.close() - }, 3000); + }) + }, 'image/png') + }) }, // 生成图片并下载 domToImage() { @@ -125,7 +121,9 @@ export default { height: domElement.offsetHeight, backgroundColor: '#fff', scale: 1, - dpi: 300 + dpi: 300, + useCORS: true, + allowTaint: true, }); console.log('下载',canvas); // 将画布转换为 Blob,并等待其完成 @@ -167,8 +165,6 @@ export default { close() { console.log(15434678); - // document.documentElement.removeChild(this.$refs.xingdownLoad) - // this.$refs.xingdownLoad.removeChild(this.$refs.xingdownLoad); document.getElementById('capture').innerHTML = ''; this.$emit('child-colse', '1') },