Commit 55eea5b0 authored by 沈翠玲's avatar 沈翠玲

测试蓝牙打印

parent e06cf83d
...@@ -134,49 +134,21 @@ module.exports = { ...@@ -134,49 +134,21 @@ module.exports = {
this.$u.toast('请绑定打印机'); this.$u.toast('请绑定打印机');
return; return;
} }
await CTPL.init(); if (this.vuex_printConnect) {
await CTPL.discovery( (res) => { this.$u.api.getPrintDown(params).then((res) => {
if (res.name === 'CT-428D') { if (res.code === 200) {
getApp().globalData.printSocket.emit('news', {
this.device = res client: null,
console.log(this.device) printer: this.vuex_printerInfo.printerName,
type: 'url_pdf',
// pdf_path: 'http://192.168.3.91:8082/static/123.pdf',
pdf_path: res.fileUrl,
});
} }
}); });
const $this = this } else {
setTimeout(()=>{ this.$u.toast('打印机连接失败');
CTPL.connect(
$this.device,
function success(res1) {
console.log('扫描到的打印机',res1)
CTPL.setSize($this.pageObj.width, $this.pageObj.height)
CTPL.clearCache()
$this.getImageData((response)=>{
console.log('response', response)
const imageRes = response
// CTPL.drawBitMap(
// 0,
// 0,
// imageRes.width,
// imageRes.height,
// 0,
// response.data
// )
// CTPL.setPrintCopies(1, 1)
// CTPL.execute((res) => {
// console.log('res', res)
// })
})
},
function fail(e) {
console.log('报错',e)
} }
)
uni.onBLEConnectionStateChange(function (res) {
console.log('sadsada', res)
})
}, 6000)
return
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment