chenhaozhe
2025-09-28 4fd63776b1abe5c0097f4b4e070e9a4c3a0dc35c
components/labelPrinterComponent/labelPrinterComponent.vue
@@ -73,6 +73,7 @@
            let vm = this;
            let binarys = [];
            for (let command of commandList) {
                    console.log('command: ',command);
               switch (vm.printMode) {
                  case "tspl":
                     let tspl = await vm.$printer.tspl().clear();
@@ -99,21 +100,13 @@
                     })
               }
            }
            let sendSuccess = false
            for(let binary of binarys){
                    try{
                        let sendSuccess = await this.$refs.bt2.sendMessage(binary);
                        console.log("发送是否成功: ", sendSuccess)
                        if(sendSuccess === false) {
                            // 断开蓝牙连接
                            this.$refs.bt2.closeBluetooth()
                           return
                        }else {
                            return uni.showToast({
                                icon: 'none',
                                title: '打印成功'
                            })
                        }
                        sendSuccess = await this.$refs.bt2.sendMessage(binary);
                        console.log("当前发送是否成功: ", sendSuccess)
                    }catch(e) {
                        uni.showToast({
                            icon: 'none',
@@ -126,6 +119,15 @@
                    }
               
            }
                if(sendSuccess === false) {
                   return
                }else {
                    return uni.showToast({
                        icon: 'none',
                        title: '打印成功'
                    })
                }
         },
         async execPrint() {
            // 检查蓝牙连接