|
|
@@ -1,6 +1,9 @@
|
|
|
/** -姜枫 2021.06.13- **/
|
|
|
import { addPrintNum } from "@/api/order";
|
|
|
var util = require("@/pagesOrder/js/util.js");
|
|
|
+import drawQrcode from "@/pagesOrder/js/weapp.qrcode.esm";
|
|
|
+var toArrayBuffer = require('to-array-buffer');
|
|
|
+
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -298,7 +301,47 @@ export default {
|
|
|
arrPrint.push(util.hexStringToBuff(util.printTwoData("订单编号:", BleVal.orderSn)));
|
|
|
arrPrint.push(util.sendDirective([0x1B, 0x61, 0x00]));
|
|
|
arrPrint.push(util.hexStringToBuff("门店地址:"+BleVal.address+"\n"));
|
|
|
- arrPrint.push(util.hexStringToBuff("\n\n\n"));
|
|
|
+ arrPrint.push(util.hexStringToBuff("\n\n"));
|
|
|
+
|
|
|
+ // const ctx = uni.createCanvasContext('canvas');
|
|
|
+ // ctx.clearRect(0, 0, 130, 130);
|
|
|
+ // let tthis = this;
|
|
|
+ // drawQrcode({
|
|
|
+ // canvasId: 'canvas',
|
|
|
+ // text: 'https://shop.huahb.cn/#/main/index',
|
|
|
+ // width: 130,
|
|
|
+ // height: 130,
|
|
|
+ // callback(e) {
|
|
|
+ // console.log(111111123)
|
|
|
+ // setTimeout(() => {
|
|
|
+ // // 获取图片数据
|
|
|
+ // uni.canvasGetImageData({
|
|
|
+ // canvasId: 'canvas',
|
|
|
+ // x: 0,
|
|
|
+ // y: 0,
|
|
|
+ // width: 130,
|
|
|
+ // height: 130,
|
|
|
+ // success(res) {
|
|
|
+ // let arr = tthis.convert4to1(res.data);
|
|
|
+ // let data = tthis.convert8to1(arr);
|
|
|
+ // const cmds = [].concat([27, 97, 1], [29, 118, 48, 0, 20, 0, 160, 0], data, [27, 74, 3], [27, 64]);
|
|
|
+ // const buffer = toArrayBuffer(Buffer.from(cmds, 'gb2312'));
|
|
|
+ // console.log(123456789)
|
|
|
+ // arrPrint.push(util.sendDirective([0x1B, 0x40]));
|
|
|
+ // for (let i = 0; i < buffer.byteLength; i = i + 50) {
|
|
|
+ // arrPrint.push(buffer.slice(i, i + 50));
|
|
|
+ // }
|
|
|
+ // arrPrint.push(util.hexStringToBuff("\n"));
|
|
|
+ // arrPrint.push(util.sendDirective([0x1B, 0x61, 0x01])); //居中
|
|
|
+ // arrPrint.push(util.hexStringToBuff("扫码采购花材\n"));
|
|
|
+ // arrPrint.push(util.hexStringToBuff("\n"));
|
|
|
+ // arrPrint.push(util.hexStringToBuff("\n"));
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }, 3000);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+
|
|
|
addPrintNum({id:self.orderId}).then(res=>{
|
|
|
if(!self.$util.isEmpty(self.detailInfo)){
|
|
|
self.detailInfo.printNum++;
|
|
|
@@ -315,6 +358,35 @@ export default {
|
|
|
this.printInfo({deviceId:deviceId, serviceId:serviceId, characteristicId:characteristicId}, arrPrint);
|
|
|
|
|
|
},
|
|
|
+
|
|
|
+ //4合1
|
|
|
+ convert4to1(res) {
|
|
|
+ let arr = [];
|
|
|
+ for (let i = 0; i < res.length; i++) {
|
|
|
+ if (i % 4 == 0) {
|
|
|
+ let rule = 0.29900 * res[i] + 0.58700 * res[i + 1] + 0.11400 * res[i + 2];
|
|
|
+ if (rule > 200) {
|
|
|
+ res[i] = 0;
|
|
|
+ } else {
|
|
|
+ res[i] = 1;
|
|
|
+ }
|
|
|
+ arr.push(res[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ },
|
|
|
+
|
|
|
+ //8合1
|
|
|
+ convert8to1(arr) {
|
|
|
+ let data = [];
|
|
|
+ for (let k = 0; k < arr.length; k += 8) {
|
|
|
+ let temp = arr[k] * 128 + arr[k + 1] * 64 + arr[k + 2] * 32 + arr[k + 3] * 16 + arr[k + 4] * 8 + arr[k + 5] * 4 +
|
|
|
+ arr[k + 6] * 2 + arr[k + 7] * 1
|
|
|
+ data.push(temp);
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+
|
|
|
printInfo(device, arr, callback) {
|
|
|
let tthis = this;
|
|
|
if (arr.length > 0) {
|