Commit 2523c261 by liangjianmin

js

parent d8926bda
Showing with 51 additions and 32 deletions
...@@ -224,7 +224,7 @@ ...@@ -224,7 +224,7 @@
serviceId: that.serviceId, serviceId: that.serviceId,
success: res => { success: res => {
that.characteristics = res.characteristics[0].uuid; that.characteristics = res.characteristics[0].uuid;
that.sendDataChangeAll(); that.sendDataChange();
console.log('服务功能特征值', res); console.log('服务功能特征值', res);
}, },
fail: res => { fail: res => {
...@@ -252,6 +252,7 @@ ...@@ -252,6 +252,7 @@
data.push("ENDQR\r\n"); data.push("ENDQR\r\n");
h += 210; h += 210;
} }
data.push("FORM\r\n");
data.push("PRINT\r\n"); data.push("PRINT\r\n");
let arrayBuffer = uni.base64ToArrayBuffer(ToBase64.encode64gb2312(data.join(''))); let arrayBuffer = uni.base64ToArrayBuffer(ToBase64.encode64gb2312(data.join('')));
this.sendData64 = arrayBuffer; this.sendData64 = arrayBuffer;
...@@ -261,22 +262,27 @@ ...@@ -261,22 +262,27 @@
sendDataChange() { sendDataChange() {
console.log('第' + this.print_number + '次打印'); console.log('第' + this.print_number + '次打印');
//发送数据 二进制 //发送数据 二进制
let data = ""; let data = [];
if (this.printLabelData.length > 0) { if (this.printLabelData.length > 0) {
data = "! 10 200 200 250 1\r\n" + data.push("! 10 200 200 200 1\r\n");
"T 8 0 10 10 入仓号:" + this.printLabelData[this.print_number].erp_order_sn + "\r\n" + data.push("T 8 0 10 20 入仓号:" + this.printLabelData[this.print_number].erp_order_sn + "\r\n");
"T 8 0 10 50 箱号:" + this.printLabelData[this.print_number].label_sort + '/' + this.printLabelData[0].label_num + "\r\n" + if (this.form.print_type == 1) {
"T 8 0 10 90 时间:" + this.printLabelData[this.print_number].create_time_cn + "\r\n" + data.push("T 8 0 10 70 总箱数:" + this.printLabelData[this.print_number].label_num + "箱\r\n");
"T 8 0 10 130 仓库代码:" + this.print_number + "\r\n" + } else {
"B QR 290 0 M 2 U 8\r\n" + data.push("T 8 0 10 70 箱号:" + this.printLabelData[this.print_number].label_sort + '/' + this.printLabelData[this.print_number].label_num + "\r\n");
"MA," + this.printLabelData[this.print_number].erp_order_sn + "\r\n" + }
"ENDQR\r\n" + data.push("T 8 0 10 120 时间:" + this.printLabelData[this.print_number].create_time_cn + "\r\n");
"PRINT\r\n"; data.push("T 8 0 10 170 仓库代码:" + this.printLabelData[this.print_number].warehouse_code + "\r\n");
data.push("B QR 290 20 M 2 U 8\r\n");
data.push("MA," + this.printLabelData[this.print_number].erp_order_sn + "\r\n");
data.push("ENDQR\r\n");
data.push("FORM\r\n");
data.push("PRINT\r\n");
} }
console.log(data) let arrayBuffer = uni.base64ToArrayBuffer(ToBase64.encode64gb2312(data.join('')));
let arrayBuffer = uni.base64ToArrayBuffer(ToBase64.encode64gb2312(data));
this.sendData64 = arrayBuffer; this.sendData64 = arrayBuffer;
this.writeBLECharacteristicValue(); this.writeBLECharacteristicValue();
console.log(data.join(''))
}, },
writeBLECharacteristicValue() { writeBLECharacteristicValue() {
//写入二进制数据 //写入二进制数据
...@@ -288,26 +294,39 @@ ...@@ -288,26 +294,39 @@
value: that.sendData64, value: that.sendData64,
success(res) { success(res) {
console.log('writeBLECharacteristicValue success', res.errMsg) console.log('writeBLECharacteristicValue success', res.errMsg)
uni.hideLoading(); that.print_number++;
uni.closeBLEConnection({ if (that.print_number < that.printLabelData.length) {
deviceId: that.deviceId, uni.closeBLEConnection({
success(res) { deviceId: that.deviceId,
uni.showModal({ success(res) {
title: '提示', console.log(res)
content: '提交成功,打印中,请查看标签打印机', setTimeout(function() {
showCancel: false, that.openBluetoothAdapter();
confirmText: '关闭', }, 0);
success: function(res) { }
if (res.confirm) { })
console.log('用户点击确定'); } else {
uni.hideLoading();
} else if (res.cancel) { uni.closeBLEConnection({
console.log('用户点击取消'); deviceId: that.deviceId,
} success(res) {
console.log(res)
}
})
uni.showModal({
title: '提示',
content: '提交成功,打印中,请查看标签打印机',
showCancel: false,
confirmText: '关闭',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
} }
}); }
} });
}) }
}, },
fail() { fail() {
uni.hideLoading(); uni.hideLoading();
......
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 sign in to comment