tianyi 4 weeks ago
parent
commit
b051102bb3
  1. 18
      components/print/index.js

18
components/print/index.js

@ -23,7 +23,6 @@
'accessToken':uni.getStorageSync('hiver_token')
},
success: function(res) {
console.log('连接成功了!!!!!!!!!!!!',res)
if (res.data.code == 200) {
data1 = res.data.result
that.bindViewTap(id, false, onDone)
@ -39,7 +38,6 @@
uni.hideLoading();
},
fail: function(err) {
console.log(err)
uni.hideLoading();
// 请求失败也需要通知队列继续处理下一条
if (typeof onDone === 'function') onDone();
@ -65,7 +63,6 @@
},
async bindViewTap(deviceId, state, onDone) {
var _this = this;
console.log(deviceId)
try {
//1.链接设备
await bluetooth.createBLEConnection(deviceId).then((res) => {
@ -77,7 +74,7 @@
let server = [];
//2.寻找服务
await bluetooth.getBLEDeviceServices().then((res) => {
console.log(res)
bluetooth.notifyId = '';
bluetooth.writeId = '';
bluetooth.num = 0;
@ -94,8 +91,6 @@
throw e;
});
} catch (e) {
//TODO handle the exception
console.log("e: " + JSON.stringify(e));
// 蓝牙连接异常也需要通知队列继续
if (typeof onDone === 'function') onDone();
}
@ -111,13 +106,10 @@
},
//写入控制命令
async writeBLECharacteristicValue(onDone) {
console.log("走到这里已经拿到数据了",data1)
if(data1.receiverName == null){
console.log("22222")
data1.receiverName = "***"
}
if(data1.receiverAddress == null){
console.log("3333")
data1.receiverAddress = '***'
}
if(data1.deliveryInfo == null){
@ -125,12 +117,11 @@
data1.deliveryInfo = {
mustFinishTime:"***"
}
console.log("111111111")
}
let printerJobs = new PrinterJobs();
printerJobs.setAlign('ct').setSize(2, 2).setLineSpacing(80).print(data1.numberCode + (data1.deliveryType == 1?'配送':'自取'))
printerJobs.setAlign('ct').setSize(2, 2).setLineSpacing(80).print(data1.numberCode + ((data1.status == 7 || data1.status == 11)? '待退款' :data1.deliveryType == 1?'配送':'到店单'))
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print('预计时间:'+ data1.deliveryInfo == null?'暂无':data1.deliveryInfo.mustFinishTime)
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print(data1.shopName)
.print(printerUtil.fillLine('-', 1, 50))
@ -201,7 +192,6 @@
let devices = [];
let list = result.devices;
for (let i = 0; i < list.length; ++i) {
console.log(list[i])
if (list[i].name && list[i].name != "未知设备") {
let arrNew = arr.filter((item) => {
return item.deviceId == list[i].deviceId;
@ -225,9 +215,7 @@
})
}
})
}).catch(e => {
console.log(e)
});
}).catch(e => {});
},
// 停止搜索
stopSearch() {

Loading…
Cancel
Save