From 909b98ab8d3db4c251bb793106c18e2831d71fec Mon Sep 17 00:00:00 2001 From: aihe <961836564@qq.com> Date: Fri, 10 May 2024 23:33:45 +0800 Subject: [PATCH] uu --- .../tpx-bluetooth-print.vue | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/components/tpx-bluetooth-print/tpx-bluetooth-print.vue b/components/tpx-bluetooth-print/tpx-bluetooth-print.vue index 302d270..a34364d 100644 --- a/components/tpx-bluetooth-print/tpx-bluetooth-print.vue +++ b/components/tpx-bluetooth-print/tpx-bluetooth-print.vue @@ -30,20 +30,17 @@ export default { } }, mounted () { + this.initData() }, unmounted() { }, methods: { + async initData() { + this.pic_res = await this.renderPic(); + }, // 打印-发送二进制数据 async writeBLECharacteristicValue(){ - - let pic_res - try{ - pic_res = await this.renderPic(); - showToast('图片获取成功') - }catch(e){ - showToast('图片获取失败') - } + let pic_res = this.pic_res let printerJobs = new PrinterJobs() printerJobs @@ -134,11 +131,12 @@ export default { src: filePath, success(res) { cxt.drawImage(filePath, 0, 0, that.canvas_width, that.canvas_height); - cxt.draw(); - that.$nextTick(async () => { //获取画布像素数据 - let data = await that.getImageInfo({ canvasId: that.canvasId, width: that.canvas_width, height: that.canvas_height, }) - resolve(data) - }) + cxt.draw(true, ()=> { + setTimeout( async ()=> { + let data = await that.getImageInfo({ canvasId: that.canvasId, width: that.canvas_width, height: that.canvas_height, }) + resolve(data) + }, 1000) + }); }, fail(e) { reject(e)