|
@@ -10,6 +10,7 @@
|
|
|
<view style='margin-top:4%;display: flex;flex-direction: column;'>
|
|
|
<button type='primary' class="btn" @tap='receiptTest' :loading='isReceiptSend'
|
|
|
:disabled='isReceiptSend'>打印质检单小票</button>
|
|
|
+ <button type='primary' class="btn" @tap='clearBlue'>重新连接蓝牙</button>
|
|
|
<button type='primary' class="btn" @tap='goToList'>返回列表页</button>
|
|
|
<!-- <button type='primary' @tap='labelTest' :loading='isLabelSend' :disabled='isLabelSend'>标签测试</button> -->
|
|
|
</view>
|
|
@@ -159,10 +160,10 @@
|
|
|
methods: {
|
|
|
|
|
|
clearBlue() {
|
|
|
-
|
|
|
+
|
|
|
let tmp = this.Bluetooth;
|
|
|
uni.closeBLEConnection({
|
|
|
- deviceId:tmp.BLEInformation.deviceId
|
|
|
+ deviceId: tmp.BLEInformation.deviceId
|
|
|
})
|
|
|
tmp.BLEInformation.deviceId = ''
|
|
|
this.$store.commit('BLEInformationSet', tmp);
|
|
@@ -171,7 +172,7 @@
|
|
|
// icon: 'none'
|
|
|
// })
|
|
|
uni.navigateBack({
|
|
|
- delta:1
|
|
|
+ delta: 1
|
|
|
})
|
|
|
},
|
|
|
goToList() {
|
|
@@ -346,6 +347,7 @@
|
|
|
if (that.gridList.type == '潮粮') {
|
|
|
command.setText("单价(元/公斤):" + that.gridList.tidalGrainPrice);
|
|
|
} else {
|
|
|
+ command.setText("单价(元/公斤):" + that.gridList.dryGrainPrice);
|
|
|
}
|
|
|
command.setPrint();
|
|
|
//杂质
|
|
@@ -400,15 +402,24 @@
|
|
|
//准备发送,根据每次发送字节数来处理分包数量
|
|
|
prepareSend(buff) {
|
|
|
console.log(buff);
|
|
|
- let that = this
|
|
|
- let time = that.oneTimeData
|
|
|
- let looptime = parseInt(buff.length / time);
|
|
|
- let lastData = parseInt(buff.length % time);
|
|
|
- console.log(looptime + "---" + lastData)
|
|
|
- this.looptime = looptime + 1;
|
|
|
- this.lastData = lastData;
|
|
|
- this.currentTime = 1;
|
|
|
- that.Send(buff)
|
|
|
+ // let that = this
|
|
|
+ // let time = that.oneTimeData
|
|
|
+ // let looptime = parseInt(buff.length / time);
|
|
|
+ // let lastData = parseInt(buff.length % time);
|
|
|
+ // console.log(looptime + "---" + lastData)
|
|
|
+ // this.looptime = looptime + 1;
|
|
|
+ // this.lastData = lastData;
|
|
|
+ // this.currentTime = 1;
|
|
|
+ // that.Send(buff)
|
|
|
+ var that = this;
|
|
|
+ var time = that.oneTimeData;
|
|
|
+ var looptime = parseInt(buff.length / time);
|
|
|
+ var lastData = parseInt(buff.length % time); //console.log(looptime + "---" + lastData)
|
|
|
+
|
|
|
+ this.looptime = looptime + 1
|
|
|
+ this.lastData = lastData
|
|
|
+ this.currentTime = 1
|
|
|
+ that.Send(buff);
|
|
|
},
|
|
|
//查询打印机状态
|
|
|
queryStatus() {
|
|
@@ -441,47 +452,97 @@
|
|
|
dataView.setUint8(i, buff[(currentTime - 1) * onTimeData + i])
|
|
|
}
|
|
|
}
|
|
|
- console.log("第" + currentTime + "次发送数据大小为:" + buf.byteLength)
|
|
|
+ // console.log("第" + currentTime + "次发送数据大小为:" + buf.byteLength)
|
|
|
+
|
|
|
let {
|
|
|
BLEInformation
|
|
|
} = that.Bluetooth;
|
|
|
-
|
|
|
- plus.bluetooth.writeBLECharacteristicValue({
|
|
|
- deviceId: BLEInformation.deviceId,
|
|
|
- serviceId: BLEInformation.writeServiceId,
|
|
|
- characteristicId: BLEInformation.writeCharaterId,
|
|
|
- value: buf,
|
|
|
- success: function(res) {
|
|
|
- console.log(res)
|
|
|
- },
|
|
|
- fail: function(e) {
|
|
|
- console.log(e)
|
|
|
- },
|
|
|
- complete: function() {
|
|
|
- currentTime++
|
|
|
- if (currentTime <= loopTime) {
|
|
|
- that.currentTime = currentTime;
|
|
|
- that.Send(buff)
|
|
|
- } else {
|
|
|
+ setTimeout(()=>{
|
|
|
+ uni.writeBLECharacteristicValue({
|
|
|
+ deviceId: BLEInformation.deviceId,
|
|
|
+ serviceId: BLEInformation.writeServiceId,
|
|
|
+ characteristicId: BLEInformation.writeCharaterId,
|
|
|
+ value: buf,
|
|
|
+ success: function(res) {
|
|
|
+ if (currentTime <= loopTime) {
|
|
|
+ // wx.showLoading({
|
|
|
+ // title: '传输中...',
|
|
|
+ // })
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '已打印第' + currentPrint + '张成功'
|
|
|
+ });
|
|
|
+ } //console.log(res)
|
|
|
+ },
|
|
|
+ fail: function(e) {
|
|
|
uni.showToast({
|
|
|
- title: '已打印第' + currentPrint + '张',
|
|
|
- })
|
|
|
- if (currentPrint == printNum) {
|
|
|
- that.looptime = 0;
|
|
|
- that.lastData = 0;
|
|
|
- that.currentTime = 1;
|
|
|
- that.isReceiptSend = false;
|
|
|
- that.isLabelSend = false;
|
|
|
- that.currentPrint = 1;
|
|
|
+ title: '打印第' + currentPrint + '张失败',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ console.log(e)
|
|
|
+ },
|
|
|
+ complete: function() {
|
|
|
+ currentTime++;
|
|
|
+
|
|
|
+ if (currentTime <= loopTime) {
|
|
|
+ that.currentTime = currentTime
|
|
|
+
|
|
|
+ that.Send(buff);
|
|
|
} else {
|
|
|
- currentPrint++;
|
|
|
- that.currentPrint = currentPrint;
|
|
|
- that.currentTime = 1;
|
|
|
- that.Send(buff)
|
|
|
+ if (currentPrint == printNum) {
|
|
|
+ that.looptime = 0
|
|
|
+ that.lastData = 0
|
|
|
+ that.currentTime = 1
|
|
|
+ that.isReceiptSend = false
|
|
|
+ that.currentPrint = 1
|
|
|
+ } else {
|
|
|
+ currentPrint++;
|
|
|
+ that.currentPrint = currentPrint
|
|
|
+ that.currentTime = 1
|
|
|
+
|
|
|
+ that.Send(buff);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ },100);
|
|
|
+
|
|
|
+ // plus.bluetooth.writeBLECharacteristicValue({
|
|
|
+ // deviceId: BLEInformation.deviceId,
|
|
|
+ // serviceId: BLEInformation.writeServiceId,
|
|
|
+ // characteristicId: BLEInformation.writeCharaterId,
|
|
|
+ // value: buf,
|
|
|
+ // success: function(res) {
|
|
|
+ // console.log(res)
|
|
|
+ // },
|
|
|
+ // fail: function(e) {
|
|
|
+ // console.log(e)
|
|
|
+ // },
|
|
|
+ // complete: function() {
|
|
|
+ // currentTime++
|
|
|
+ // if (currentTime <= loopTime) {
|
|
|
+ // that.currentTime = currentTime;
|
|
|
+ // that.Send(buff)
|
|
|
+ // } else {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '已打印第' + currentPrint + '张',
|
|
|
+ // })
|
|
|
+ // if (currentPrint == printNum) {
|
|
|
+ // that.looptime = 0;
|
|
|
+ // that.lastData = 0;
|
|
|
+ // that.currentTime = 1;
|
|
|
+ // that.isReceiptSend = false;
|
|
|
+ // that.isLabelSend = false;
|
|
|
+ // that.currentPrint = 1;
|
|
|
+ // } else {
|
|
|
+ // currentPrint++;
|
|
|
+ // that.currentPrint = currentPrint;
|
|
|
+ // that.currentTime = 1;
|
|
|
+ // that.Send(buff)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
},
|
|
|
buffBindChange: function(res) { //更改打印字节数
|
|
|
let index = res.detail.value
|