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