uu
This commit is contained in:
parent
d49298e395
commit
4fc797c552
@ -133,13 +133,13 @@ export default {
|
||||
this.canvasWidth = w
|
||||
this.canvasHeight = h
|
||||
// 在canvas 画一张图片
|
||||
// ctx.fillStyle = 'rgba(255,255,255,1)';
|
||||
ctx.clearRect(0, 0, w, h);
|
||||
ctx.fillRect(0, 0, w, h);
|
||||
|
||||
let imgRect = canvasUtil.containImg(0, 0, w, h, res.width, res.height)
|
||||
let ctData = [imgRect.dx, imgRect.dy, imgRect.dWidth, imgRect.dHeight]
|
||||
ctx.fillStyle = 'rgba(255,255,255,1)';
|
||||
ctx.clearRect(...ctData);
|
||||
ctx.fillRect(...ctData);
|
||||
// 把原图缩放到 打印宽度的比例 绘制
|
||||
ctx.drawImage(filePath, imgRect.dx, imgRect.dy, imgRect.dWidth, imgRect.dHeight);
|
||||
ctx.drawImage(filePath, ...ctData);
|
||||
|
||||
ctx.draw(false, () => {
|
||||
setTimeout( async ()=> {
|
||||
|
||||
@ -155,6 +155,7 @@ export default {
|
||||
},
|
||||
unmounted() {
|
||||
this.stopDiscoveryPrinter()
|
||||
this.closeBluetoothAdapter()
|
||||
},
|
||||
methods: {
|
||||
changeTab(type) {
|
||||
@ -202,7 +203,12 @@ export default {
|
||||
// 停止搜寻附近的蓝牙外围设备
|
||||
async stopDiscoveryPrinter () {
|
||||
this.searchLoading = false
|
||||
uni.stopBluetoothDevicesDiscovery()
|
||||
uni?.stopBluetoothDevicesDiscovery?.()
|
||||
},
|
||||
// 断开蓝牙
|
||||
async closeBluetoothAdapter () {
|
||||
this.searchLoading = false
|
||||
uni?.closeBluetoothAdapter?.()
|
||||
},
|
||||
async handleSelectDeviceId (item) {
|
||||
this.deviceId = item.deviceId
|
||||
|
||||
Loading…
Reference in New Issue
Block a user