Commit 8aa09097 by liangjianmin

bug

parent 92718ac9
......@@ -23,8 +23,8 @@ import { API } from '@/util/api.js';
export default {
data() {
return {
account: 'admin@ichunt.com',
passwd: '123456789'
account: '',
passwd: ''
};
},
onLoad(options) {},
......
......@@ -219,7 +219,7 @@ export default {
data.push('T 8 0 10 220 仓库代码:' + this.printLabelData[this.print_number].warehouse_code + '\r\n');
data.push('T 8 0 10 260 流水号:' + this.printLabelData[this.print_number].wstyptll_id_sn + '\r\n');
data.push('B QR 280 110 M 2 U 8\r\n');
data.push('MA,' + this.printLabelData[this.print_number]['box_code'] + '|\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');
......
......@@ -64,6 +64,8 @@ export default {
};
},
onLoad(option) {
this.platform = getPlatform();
//停止搜索,节省系统资源
uni.stopBluetoothDevicesDiscovery({
success: res => {
......@@ -187,7 +189,7 @@ export default {
uni.showLoading({
title: '打印中...'
});
console.log('第' + this.print_number + '次打印');
console.log('第' + this.print_number + '次开始打印start...');
let data = [];
if (this.printLabelData.length > 0) {
data.push('! 60 200 200 300 1\r\n');
......@@ -204,15 +206,13 @@ export default {
data.push('T 8 0 10 220 仓库代码:' + this.printLabelData[this.print_number].warehouse_code + '\r\n');
data.push('T 8 0 10 260 流水号:' + this.printLabelData[this.print_number].wstyptll_id_sn + '\r\n');
data.push('B QR 280 110 M 2 U 8\r\n');
data.push('MA,' + this.printLabelData[this.print_number].box_code + '|\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');
}
let arrayBuffer = uni.base64ToArrayBuffer(ToBase64.encode64gb2312(data.join('')));
this.sendData64 = arrayBuffer;
this.writeBLECharacteristicValue();
console.log(data.join(''));
this.cutCommand(data.join(''));
} catch (e) {
uni.hideLoading();
uni.showModal({
......@@ -224,57 +224,78 @@ export default {
}
},
/**
* 分批传输数据
*/
cutCommand: function(data) {
var packageLength = 15; //安卓不超过20个字节传输
var sendData64 = [];
if (this.platform == 'ios') {
packageLength = 40;
}
console.log('package长度:' + packageLength);
for (let i = 0; i < Math.ceil(data.length / packageLength); i++) {
sendData64[i] = uni.base64ToArrayBuffer(ToBase64.encode64gb2312(data.substr(i * packageLength, packageLength)));
}
this.sendData64 = sendData64;
console.log(sendData64);
this.writeBLECharacteristicValue(1);
},
/**
* 写入二进制数据
*/
writeBLECharacteristicValue() {
let that = this;
writeBLECharacteristicValue(times) {
var sendData64 = this.sendData64;
if (sendData64.length >= times) {
uni.writeBLECharacteristicValue({
deviceId: this.deviceId,
serviceId: this.serviceId,
characteristicId: this.characteristics,
value: this.sendData64,
value: sendData64[times - 1],
success: res => {
this.print_number++;
console.log('打印张数:' + this.print_number);
if (this.print_number < this.printLabelData.length) {
this.sendDataChange();
} else {
this.writeBLECharacteristicValue(++times);
},
fail() {
uni.hideLoading();
//清空数据
that.print_number = 0;
that.printLabelData = [];
that.sendData64 = '';
uni.showModal({
title: '提示',
content: '打印成功,请查看标签打印机',
content: '打印失败,请检查打印机',
showCancel: false,
confirmText: '关闭',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
},
fail() {
});
} else {
this.print_number++;
console.log('第' + this.print_number + '次传输完成end');
if (this.print_number < this.printLabelData.length) {
this.sendDataChange();
} else {
uni.hideLoading();
//清空数据
this.print_number = 0;
this.printLabelData = [];
this.sendData64 = '';
uni.showModal({
title: '提示',
content: '打印失败,请检查打印机',
content: '打印成功,请查看标签打印机',
showCancel: false,
confirmText: '关闭',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
});
}
},
change(index, type) {
if (type == 'erp_order_sn_pre') {
......
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