diff --git a/public/js/EWebBridge.js b/public/js/EWebBridge.js index 3d77f1175..ca3217e2a 100644 --- a/public/js/EWebBridge.js +++ b/public/js/EWebBridge.js @@ -187,13 +187,14 @@ function appCallBack() {} return window.WVJBCallbacks.push(callback) } window.WVJBCallbacks = [callback] - var WVJBIframe = document.createElement('iframe') + var WVJBIframe = {} + WVJBIframe = document.createElement('iframe') WVJBIframe.style.display = 'none' WVJBIframe.src = 'https://__bridge_loaded__' document.documentElement.appendChild(WVJBIframe) - setTimeout(function() { + // setTimeout(function() { document.documentElement.removeChild(WVJBIframe) - }, 1000) + // }, 100) } } @@ -243,11 +244,10 @@ function appCallBack() {} return triggerCallHandler(method, params) } }) + console.log('z合理',window.WebViewJavascriptBridge); + window.WebViewJavascriptBridge = null })(window) //notation: js file can only use this kind of comments //since comments will cause error when use in webview.loadurl, //comments will be remove by java use regexp -setTimeout(function() { - document.documentElement.removeChild(WVJBIframe) -}, 4000) diff --git a/src/views/ebiz/generateImg/generateImg.vue b/src/views/ebiz/generateImg/generateImg.vue index af466380e..d02cd3171 100644 --- a/src/views/ebiz/generateImg/generateImg.vue +++ b/src/views/ebiz/generateImg/generateImg.vue @@ -164,29 +164,18 @@ export default { // 检查结果,并处理下载逻辑 if (res.result === '0') { console.log(5555); - console.log(res); console.log(res.path); console.log(EWebBridge); - // if (!this.downLoadJin) { - // this.downLoadJin = true; - // 调用原生应用下载接口,并等待其完成 - await EWebBridge.webCallAppInJs('download', { - name: '业绩贺报.png', - url: res.path - }); - console.log('下载完成'); - // } else { - // // this.$toast.fail('已有下载任务在进行,请稍后再试!'); - // } - // 5 秒后重置下载标志 - // setTimeout(() => { - // this.downLoadJin = false; - // }, 5000); - // arr = false - + EWebBridge.webCallAppInJs('download', { + name: '业绩贺报.png', + url: res.path + }).then(() => { + console.log('下载完成') + }).catch(() => { + // this.$toast.fail('图片下载失败,请重新下载!') + }) } canvas = null - console.log('41273854',canvas); } catch (error) { console.log(6666); @@ -198,14 +187,6 @@ export default { // 调用 captureAndProcessImage 函数 captureAndProcessImage(); - EWebBridge.webCallAppInJs('download',{ - name: '', - url: '' - }); - // setTimeout(() => { - // document.documentElement.removeChild(WVJBIframe) - // }, 2500); - setTimeout(() => { this.close() }, 3000); @@ -214,31 +195,15 @@ export default { }, 500); }, - saveImg() { - const content = this.$refs.xingdownLoad // 要下载成图片的dom - if (!content) { - return - } - html2canvas(content, { - scale: 2, // 放大倍数,支持小数,可以控制清晰度 - letterRendering: true, - backgroundColor: '#fff', - height: content.clientHeight, // 要转化为图片下载的dom 高度 - width: content.clientWidth, - }).then((canvas) => { - canvas.toBlob(blob => { - saveAs(blob, `业绩贺报.png`) - }, 'image/png') - this.$toast('下载成功'); - }) + + saveImg(res) { + }, close() { - // this.$refs.xingdownLoad.innerHTML = ''; // 清空内容 - setTimeout(() => { - this.$emit('child-colse', '1') - }, 200); - - + console.log(15434678); + // document.documentElement.removeChild(this.$refs.xingdownLoad) + // this.$refs.xingdownLoad.removeChild(this.$refs.xingdownLoad); + this.$emit('child-colse', '1') } } }