更换贺报下载的方法25

This commit is contained in:
xuxingjun
2024-12-30 16:18:44 +08:00
parent a3a1b50e1a
commit e82d9823be
2 changed files with 21 additions and 56 deletions

View File

@@ -187,13 +187,14 @@ function appCallBack() {}
return window.WVJBCallbacks.push(callback) return window.WVJBCallbacks.push(callback)
} }
window.WVJBCallbacks = [callback] window.WVJBCallbacks = [callback]
var WVJBIframe = document.createElement('iframe') var WVJBIframe = {}
WVJBIframe = document.createElement('iframe')
WVJBIframe.style.display = 'none' WVJBIframe.style.display = 'none'
WVJBIframe.src = 'https://__bridge_loaded__' WVJBIframe.src = 'https://__bridge_loaded__'
document.documentElement.appendChild(WVJBIframe) document.documentElement.appendChild(WVJBIframe)
setTimeout(function() { // setTimeout(function() {
document.documentElement.removeChild(WVJBIframe) document.documentElement.removeChild(WVJBIframe)
}, 1000) // }, 100)
} }
} }
@@ -243,11 +244,10 @@ function appCallBack() {}
return triggerCallHandler(method, params) return triggerCallHandler(method, params)
} }
}) })
console.log('z合理',window.WebViewJavascriptBridge);
window.WebViewJavascriptBridge = null
})(window) })(window)
//notation: js file can only use this kind of comments //notation: js file can only use this kind of comments
//since comments will cause error when use in webview.loadurl, //since comments will cause error when use in webview.loadurl,
//comments will be remove by java use regexp //comments will be remove by java use regexp
setTimeout(function() {
document.documentElement.removeChild(WVJBIframe)
}, 4000)

View File

@@ -164,29 +164,18 @@ export default {
// 检查结果,并处理下载逻辑 // 检查结果,并处理下载逻辑
if (res.result === '0') { if (res.result === '0') {
console.log(5555); console.log(5555);
console.log(res);
console.log(res.path); console.log(res.path);
console.log(EWebBridge); console.log(EWebBridge);
// if (!this.downLoadJin) { EWebBridge.webCallAppInJs('download', {
// this.downLoadJin = true; name: '业绩贺报.png',
// 调用原生应用下载接口,并等待其完成 url: res.path
await EWebBridge.webCallAppInJs('download', { }).then(() => {
name: '业绩贺报.png', console.log('下载完成')
url: res.path }).catch(() => {
}); // this.$toast.fail('图片下载失败,请重新下载!')
console.log('下载完成'); })
// } else {
// // this.$toast.fail('已有下载任务在进行,请稍后再试!');
// }
// 5 秒后重置下载标志
// setTimeout(() => {
// this.downLoadJin = false;
// }, 5000);
// arr = false
} }
canvas = null canvas = null
console.log('41273854',canvas);
} catch (error) { } catch (error) {
console.log(6666); console.log(6666);
@@ -198,14 +187,6 @@ export default {
// 调用 captureAndProcessImage 函数 // 调用 captureAndProcessImage 函数
captureAndProcessImage(); captureAndProcessImage();
EWebBridge.webCallAppInJs('download',{
name: '',
url: ''
});
// setTimeout(() => {
// document.documentElement.removeChild(WVJBIframe)
// }, 2500);
setTimeout(() => { setTimeout(() => {
this.close() this.close()
}, 3000); }, 3000);
@@ -214,31 +195,15 @@ export default {
}, 500); }, 500);
}, },
saveImg() {
const content = this.$refs.xingdownLoad // 要下载成图片的dom saveImg(res) {
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('下载成功');
})
}, },
close() { close() {
// this.$refs.xingdownLoad.innerHTML = ''; // 清空内容 console.log(15434678);
setTimeout(() => { // document.documentElement.removeChild(this.$refs.xingdownLoad)
this.$emit('child-colse', '1') // this.$refs.xingdownLoad.removeChild(this.$refs.xingdownLoad);
}, 200); this.$emit('child-colse', '1')
} }
} }
} }