Merge branch 'Dev' of http://101.37.171.70:10101/r/~jhz/STUWMS into Dev
| | |
| | | "LcPrinter" : { |
| | | "__plugin_info__" : { |
| | | "name" : "LcPrinter", |
| | | "description" : "新版打印插件", |
| | | "description" : "打印插件", |
| | | "platforms" : "Android", |
| | | "url" : "", |
| | | "android_package_name" : "", |
| | |
| | | <button type="default" :class="cantPrint ? 'btn-disabled' : 'btn-c'" @click="PrintHBarCode" |
| | | :disabled="cantPrint">打印</button> |
| | | <button type="primary" @click="printerLabel">测试打印</button> |
| | | <button type="primary" @click="printTest">回纸距离</button> |
| | | </view> |
| | | </view> |
| | | <view class="divide"></view> |
| | |
| | | }; |
| | | }, |
| | | methods: { |
| | | |
| | | //打印机初始化 |
| | | initPrinter() { |
| | | // 调用异步方法 |
| | | console.log('新版初始化'); |
| | | var ret = printer.initPrinter({}); |
| | | console.log('初始化'); |
| | | var ret = printer.initPrinter({ |
| | | name: 'unimp', |
| | | age: 1 |
| | | }); |
| | | modal.toast({ |
| | | message: ret, |
| | | duration: 1.5 |
| | |
| | | printer.setConcentration({ //设置打印浓度。font_level 取值范围:1~39。 |
| | | level: 39 |
| | | }); |
| | | printer.setLineSpacing({ |
| | | spacing: 1 |
| | | }); |
| | | //add by ljh |
| | | printer.setFontSize({ |
| | | fontSize: 8 |
| | | }); |
| | | //add end |
| | | printer.getsupportprint(); |
| | | |
| | | }, |
| | | printTest() { |
| | | printer.printEnableMark({enable: false}); |
| | | console.log('测试回纸距离'); |
| | | printer.printBarcode({ |
| | | text: 1234567890123456789, |
| | | height: 80, |
| | | barcodeType: 73 |
| | | }); |
| | | printer.setFeedPaperSpace({ space: 1000}); |
| | | printer.setUnwindPaperLen({ length: 60 }); |
| | | printer.printLine({ |
| | | line_length: 5 |
| | | }); |
| | | |
| | | printer.printGoToNextMark();//标签打印使用,开始走纸 |
| | | //printer.start();//热敏打印使用,开始走纸 |
| | | }, |
| | | printerLabel(item) { |
| | | console.log('测试打印'); |
| | | |
| | | printer.setLineSpacing({ |
| | | spacing: 1.2 |
| | | }); |
| | | |
| | | printer.setUnwindPaperLen({ length: 60 }); |
| | | printer.setFontSize({ |
| | | fontSize: 1 |
| | |
| | | isUnderLine: false, |
| | | content: '物料简称:12SH 出风网 注塑灰011(同GE灰)\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize:2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '物料名称:12SH 出风网 注塑灰011(同GE灰)\r\n' |
| | | }); |
| | | // printer.printText2({ |
| | | // offset: 1, |
| | | // fontSize:2, |
| | | // isBold: false, |
| | | // isUnderLine: false, |
| | | // content: '物料名称:12SH 出风网 注塑灰011(同GE灰)\r\n' |
| | | // }); |
| | | |
| | | printer.printText2({ |
| | | offset: 1, |
| | |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '工号:000001\r\n' |
| | | content: '流水号:000001\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '打印日期:2025-8-13\r\n' |
| | | }); |
| | | printer.printQR2({ |
| | | text: 'title', |
| | | height: 100, |
| | | height: 120, |
| | | offset: 3 |
| | | }); |
| | | |
| | | printer.printLine({ |
| | | line_length: 5 |
| | | }); |
| | | printer.printGoToNextMark(); |
| | | |
| | | console.log('测试打印QR结束'); |
| | |
| | | this.resetButtonState(); |
| | | // 添加打印状态监听 |
| | | if(!isPrinterInitialized){ |
| | | const self = this; |
| | | globalEvent.addEventListener('onPrintCallback', function(e) { |
| | | uni.showToast({ |
| | | title: 'state: ' + JSON.stringify(e), |
| | |
| | | duration: 2000 |
| | | }); |
| | | //成功后设置状态 |
| | | this.isPrinting = false; |
| | | self.isPrinting = false; |
| | | //this.resetButtonState(); |
| | | } else if (e.key == 3) { |
| | | this.isPrinting = false; |
| | | self.isPrinting = false; |
| | | uni.showToast({ |
| | | title: '缺纸', |
| | | duration: 2000 |
| | |
| | | }, |
| | | onReady() { |
| | | |
| | | }, |
| | | onUnload() { |
| | | // 调用同步方法 |
| | | |
| | | } |
| | | } |
| | | </script> |