maliang 3 veckor sedan
förälder
incheckning
29eaf36780
59 ändrade filer med 5046 tillägg och 188 borttagningar
  1. 9 2
      App.vue
  2. 220 0
      common/mixins/blePrintMixin.js
  3. 13 11
      common/store/index.js
  4. 229 0
      common/store/modules/ble.js
  5. 165 0
      components/ble-pop/ble-pop.vue
  6. 18 1
      components/error-pop/error-pop.vue
  7. 3 2
      components/good-item/good-item.vue
  8. 224 0
      components/print-pop/print-pop.vue
  9. 190 0
      components/tki-barcode/barcode.js
  10. 17 0
      components/tki-barcode/barcodes/Barcode.js
  11. 167 0
      components/tki-barcode/barcodes/CODE128/CODE128.js
  12. 42 0
      components/tki-barcode/barcodes/CODE128/CODE128A.js
  13. 42 0
      components/tki-barcode/barcodes/CODE128/CODE128B.js
  14. 42 0
      components/tki-barcode/barcodes/CODE128/CODE128C.js
  15. 41 0
      components/tki-barcode/barcodes/CODE128/CODE128_AUTO.js
  16. 73 0
      components/tki-barcode/barcodes/CODE128/auto.js
  17. 54 0
      components/tki-barcode/barcodes/CODE128/constants.js
  18. 29 0
      components/tki-barcode/barcodes/CODE128/index.js
  19. 104 0
      components/tki-barcode/barcodes/CODE39/index.js
  20. 92 0
      components/tki-barcode/barcodes/EAN_UPC/EAN.js
  21. 119 0
      components/tki-barcode/barcodes/EAN_UPC/EAN13.js
  22. 58 0
      components/tki-barcode/barcodes/EAN_UPC/EAN2.js
  23. 65 0
      components/tki-barcode/barcodes/EAN_UPC/EAN5.js
  24. 81 0
      components/tki-barcode/barcodes/EAN_UPC/EAN8.js
  25. 165 0
      components/tki-barcode/barcodes/EAN_UPC/UPC.js
  26. 185 0
      components/tki-barcode/barcodes/EAN_UPC/UPCE.js
  27. 30 0
      components/tki-barcode/barcodes/EAN_UPC/constants.js
  28. 27 0
      components/tki-barcode/barcodes/EAN_UPC/encoder.js
  29. 39 0
      components/tki-barcode/barcodes/EAN_UPC/index.js
  30. 55 0
      components/tki-barcode/barcodes/GenericBarcode/index.js
  31. 69 0
      components/tki-barcode/barcodes/ITF/ITF.js
  32. 55 0
      components/tki-barcode/barcodes/ITF/ITF14.js
  33. 9 0
      components/tki-barcode/barcodes/ITF/constants.js
  34. 19 0
      components/tki-barcode/barcodes/ITF/index.js
  35. 74 0
      components/tki-barcode/barcodes/MSI/MSI.js
  36. 33 0
      components/tki-barcode/barcodes/MSI/MSI10.js
  37. 35 0
      components/tki-barcode/barcodes/MSI/MSI1010.js
  38. 33 0
      components/tki-barcode/barcodes/MSI/MSI11.js
  39. 35 0
      components/tki-barcode/barcodes/MSI/MSI1110.js
  40. 29 0
      components/tki-barcode/barcodes/MSI/checksums.js
  41. 34 0
      components/tki-barcode/barcodes/MSI/index.js
  42. 92 0
      components/tki-barcode/barcodes/codabar/index.js
  43. 34 0
      components/tki-barcode/barcodes/index.js
  44. 73 0
      components/tki-barcode/barcodes/pharmacode/index.js
  45. 234 0
      components/tki-barcode/tki-barcode.vue
  46. 3 1
      main.js
  47. 13 4
      manifest.json
  48. 465 158
      package-lock.json
  49. 5 1
      package.json
  50. 1 7
      pages/inventory-task/detail.vue
  51. 139 0
      pages/picking-task/components/ble-tip-pop.vue
  52. 41 1
      pages/picking-task/delivery.vue
  53. 476 0
      plugins/BluetoothTool.js
  54. 85 0
      plugins/gb2312ToBase64.js
  55. 69 0
      plugins/permission.js
  56. 46 0
      plugins/printer.ts
  57. 247 0
      plugins/usbTool.js
  58. BIN
      static/image/refresh-icon.png
  59. BIN
      static/image/shebei-icon.png

+ 9 - 2
App.vue

@@ -3,12 +3,16 @@
 	var _codeQueryTag = false;
 export default {
 	onLaunch(options) {
+		// #ifdef APP-PLUS
 		// 重置app更新信息
 		uni.setStorageSync('update', false);
 		uni.setStorageSync('downloadApkParams', null);
 		console.log('onLaunch')
 		// 检测客户端更新
 		this.$store.dispatch('update/update', 0)
+		// 初始化蓝牙
+		this.$store.dispatch('ble/initBle')
+		// #endif
 	},
 	onShow() {
 		// #ifdef APP-PLUS
@@ -23,8 +27,11 @@ export default {
 	onHide() {
 		this.stopScan();
 	},
-	onLoad() {
-		
+	// 应用退出,断开连接
+	onExit(){
+		// #ifdef APP-PLUS
+		this.$store.dispatch('ble/closeBluetooth')
+		// #endif
 	},
 	// globalData: {
 	// 	uploadUrl: '',

+ 220 - 0
common/mixins/blePrintMixin.js

@@ -0,0 +1,220 @@
+import { mapState, mapActions } from "vuex";
+import { FakeConnectedDevice } from "@psdk/frame-father";
+import bluetoothTool from "@/plugins/BluetoothTool.js";
+
+import {
+  TBar,
+  TBarCode,
+  TQRCode,
+  TBox,
+  TImage,
+  TPage,
+  TRotation,
+  TCodeType,
+  TLine,
+  TText,
+  TFont,
+  TTLine,
+} from "@psdk/tspl";
+
+///转成安卓有符号的
+function uint8ArrayToSignedArray(uint8Array) {
+  let signedArray = new Array(uint8Array.length);
+  for (let i = 0; i < uint8Array.length; i++) {
+    if (uint8Array[i] >= 128) {
+      signedArray[i] = uint8Array[i] - 256;
+    } else {
+      signedArray[i] = uint8Array[i];
+    }
+  }
+  return signedArray;
+}
+
+async function sendMessage(cmd) {
+  console.log(cmd);
+  const result = bluetoothTool.sendByteData(cmd);
+  uni.showToast({
+    icon: "none",
+    title: result ? "发送成功!" : "发送失败...",
+  });
+}
+
+export default {
+  name: "blePrintMixin",
+  computed: {
+    ...mapState({
+      discoveredDevices: (state) => state.ble.discoveredDevices, // 已发现的蓝牙设备
+      connectedBleDevice: (state) => state.ble.connectedBleDevice,
+      connectedDeviceId: (state) => state.ble.connectedDeviceId, // 已连接的蓝牙设备ID
+    }),
+  },
+  data() {
+    return {
+      bleErrorTipPop: {
+        show: false,
+        content: "未连接 蓝牙",
+        extraText: "请连接蓝牙之后再继续操作",
+      },
+      // 蓝牙打印弹框
+      blePrintPop: {
+        show: false,
+        data: {},
+      },
+      // 选择蓝牙设备弹框
+      bleSelectPop: {
+        show: false,
+        discoveredDevices: [],
+      },
+    };
+  },
+  mounted() {},
+  methods: {
+    ...mapActions("ble", [
+      "checkBleStatus", // 检查蓝牙设备连接状态
+      "discovery", // 搜索蓝牙设备
+      "connectBT", // 连接蓝牙设备
+      "cancelDiscovery", // 停止蓝牙搜索
+    ]),
+    bleErrorTipConfirm() {
+      this.bleErrorTipPop.show = false;
+      this.openBleSelectPop();
+    },
+    //打开蓝牙选择弹框
+    openBleSelectPop() {
+      this.discovery(); // 搜索蓝牙设备
+      this.bleSelectPop.show = true;
+    },
+    //关闭蓝牙选择弹框
+    closeBleSelectPop() {
+      this.cancelDiscovery();
+      this.bleSelectPop.show = false;
+    },
+    //选择蓝牙设备
+    async handleSelectBle(item) {
+      console.log("选择蓝牙设备=====", item);
+      const device = await this.connectBT(item);
+      if (device) {
+        this.closeBleSelectPop();
+        this.$printer.init(new FakeConnectedDevice()); // 初始化打印机
+        this.blePrintPop.show = true;
+      }
+      console.log("this.blePrintPop.data=====", this.blePrintPop.data);
+    },
+    // 打开蓝牙打印弹框
+    async openBlePrintPop(data) {
+      const res = await this.checkBleStatus(); // 检查蓝牙设备打开状态
+      this.blePrintPop.data = data;
+      switch (res.code) {
+        case 0:
+          // const devices = bluetoothTool.getPairedDevices(); // 获取已配对的蓝牙设备
+          // console.log("devices======", devices);
+          if (this.connectedDeviceId != "") {
+            this.blePrintPop.show = true;
+          } else {
+            // 如果没有配对的设备,提示用户去配对
+            this.bleErrorTipPop.show = true;
+          }
+          break;
+        case 1:
+          uni.showToast({
+            icon: "none",
+            title: "请打开蓝牙",
+          });
+          break;
+        case 2:
+          uni.showToast({
+            icon: "none",
+            title: "当前设备不支持蓝牙",
+          });
+          break;
+      }
+    },
+    // 重新搜索蓝牙设备
+    refreshBleDevice() {
+      this.discovery();
+    },
+    /**
+     * 打印
+     *@data {Object} 需要打印的数据
+     * */
+    async writeTsplModel(data) {
+      const vm = this;
+      const obj = {
+        qrCode: data.qrCode, // 二维码
+        barCode: data.barCode, // 商品条码
+        customerName: data.customerName, //客户名
+        number: data.number, // 单据编号
+        batchNumber: data.batchNumber, // 批次条码
+      };
+      try {
+        const tspl = await vm.$printer
+          .tspl()
+          .clear()
+          .page(
+            new TPage({
+              width: 76,
+              height: 130,
+            })
+          )
+          .qrcode(
+            new TQRCode({
+              x: 50,
+              y: 20,
+              content: "283423982494284284828484",
+              cellWidth: 10,
+            })
+          )
+          .text(
+            new TText({
+              x: 50 + 30,
+              y: 20,
+              content: obj.customerName,
+              font: TFont.TSS24,
+            })
+          )
+          .text(
+            new TText({
+              x: 50 + 30,
+              y: 20 + 35,
+              content: obj.number,
+              font: TFont.TSS24,
+            })
+          )
+          .barcode(
+            new TBarCode({
+              x: 50,
+              y: 20 + 35 + 20,
+              cellWidth: 2,
+              height: 60,
+              content: obj.barCode,
+              rotation: TRotation.ROTATION_0,
+              codeType: TCodeType.CODE128,
+              showType: 2,
+            })
+          )
+          .text(
+            new TText({
+              x: 50 + 20,
+              y: 50 + 100,
+              content: obj.barCode,
+              font: TFont.TSS24,
+            })
+          )
+          .print();
+        var binary = tspl.command().binary();
+        await sendMessage(Array.from(uint8ArrayToSignedArray(binary)));
+      } catch (e) {
+        console.error(e);
+        uni.showToast({
+          title: "失败",
+        });
+      }
+    },
+
+    async writeData({ num = 1, data }) {
+      for (let i = 0; i < num; i++) {
+        await this.writeTsplModel(data);
+      }
+    },
+  },
+};

+ 13 - 11
common/store/index.js

@@ -1,15 +1,17 @@
-import Vue from 'vue'
-import Vuex from 'vuex'
+import Vue from "vue";
+import Vuex from "vuex";
 
-Vue.use(Vuex)
-import user from './modules/user.js'
-import update from './modules/update.js'
+Vue.use(Vuex);
+import user from "./modules/user.js";
+import update from "./modules/update.js";
+import ble from "./modules/ble.js";
 
 const store = new Vuex.Store({
-	modules: {
-		user,
-		update,
-	}
-})
+  modules: {
+    user,
+    update,
+    ble,
+  },
+});
 
-export default store
+export default store;

+ 229 - 0
common/store/modules/ble.js

@@ -0,0 +1,229 @@
+import bluetoothTool from "@/plugins/BluetoothTool.js";
+import permission from "@/plugins/permission.js";
+
+const statusMap = [
+  {
+    code: 0,
+    msg: "蓝牙设备已打开",
+  },
+  {
+    code: 1,
+    msg: "蓝牙设备未打开",
+  },
+  {
+    code: 2,
+    msg: "当前设备不支持蓝牙",
+  },
+];
+
+export default {
+  namespaced: true,
+  // 储存数据
+  state: {
+    discoveredDevices: [], // 已发现的蓝牙设备
+    connectedBleDevice: null, // 当前连接的蓝牙设备
+    connectedDeviceId: "", // 已连接的蓝牙设备ID
+  },
+  // 修改数据
+  mutations: {
+    // 设置已发现的蓝牙设备
+    setDiscoveredDevices(state, data) {
+      console.log("setDiscoveredDevices------", data);
+      state.discoveredDevices = data;
+    },
+    // 设置已发现的蓝牙设备
+    addDiscoveredDevice(state, device) {
+      console.log("addDiscoveredDevice------", device);
+      state.discoveredDevices.push(device);
+    },
+    // 已连接蓝牙设备
+    setConnectedBleDevice(state, data) {
+      console.log(111111, data);
+      state.connectedBleDevice = { ...data };
+    },
+    // 设置已连接蓝牙设备ID
+    setConnectedDeviceId(state, data) {
+      state.connectedDeviceId = data;
+    },
+  },
+  actions: {
+    // 检查蓝牙设备打开状态
+    checkBleStatus({ commit }) {
+      return new Promise((resolve) => {
+        // 检查蓝牙是否打开
+        if (bluetoothTool.isSupportBluetooth()) {
+          console.log("蓝牙设备支持");
+          if (bluetoothTool.getBluetoothStatus()) {
+            console.log("蓝牙设备已打开");
+            resolve({
+              code: statusMap[0].code,
+              msg: statusMap[0].msg,
+            });
+          } else {
+            console.log("蓝牙设备未打开");
+            resolve({
+              code: statusMap[1].code,
+              msg: statusMap[1].msg,
+            });
+          }
+        } else {
+          resolve({
+            code: statusMap[2].code,
+            msg: statusMap[2].msg,
+          });
+        }
+      });
+    },
+    // 初始蓝牙
+    initBle({ commit, state }) {
+      console.log("state======", state);
+      // 检查蓝牙权限
+      permission
+        .androidPermissionCheck("bluetooth")
+        .then(() => {
+          bluetoothTool.init({
+            // 监听蓝牙状态变化
+            listenBTStatusCallback: (state) => {
+              if (state == "STATE_ON") {
+                console.log("蓝牙已打开:", state);
+                // 可以在这里添加蓝牙打开后的初始化逻辑
+              } else if (state == "STATE_OFF") {
+                console.log("蓝牙已关闭:", state);
+                // 可以在这里添加蓝牙关闭后的清理逻辑
+              }
+            },
+            // 发现新设备回调
+            discoveryDeviceCallback: function (device) {
+              try {
+                // 基本验证
+                if (!device || !device.name) {
+                  console.log("无效设备:", device);
+                  return;
+                }
+
+                // 设备名称过滤
+                const deviceName = device.name.toUpperCase();
+                const isBleDevice =
+                  deviceName.endsWith("_BLE") ||
+                  deviceName.endsWith("-LE") ||
+                  deviceName.endsWith("-BLE");
+
+                // 如果是BLE设备,直接返回
+                if (isBleDevice) {
+                  console.log("发现BLE设备:", device);
+                  return;
+                }
+
+                // 设备去重
+                const isDuplicate = state.discoveredDevices.find(
+                  (item) => item.address === device.address
+                );
+                if (isDuplicate) {
+                  console.log("重复设备:", device);
+                  return;
+                }
+
+                // 添加设备到列表
+                console.log("发现新设备:", device);
+                commit("addDiscoveredDevice", device);
+              } catch (error) {
+                console.error("处理设备发现回调出错:", error);
+              }
+            },
+            // 搜索完成回调
+            discoveryFinishedCallback: function () {
+              console.log("蓝牙设备搜索完成");
+              // 可以在这里添加搜索完成后的处理逻辑
+            },
+            // 读取数据回调
+            readDataCallback: function (dataByteArr) {
+              try {
+                if (!dataByteArr || dataByteArr.length === 0) {
+                  console.log("无数据读取");
+                  return;
+                }
+                console.log("读取到数据:", dataByteArr);
+                // 这里可以添加数据处理逻辑
+              } catch (error) {
+                console.error("处理数据读取回调出错:", error);
+              }
+            },
+            // 连接异常回调
+            connExceptionCallback: function (e) {
+              console.error("蓝牙连接异常:", e);
+              // 可以在这里添加连接异常的处理逻辑
+              uni.showToast({
+                icon: "none",
+                title: "蓝牙连接异常,请重试",
+                duration: 2000,
+              });
+            },
+          });
+        })
+        .catch((error) => {
+          console.error("蓝牙权限检查失败:", error);
+          uni.showToast({
+            icon: "none",
+            title: "请授予蓝牙权限",
+            duration: 2000,
+          });
+        });
+    },
+    // 搜索蓝牙设备
+    async discovery({ commit }) {
+      // 使用openBluetoothAdapter 接口,免去主动申请权限的麻烦
+      uni.openBluetoothAdapter({
+        success: async (res) => {
+          try {
+            await permission.androidPermissionCheck("bluetooth");
+            commit("setDiscoveredDevices", []);
+            bluetoothTool.discoveryNewDevice();
+            console.log("openBluetoothAdapter=====", res);
+          } catch (err) {
+            bluetoothTool.shortToast(`授权失败:!${err}`);
+            console.log("授权失败:", err);
+          }
+        },
+      });
+    },
+    // 连接蓝牙
+    connectBT({ commit }, device) {
+      uni.showLoading({
+        title: "连接中",
+      });
+      return new Promise((resolve) => {
+        bluetoothTool.connDevice(device.address, (result) => {
+          uni.hideLoading();
+          if (result) {
+            console.log(result);
+            bluetoothTool.cancelDiscovery();
+            commit("setConnectedBleDevice", device);
+            commit("setConnectedDeviceId", device.address);
+            uni.showToast({
+              icon: "none",
+              title: "连接成功",
+            });
+            resolve(device);
+          } else {
+            uni.showToast({
+              icon: "none",
+              title: "连接失败",
+            });
+            resolve(null);
+          }
+        });
+      });
+    },
+    // 断开连接
+    closeBluetooth({ commit, state }) {
+      if (state.connectedDeviceId != "") {
+        bluetoothTool.closeBtSocket();
+        commit("setConnectedBleDevice", null);
+        commit("setConnectedDeviceId", "");
+      }
+    },
+    cancelDiscovery() {
+      bluetoothTool.cancelDiscovery();
+    },
+  },
+};

+ 165 - 0
components/ble-pop/ble-pop.vue

@@ -0,0 +1,165 @@
+<template>
+  <view>
+    <u-popup
+      :show="show"
+      mode="center"
+      @open="handleOpen"
+      :round="10"
+      :closeable="false"
+      :closeOnClickOverlay="false"
+    >
+      <view class="pop-content">
+        <view class="top-box">
+          <view class="flex-box flex-justify-sb flex-row-center">
+            <view class="pop-name">选择设备</view>
+            <image
+              src="@/static/image/refresh-icon.png"
+              class="refresh-btn"
+              @click="handleRefresh"
+            ></image>
+          </view>
+          <u-icon
+            name="close"
+            color="#666"
+            size="20"
+            @click="handleClose"
+          ></u-icon>
+        </view>
+        <view class="ble-box">
+          <scroll-view
+            scroll-y
+            :style="{
+              height: '100%',
+            }"
+          >
+            <block v-for="(item, index) in list" :key="index">
+              <view class="ble-item">
+                <image
+                  src="@/static/image/shebei-icon.png"
+                  class="shebei-icon"
+                ></image>
+                <view class="ble-name">{{ item.name }}</view>
+                <view class="action-btn" @click="clickItem(item)">选择</view>
+              </view>
+            </block>
+          </scroll-view>
+        </view>
+      </view>
+    </u-popup>
+  </view>
+</template>
+
+<script>
+export default {
+  props: {
+    show: {
+      type: Boolean,
+      default: false,
+    },
+  },
+  computed: {
+    list() {
+      return this.$store.state.ble.discoveredDevices;
+    },
+  },
+  data() {
+    return {};
+  },
+  methods: {
+    handleClose() {
+      this.$emit("update:show", false);
+      this.$emit("close");
+    },
+    handleOpen() {
+      this.$emit("open");
+    },
+    handleRefresh() {
+      this.$emit("refresh");
+    },
+    clickItem(item) {
+      this.$emit("selectItem", item);
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.pop-content {
+  width: 590rpx;
+  padding: 30rpx;
+  background: #fff;
+  border-radius: 10rpx;
+
+  .pop-name {
+    font-family: PingFang SC;
+    font-weight: 500;
+    font-size: 32rpx;
+    line-height: 1;
+    color: rgba(29, 33, 42, 1);
+  }
+
+  .ble-box {
+    height: 600rpx;
+  }
+}
+.flex-box {
+  display: flex;
+}
+.flex-justify-sb {
+  justify-content: space-between;
+}
+.flex-row-center {
+  align-items: center;
+}
+.top-box {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 30rpx;
+
+  .refresh-btn {
+    width: 40rpx;
+    height: 40rpx;
+    margin-left: 10rpx;
+  }
+
+  .shebei-icon {
+    width: 80rpx;
+    height: 80rpx;
+    margin-right: 20rpx;
+  }
+}
+.ble-item {
+  display: grid;
+  grid-template-columns: 100rpx 1fr 120rpx;
+  align-items: center;
+  margin-bottom: 20rpx;
+  width: 100%;
+
+  .shebei-icon {
+    width: 80rpx;
+    height: 80rpx;
+    margin-right: 20rpx;
+  }
+
+  .action-btn {
+    font-family: PingFang SC;
+    font-weight: 400;
+    font-size: 22rpx;
+    width: 120rpx;
+    height: 44rpx;
+    border-radius: 40rpx;
+    text-align: center;
+    line-height: 44rpx;
+    background-color: rgba(2, 86, 255, 0.1);
+    color: rgba(2, 86, 255, 1);
+    margin-left: 20rpx;
+  }
+
+  .ble-name {
+    overflow: hidden;
+    white-space: no-wrap;
+    text-overflow: ellipsis;
+  }
+}
+</style>

+ 18 - 1
components/error-pop/error-pop.vue

@@ -5,7 +5,14 @@
 				<view class="flex_box flex_row_center">
 					<u-image src="@/static/image/error-img.png" width="112rpx" height="112rpx"></u-image>
 				</view>
-				<view :class="['tips-value',{'is-center': isCenter}]">{{content}}</view>
+				<view :class="['tips-value',{'is-center': isCenter}]">
+					<view class="">
+						{{content}}
+					</view>
+					<view class="tips-value-extra" v-if="extraText">
+						{{extraText}}
+					</view>
+				</view>
 				<view class="btn-box">
 					<u-button class="no-btn" type="primary" :plain="true" :text="cancelBtnText" @click="closeClick"></u-button>
 					<u-button class="yes-btn" type="primary" :text="confirmBtnText" @click="confirmClick"></u-button>
@@ -26,6 +33,10 @@
 				type:String,
 				default:''
 			},
+			extraText: {
+				type:String,
+				default:''
+			},
 			cancelBtnText: {
 			    type:String,
 				default:'否'
@@ -78,6 +89,12 @@
 		&.is-center{
 			text-align: center;
 		}
+		
+		&-extra{
+			font-weight: 400;
+			font-size: 28rpx;
+			color: rgba(153, 153, 153, 1);
+		}
 	}
 	.btn-box {
 		display: flex;

+ 3 - 2
components/good-item/good-item.vue

@@ -18,10 +18,10 @@
 					<view class="item-label">规格</view>
 					<view class="item-value">{{item.materialStandard || '-'}}</view>
 				</view>
-				<view class="good-cont-item">
+			<!-- 	<view class="good-cont-item">
 					<view class="item-label">批次号</view>
 					<view class="item-value">{{item.batchNumber || '-'}}</view>
-				</view>
+				</view> -->
 				<view class="good-cont-item" @click.stop="calendarClick">
 					<view class="item-label">生产日期</view>
 					<view class="item-value">{{item.productionDate ? $u.timeFormat(item.productionDate, 'yyyy-mm-dd') : '-'}}</view>
@@ -79,6 +79,7 @@
 			display: flex;
 			align-items: center;
 			padding: 0 24rpx;
+			
 			&-name {
 				color: #333;
 				font-family: "PingFang SC";

+ 224 - 0
components/print-pop/print-pop.vue

@@ -0,0 +1,224 @@
+<template>
+  <view>
+    <u-popup
+      :show="show"
+      mode="center"
+      @close="handleClose"
+      @open="handleOpen"
+      :round="10"
+      :closeOnClickOverlay="false"
+    >
+      <view class="pop-content">
+        <view class="pop-main">
+          <view class="flex_box flex-row-center pd-30">
+            <view class="qr-code">
+              <uqrcode
+                ref="uqrcode"
+                canvas-id="qrcode"
+                value="https://uqrcode.cn/doc"
+                sizeUnit="rpx"
+                :size="200"
+              ></uqrcode>
+            </view>
+            <view class="flex-box flex-column flex-justify-sa info-box">
+              <view class="item-value">快马便利</view>
+              <view class="item-value">阳光店</view>
+              <view class="item-value">DD2500426-188</view>
+            </view>
+          </view>
+          <tki-barcode
+            ref="barcode"
+            :show="showBarCode"
+            :val="barcodeVal"
+            :opations="{
+              width: 1,
+              height: 100,
+              displayValue: true,
+              margin: 10,
+            }"
+            @result="getBarCodeImg"
+          />
+          <view class="tips-value">请确认打印条码数量</view>
+          <view class="num-box">
+            <u-number-box
+              v-model="printNum"
+              :inputWidth="56"
+              :min="0"
+            ></u-number-box>
+          </view>
+        </view>
+        <!-- 操作按钮 -->
+        <view class="btn-footer">
+          <u-button
+            text="取消"
+            type="primary"
+            :plain="true"
+            @click="handleClose"
+            :customStyle="{
+              marginRight: '16rpx',
+              border: '1px solid #bfc8db',
+              color: '#86909c',
+            }"
+            class="footer-btn no-btn"
+          ></u-button>
+          <u-button
+            text="确定"
+            type="primary"
+            @click="handleConfirm"
+            class="footer-btn yes-btn"
+          ></u-button>
+        </view>
+      </view>
+    </u-popup>
+  </view>
+</template>
+
+<script>
+import tkiBarcode from "@/components/tki-barcode/tki-barcode.vue";
+
+export default {
+  components: { tkiBarcode },
+  props: {
+    show: {
+      type: Boolean,
+      default: false,
+    },
+    info: {
+      type: Object,
+      default: () => ({}),
+    },
+  },
+  computed: {
+    barcodeVal() {
+      return this.info.barCode || "";
+    },
+  },
+  data() {
+    return {
+      showBarCode: false,
+      printNum: 1,
+    };
+  },
+  methods: {
+    // 关闭弹窗
+    handleClose() {
+      this.showBarCode = false;
+      this.$emit("update:show", false);
+      this.$emit("close");
+    },
+    handleOpen() {
+      this.printNum = 1;
+      this.showBarCode = true;
+    },
+    handleConfirm() {
+      const params = {
+        num: this.printNum,
+        // data: this.info,
+        data: {
+          qrCode: "12892u483482731", // 二维码
+          barCode: "189387467634928", // 商品条码
+          customerName: "快马便利(阳光店)", //客户名
+          number: "DD2500426-188", // 单据编号
+          batchNumber: "12892847378728467", // 批次条码
+        },
+      };
+      this.$emit("confirm", params);
+      this.handleClose();
+    },
+    getBarCodeImg(res) {
+      console.log("条形码图片", res);
+      this.$emit("barCodeImg", res);
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.pop-content {
+  width: 590rpx;
+  padding: 60rpx 20rpx 48rpx;
+  background: #fff;
+  border-radius: 10rpx;
+
+  .pop-main {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+  }
+
+  .flex_box {
+    display: flex;
+  }
+  .pd-30 {
+    padding: 30rpx;
+  }
+  .mt-30 {
+    margin-top: 30rpx;
+  }
+  .flex-column {
+    flex-direction: column;
+  }
+  .flex-align-center {
+    align-items: center;
+  }
+  .flex-row-center {
+    flex-direction: row;
+    justify-content: center;
+  }
+
+  .info-box {
+    flex: 1;
+  }
+  .item-value {
+    font-size: 32rpx;
+    margin-bottom: 10rpx;
+  }
+  .qr-code {
+    width: 200rpx;
+    height: 200rpx;
+    background-color: #bfc8db;
+    margin-right: 20rpx;
+  }
+
+  .bar-code {
+    width: 400rpx;
+    margin-bottom: 10rpx;
+  }
+  .tips-value {
+    color: #1d212a;
+    font-family: "PingFang SC";
+    font-size: 32rpx;
+    font-style: normal;
+    font-weight: bold;
+    margin-top: 30rpx;
+    text-align: center;
+  }
+
+  .num-box {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    margin-top: 30rpx;
+  }
+  .btn-footer {
+    display: flex;
+    padding: 30rpx;
+
+    .no-btn {
+      border: 1px solid #bfc8db;
+      color: #86909c;
+    }
+    .yes-btn {
+      background: #0256ff;
+    }
+
+    .footer-btn {
+      flex: 1;
+      margin: 0 16rpx;
+      width: 244rpx;
+      border-radius: 16rpx;
+      font-size: 32rpx;
+    }
+  }
+}
+</style>

+ 190 - 0
components/tki-barcode/barcode.js

@@ -0,0 +1,190 @@
+const barcodes = require('./barcodes/index.js')['default'];
+let barcode = {};
+(function () {
+    // 初始化
+    barcode = function (cont, ctxid, options, ctxsize, result) {
+        let ops = {}, newOptions, encodings, globaContext, ctx, globaCtxid, cbCanvasSize, cbResult;
+        globaCtxid = ctxid
+        cbCanvasSize = ctxsize
+        cbResult = result
+        newOptions = Object.assign(ops, options);
+        // 修成margin
+        fixMargin(newOptions)
+        // 处理options 数据
+        if (newOptions.text == '' || cont == '') {
+            return false
+        }
+        // 获取ctx
+        globaContext = cont
+        ctx = uni.createCanvasContext(globaCtxid, globaContext)
+        // 获取编码数据
+        encodings = new barcodes[newOptions.format.toUpperCase()](newOptions.text, newOptions).encode()
+        let fixencodings = fixEncodings(encodings, newOptions)
+        // 返回canvas实际大小
+        cbCanvasSize({ width: fixencodings.width, height: fixencodings.height })
+        // 绘制canvas
+        setTimeout(() => {
+            drawCanvas.render(newOptions, fixencodings)
+        }, 50);
+        // 绘制canvas
+        let drawCanvas = {
+            render(options, encoding) {
+                this.prepare(options, encoding)
+                encoding.encodings.forEach((v, i) => {
+                    this.barcode(options, v)
+                    this.text(options, v)
+                    this.move(v)
+                });
+                this.draw(options, encoding)
+            },
+            barcode(options, encoding) {
+                let binary = encoding.data;
+                let yFrom;
+                if (options.textPosition == "top") {
+                    yFrom = options.marginTop + options.fontSize + options.textMargin;
+                } else {
+                    yFrom = options.marginTop;
+                }
+                // 绘制条码
+                ctx.fillStyle = options.lineColor;
+                for (let b = 0; b < binary.length; b++) {
+                    let x = b * options.width + encoding.barcodePadding;
+                    let height = options.height
+                    if (encoding.options) {
+                        if (encoding.options.height != undefined) {
+                            height = encoding.options.height
+                        }
+                    }
+                    if (binary[b] === "1") {
+                        ctx.fillRect(x, yFrom, options.width, height);
+                    } else if (binary[b]) {
+                        ctx.fillRect(x, yFrom, options.width, height * binary[b]);
+                    }
+                }
+            },
+            text(options, encoding) {
+                if (options.displayValue) {
+                    let x, y, align, size;
+                    if (options.textPosition == "top") {
+                        y = options.marginTop + options.fontSize;
+                    } else {
+                        y = options.height + options.textMargin + options.marginTop + options.fontSize;
+                    }
+                    if (encoding.options) {
+                        if (encoding.options.textAlign != undefined) {
+                            align = encoding.options.textAlign
+                        }
+                        if (encoding.options.fontSize != undefined) {
+                            size = encoding.options.fontSize
+                        }
+                    } else {
+                        align = options.textAlign
+                        size = options.fontSize
+                    }
+                    ctx.setFontSize(size)
+                    if (align == "left" || encoding.barcodePadding > 0) {
+                        x = 0;
+                        ctx.setTextAlign('left')
+                    } else if (align == "right") {
+                        x = encoding.width - 1;
+                        ctx.setTextAlign('right')
+                    }
+                    else {
+                        x = encoding.width / 2;
+                        ctx.setTextAlign('center');
+                    }
+                    ctx.fillStyle = options.fontColor;
+                    if (encoding.text != undefined) {
+                        ctx.fillText(encoding.text, x, y);
+                    }
+                }
+            },
+            move(encoding) {
+                ctx.translate(encoding.width, 0);
+            },
+            prepare(options, encoding) {
+                // 绘制背景
+                if (options.background) {
+                    ctx.fillStyle = options.background;
+                    ctx.fillRect(0, 0, encoding.width, encoding.height);
+                }
+                ctx.translate(options.marginLeft, 0);
+            },
+            draw(options, encoding) {
+                ctx.draw(false, () => {
+                    this.toImgs(options, encoding)
+                })
+            },
+            toImgs(options, encoding) {
+                setTimeout(() => {
+                    uni.canvasToTempFilePath({
+                        width: encoding.width,
+                        height: encoding.height,
+                        destWidth: encoding.width,
+                        destHeight: encoding.height,
+                        canvasId: globaCtxid,
+                        fileType: 'png',
+                        success: function (res) {
+                            cbResult(res.tempFilePath)
+                        },
+                        fail: function (res) {
+                            cbResult(res)
+                        },
+                        complete: function () {
+                            uni.hideLoading();
+                        },
+                    }, globaContext);
+                }, options.text.length + 100);
+            }
+        }
+        // 混入canvas数据
+        function fixEncodings(encoding, options) {
+            let encodingArr = [], width = options.marginLeft + options.marginRight, height;
+            if (!Array.isArray(encoding)) {
+                encodingArr[0] = JSON.parse(JSON.stringify(encoding))
+            } else {
+                encodingArr = [...encoding]
+            }
+            encodingArr.forEach((v, i) => {
+                // 获取文本宽度
+                let textWidth = ctx.measureText(encodingArr[i].text ? encodingArr[i].text : '').width;
+                // 获取条形码宽度
+                let barcodeWidth = encodingArr[i].data.length * options.width;
+                // 获取内边距
+                let barcodePadding = 0;
+                if (options.displayValue && barcodeWidth < textWidth) {
+                    if (options.textAlign == "center") {
+                        barcodePadding = Math.floor((textWidth - barcodeWidth) / 2);
+                    } else if (options.textAlign == "left") {
+                        barcodePadding = 0;
+                    } else if (options.textAlign == "right") {
+                        barcodePadding = Math.floor(textWidth - barcodeWidth);
+                    }
+                }
+                // 混入encodingArr[i]
+                encodingArr[i].barcodePadding = barcodePadding
+                encodingArr[i].width = Math.ceil(Math.max(textWidth, barcodeWidth))
+                width += encodingArr[i].width
+                if (encodingArr[i].options) {
+                    if (encodingArr[i].options.height != undefined) {
+                        encodingArr[i].height = encodingArr[i].options.height + (options.displayValue && (encodingArr[i].text ? encodingArr[i].text : '').length > 0 ? options.fontSize + options.textMargin : 0) + options.marginTop + options.marginBottom;
+                    } else {
+                        encodingArr[i].height = height = options.height + (options.displayValue && (encodingArr[i].text ? encodingArr[i].text : '').length > 0 ? options.fontSize + options.textMargin : 0) + options.marginTop + options.marginBottom;
+                    }
+                } else {
+                    encodingArr[i].height = height = options.height + (options.displayValue && (encodingArr[i].text ? encodingArr[i].text : '').length > 0 ? options.fontSize + options.textMargin : 0) + options.marginTop + options.marginBottom;
+                }
+            });
+            return { encodings: encodingArr, width, height };
+        }
+        // 修正Margin
+        function fixMargin(options) {
+            options.marginTop = options.marginTop == undefined ? options.margin : options.marginTop;
+            options.marginBottom = options.marginBottom == undefined ? options.margin : options.marginBottom;
+            options.marginRight = options.marginRight == undefined ? options.margin : options.marginRight;
+            options.marginLeft = options.marginLeft == undefined ? options.margin : options.marginLeft;
+        }
+    };
+})()
+
+export default barcode

+ 17 - 0
components/tki-barcode/barcodes/Barcode.js

@@ -0,0 +1,17 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var Barcode = function Barcode(data, options) {
+	_classCallCheck(this, Barcode);
+
+	this.data = data;
+	this.text = options.text || data;
+	this.options = options;
+};
+
+exports.default = Barcode;

+ 167 - 0
components/tki-barcode/barcodes/CODE128/CODE128.js

@@ -0,0 +1,167 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _Barcode2 = require('../Barcode.js');
+
+var _Barcode3 = _interopRequireDefault(_Barcode2);
+
+var _constants = require('./constants');
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+// This is the master class,
+// it does require the start code to be included in the string
+var CODE128 = function (_Barcode) {
+	_inherits(CODE128, _Barcode);
+
+	function CODE128(data, options) {
+		_classCallCheck(this, CODE128);
+
+		// Get array of ascii codes from data
+		var _this = _possibleConstructorReturn(this, (CODE128.__proto__ || Object.getPrototypeOf(CODE128)).call(this, data.substring(1), options));
+
+		_this.bytes = data.split('').map(function (char) {
+			return char.charCodeAt(0);
+		});
+		return _this;
+	}
+
+	_createClass(CODE128, [{
+		key: 'valid',
+		value: function valid() {
+			// ASCII value ranges 0-127, 200-211
+			return (/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)
+			);
+		}
+
+		// The public encoding function
+
+	}, {
+		key: 'encode',
+		value: function encode() {
+			var bytes = this.bytes;
+			// Remove the start code from the bytes and set its index
+			var startIndex = bytes.shift() - 105;
+			// Get start set by index
+			var startSet = _constants.SET_BY_CODE[startIndex];
+
+			if (startSet === undefined) {
+				throw new RangeError('The encoding does not start with a start character.');
+			}
+
+			if (this.shouldEncodeAsEan128() === true) {
+				bytes.unshift(_constants.FNC1);
+			}
+
+			// Start encode with the right type
+			var encodingResult = CODE128.next(bytes, 1, startSet);
+
+			return {
+				text: this.text === this.data ? this.text.replace(/[^\x20-\x7E]/g, '') : this.text,
+				data:
+				// Add the start bits
+				CODE128.getBar(startIndex) +
+				// Add the encoded bits
+				encodingResult.result +
+				// Add the checksum
+				CODE128.getBar((encodingResult.checksum + startIndex) % _constants.MODULO) +
+				// Add the end bits
+				CODE128.getBar(_constants.STOP)
+			};
+		}
+
+		// GS1-128/EAN-128
+
+	}, {
+		key: 'shouldEncodeAsEan128',
+		value: function shouldEncodeAsEan128() {
+			var isEAN128 = this.options.ean128 || false;
+			if (typeof isEAN128 === 'string') {
+				isEAN128 = isEAN128.toLowerCase() === 'true';
+			}
+			return isEAN128;
+		}
+
+		// Get a bar symbol by index
+
+	}], [{
+		key: 'getBar',
+		value: function getBar(index) {
+			return _constants.BARS[index] ? _constants.BARS[index].toString() : '';
+		}
+
+		// Correct an index by a set and shift it from the bytes array
+
+	}, {
+		key: 'correctIndex',
+		value: function correctIndex(bytes, set) {
+			if (set === _constants.SET_A) {
+				var charCode = bytes.shift();
+				return charCode < 32 ? charCode + 64 : charCode - 32;
+			} else if (set === _constants.SET_B) {
+				return bytes.shift() - 32;
+			} else {
+				return (bytes.shift() - 48) * 10 + bytes.shift() - 48;
+			}
+		}
+	}, {
+		key: 'next',
+		value: function next(bytes, pos, set) {
+			if (!bytes.length) {
+				return { result: '', checksum: 0 };
+			}
+
+			var nextCode = void 0,
+			    index = void 0;
+
+			// Special characters
+			if (bytes[0] >= 200) {
+				index = bytes.shift() - 105;
+				var nextSet = _constants.SWAP[index];
+
+				// Swap to other set
+				if (nextSet !== undefined) {
+					nextCode = CODE128.next(bytes, pos + 1, nextSet);
+				}
+				// Continue on current set but encode a special character
+				else {
+						// Shift
+						if ((set === _constants.SET_A || set === _constants.SET_B) && index === _constants.SHIFT) {
+							// Convert the next character so that is encoded correctly
+							bytes[0] = set === _constants.SET_A ? bytes[0] > 95 ? bytes[0] - 96 : bytes[0] : bytes[0] < 32 ? bytes[0] + 96 : bytes[0];
+						}
+						nextCode = CODE128.next(bytes, pos + 1, set);
+					}
+			}
+			// Continue encoding
+			else {
+					index = CODE128.correctIndex(bytes, set);
+					nextCode = CODE128.next(bytes, pos + 1, set);
+				}
+
+			// Get the correct binary encoding and calculate the weight
+			var enc = CODE128.getBar(index);
+			var weight = index * pos;
+
+			return {
+				result: enc + nextCode.result,
+				checksum: weight + nextCode.checksum
+			};
+		}
+	}]);
+
+	return CODE128;
+}(_Barcode3.default);
+
+exports.default = CODE128;

+ 42 - 0
components/tki-barcode/barcodes/CODE128/CODE128A.js

@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _CODE2 = require('./CODE128.js');
+
+var _CODE3 = _interopRequireDefault(_CODE2);
+
+var _constants = require('./constants');
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var CODE128A = function (_CODE) {
+	_inherits(CODE128A, _CODE);
+
+	function CODE128A(string, options) {
+		_classCallCheck(this, CODE128A);
+
+		return _possibleConstructorReturn(this, (CODE128A.__proto__ || Object.getPrototypeOf(CODE128A)).call(this, _constants.A_START_CHAR + string, options));
+	}
+
+	_createClass(CODE128A, [{
+		key: 'valid',
+		value: function valid() {
+			return new RegExp('^' + _constants.A_CHARS + '+$').test(this.data);
+		}
+	}]);
+
+	return CODE128A;
+}(_CODE3.default);
+
+exports.default = CODE128A;

+ 42 - 0
components/tki-barcode/barcodes/CODE128/CODE128B.js

@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _CODE2 = require('./CODE128.js');
+
+var _CODE3 = _interopRequireDefault(_CODE2);
+
+var _constants = require('./constants');
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var CODE128B = function (_CODE) {
+	_inherits(CODE128B, _CODE);
+
+	function CODE128B(string, options) {
+		_classCallCheck(this, CODE128B);
+
+		return _possibleConstructorReturn(this, (CODE128B.__proto__ || Object.getPrototypeOf(CODE128B)).call(this, _constants.B_START_CHAR + string, options));
+	}
+
+	_createClass(CODE128B, [{
+		key: 'valid',
+		value: function valid() {
+			return new RegExp('^' + _constants.B_CHARS + '+$').test(this.data);
+		}
+	}]);
+
+	return CODE128B;
+}(_CODE3.default);
+
+exports.default = CODE128B;

+ 42 - 0
components/tki-barcode/barcodes/CODE128/CODE128C.js

@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _CODE2 = require('./CODE128.js');
+
+var _CODE3 = _interopRequireDefault(_CODE2);
+
+var _constants = require('./constants');
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var CODE128C = function (_CODE) {
+	_inherits(CODE128C, _CODE);
+
+	function CODE128C(string, options) {
+		_classCallCheck(this, CODE128C);
+
+		return _possibleConstructorReturn(this, (CODE128C.__proto__ || Object.getPrototypeOf(CODE128C)).call(this, _constants.C_START_CHAR + string, options));
+	}
+
+	_createClass(CODE128C, [{
+		key: 'valid',
+		value: function valid() {
+			return new RegExp('^' + _constants.C_CHARS + '+$').test(this.data);
+		}
+	}]);
+
+	return CODE128C;
+}(_CODE3.default);
+
+exports.default = CODE128C;

+ 41 - 0
components/tki-barcode/barcodes/CODE128/CODE128_AUTO.js

@@ -0,0 +1,41 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _CODE2 = require('./CODE128');
+
+var _CODE3 = _interopRequireDefault(_CODE2);
+
+var _auto = require('./auto');
+
+var _auto2 = _interopRequireDefault(_auto);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var CODE128AUTO = function (_CODE) {
+	_inherits(CODE128AUTO, _CODE);
+
+	function CODE128AUTO(data, options) {
+		_classCallCheck(this, CODE128AUTO);
+
+		// ASCII value ranges 0-127, 200-211
+		if (/^[\x00-\x7F\xC8-\xD3]+$/.test(data)) {
+			var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, (0, _auto2.default)(data), options));
+		} else {
+			var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, data, options));
+		}
+		return _possibleConstructorReturn(_this);
+	}
+
+	return CODE128AUTO;
+}(_CODE3.default);
+
+exports.default = CODE128AUTO;

+ 73 - 0
components/tki-barcode/barcodes/CODE128/auto.js

@@ -0,0 +1,73 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _constants = require('./constants');
+
+// Match Set functions
+var matchSetALength = function matchSetALength(string) {
+	return string.match(new RegExp('^' + _constants.A_CHARS + '*'))[0].length;
+};
+var matchSetBLength = function matchSetBLength(string) {
+	return string.match(new RegExp('^' + _constants.B_CHARS + '*'))[0].length;
+};
+var matchSetC = function matchSetC(string) {
+	return string.match(new RegExp('^' + _constants.C_CHARS + '*'))[0];
+};
+
+// CODE128A or CODE128B
+function autoSelectFromAB(string, isA) {
+	var ranges = isA ? _constants.A_CHARS : _constants.B_CHARS;
+	var untilC = string.match(new RegExp('^(' + ranges + '+?)(([0-9]{2}){2,})([^0-9]|$)'));
+
+	if (untilC) {
+		return untilC[1] + String.fromCharCode(204) + autoSelectFromC(string.substring(untilC[1].length));
+	}
+
+	var chars = string.match(new RegExp('^' + ranges + '+'))[0];
+
+	if (chars.length === string.length) {
+		return string;
+	}
+
+	return chars + String.fromCharCode(isA ? 205 : 206) + autoSelectFromAB(string.substring(chars.length), !isA);
+}
+
+// CODE128C
+function autoSelectFromC(string) {
+	var cMatch = matchSetC(string);
+	var length = cMatch.length;
+
+	if (length === string.length) {
+		return string;
+	}
+
+	string = string.substring(length);
+
+	// Select A/B depending on the longest match
+	var isA = matchSetALength(string) >= matchSetBLength(string);
+	return cMatch + String.fromCharCode(isA ? 206 : 205) + autoSelectFromAB(string, isA);
+}
+
+// Detect Code Set (A, B or C) and format the string
+
+exports.default = function (string) {
+	var newString = void 0;
+	var cLength = matchSetC(string).length;
+
+	// Select 128C if the string start with enough digits
+	if (cLength >= 2) {
+		newString = _constants.C_START_CHAR + autoSelectFromC(string);
+	} else {
+		// Select A/B depending on the longest match
+		var isA = matchSetALength(string) > matchSetBLength(string);
+		newString = (isA ? _constants.A_START_CHAR : _constants.B_START_CHAR) + autoSelectFromAB(string, isA);
+	}
+
+	return newString.replace(/[\xCD\xCE]([^])[\xCD\xCE]/, // Any sequence between 205 and 206 characters
+	function (match, char) {
+		return String.fromCharCode(203) + char;
+	});
+};

+ 54 - 0
components/tki-barcode/barcodes/CODE128/constants.js

@@ -0,0 +1,54 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _SET_BY_CODE;
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+// constants for internal usage
+var SET_A = exports.SET_A = 0;
+var SET_B = exports.SET_B = 1;
+var SET_C = exports.SET_C = 2;
+
+// Special characters
+var SHIFT = exports.SHIFT = 98;
+var START_A = exports.START_A = 103;
+var START_B = exports.START_B = 104;
+var START_C = exports.START_C = 105;
+var MODULO = exports.MODULO = 103;
+var STOP = exports.STOP = 106;
+var FNC1 = exports.FNC1 = 207;
+
+// Get set by start code
+var SET_BY_CODE = exports.SET_BY_CODE = (_SET_BY_CODE = {}, _defineProperty(_SET_BY_CODE, START_A, SET_A), _defineProperty(_SET_BY_CODE, START_B, SET_B), _defineProperty(_SET_BY_CODE, START_C, SET_C), _SET_BY_CODE);
+
+// Get next set by code
+var SWAP = exports.SWAP = {
+	101: SET_A,
+	100: SET_B,
+	99: SET_C
+};
+
+var A_START_CHAR = exports.A_START_CHAR = String.fromCharCode(208); // START_A + 105
+var B_START_CHAR = exports.B_START_CHAR = String.fromCharCode(209); // START_B + 105
+var C_START_CHAR = exports.C_START_CHAR = String.fromCharCode(210); // START_C + 105
+
+// 128A (Code Set A)
+// ASCII characters 00 to 95 (0–9, A–Z and control codes), special characters, and FNC 1–4
+var A_CHARS = exports.A_CHARS = "[\x00-\x5F\xC8-\xCF]";
+
+// 128B (Code Set B)
+// ASCII characters 32 to 127 (0–9, A–Z, a–z), special characters, and FNC 1–4
+var B_CHARS = exports.B_CHARS = "[\x20-\x7F\xC8-\xCF]";
+
+// 128C (Code Set C)
+// 00–99 (encodes two digits with a single code point) and FNC1
+var C_CHARS = exports.C_CHARS = "(\xCF*[0-9]{2}\xCF*)";
+
+// CODE128 includes 107 symbols:
+// 103 data symbols, 3 start symbols (A, B and C), and 1 stop symbol (the last one)
+// Each symbol consist of three black bars (1) and three white spaces (0).
+var BARS = exports.BARS = [11011001100, 11001101100, 11001100110, 10010011000, 10010001100, 10001001100, 10011001000, 10011000100, 10001100100, 11001001000, 11001000100, 11000100100, 10110011100, 10011011100, 10011001110, 10111001100, 10011101100, 10011100110, 11001110010, 11001011100, 11001001110, 11011100100, 11001110100, 11101101110, 11101001100, 11100101100, 11100100110, 11101100100, 11100110100, 11100110010, 11011011000, 11011000110, 11000110110, 10100011000, 10001011000, 10001000110, 10110001000, 10001101000, 10001100010, 11010001000, 11000101000, 11000100010, 10110111000, 10110001110, 10001101110, 10111011000, 10111000110, 10001110110, 11101110110, 11010001110, 11000101110, 11011101000, 11011100010, 11011101110, 11101011000, 11101000110, 11100010110, 11101101000, 11101100010, 11100011010, 11101111010, 11001000010, 11110001010, 10100110000, 10100001100, 10010110000, 10010000110, 10000101100, 10000100110, 10110010000, 10110000100, 10011010000, 10011000010, 10000110100, 10000110010, 11000010010, 11001010000, 11110111010, 11000010100, 10001111010, 10100111100, 10010111100, 10010011110, 10111100100, 10011110100, 10011110010, 11110100100, 11110010100, 11110010010, 11011011110, 11011110110, 11110110110, 10101111000, 10100011110, 10001011110, 10111101000, 10111100010, 11110101000, 11110100010, 10111011110, 10111101110, 11101011110, 11110101110, 11010000100, 11010010000, 11010011100, 1100011101011];

+ 29 - 0
components/tki-barcode/barcodes/CODE128/index.js

@@ -0,0 +1,29 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.CODE128C = exports.CODE128B = exports.CODE128A = exports.CODE128 = undefined;
+
+var _CODE128_AUTO = require('./CODE128_AUTO.js');
+
+var _CODE128_AUTO2 = _interopRequireDefault(_CODE128_AUTO);
+
+var _CODE128A = require('./CODE128A.js');
+
+var _CODE128A2 = _interopRequireDefault(_CODE128A);
+
+var _CODE128B = require('./CODE128B.js');
+
+var _CODE128B2 = _interopRequireDefault(_CODE128B);
+
+var _CODE128C = require('./CODE128C.js');
+
+var _CODE128C2 = _interopRequireDefault(_CODE128C);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+exports.CODE128 = _CODE128_AUTO2.default;
+exports.CODE128A = _CODE128A2.default;
+exports.CODE128B = _CODE128B2.default;
+exports.CODE128C = _CODE128C2.default;

+ 104 - 0
components/tki-barcode/barcodes/CODE39/index.js

@@ -0,0 +1,104 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+exports.CODE39 = undefined;
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _Barcode2 = require("../Barcode.js");
+
+var _Barcode3 = _interopRequireDefault(_Barcode2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
+// https://en.wikipedia.org/wiki/Code_39#Encoding
+
+var CODE39 = function (_Barcode) {
+	_inherits(CODE39, _Barcode);
+
+	function CODE39(data, options) {
+		_classCallCheck(this, CODE39);
+
+		data = data.toUpperCase();
+
+		// Calculate mod43 checksum if enabled
+		if (options.mod43) {
+			data += getCharacter(mod43checksum(data));
+		}
+
+		return _possibleConstructorReturn(this, (CODE39.__proto__ || Object.getPrototypeOf(CODE39)).call(this, data, options));
+	}
+
+	_createClass(CODE39, [{
+		key: "encode",
+		value: function encode() {
+			// First character is always a *
+			var result = getEncoding("*");
+
+			// Take every character and add the binary representation to the result
+			for (var i = 0; i < this.data.length; i++) {
+				result += getEncoding(this.data[i]) + "0";
+			}
+
+			// Last character is always a *
+			result += getEncoding("*");
+			return {
+				data: result,
+				text: this.text
+			};
+		}
+	}, {
+		key: "valid",
+		value: function valid() {
+			return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/) !== -1;
+		}
+	}]);
+
+	return CODE39;
+}(_Barcode3.default);
+
+// All characters. The position in the array is the (checksum) value
+
+
+var characters = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "-", ".", " ", "$", "/", "+", "%", "*"];
+
+// The decimal representation of the characters, is converted to the
+// corresponding binary with the getEncoding function
+var encodings = [20957, 29783, 23639, 30485, 20951, 29813, 23669, 20855, 29789, 23645, 29975, 23831, 30533, 22295, 30149, 24005, 21623, 29981, 23837, 22301, 30023, 23879, 30545, 22343, 30161, 24017, 21959, 30065, 23921, 22385, 29015, 18263, 29141, 17879, 29045, 18293, 17783, 29021, 18269, 17477, 17489, 17681, 20753, 35770];
+
+// Get the binary representation of a character by converting the encodings
+// from decimal to binary
+function getEncoding(character) {
+	return getBinary(characterValue(character));
+}
+
+function getBinary(characterValue) {
+	return encodings[characterValue].toString(2);
+}
+
+function getCharacter(characterValue) {
+	return characters[characterValue];
+}
+
+function characterValue(character) {
+	return characters.indexOf(character);
+}
+
+function mod43checksum(data) {
+	var checksum = 0;
+	for (var i = 0; i < data.length; i++) {
+		checksum += characterValue(data[i]);
+	}
+
+	checksum = checksum % 43;
+	return checksum;
+}
+
+exports.CODE39 = CODE39;

+ 92 - 0
components/tki-barcode/barcodes/EAN_UPC/EAN.js

@@ -0,0 +1,92 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _constants = require('./constants');
+
+var _encoder = require('./encoder');
+
+var _encoder2 = _interopRequireDefault(_encoder);
+
+var _Barcode2 = require('../Barcode');
+
+var _Barcode3 = _interopRequireDefault(_Barcode2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+// Base class for EAN8 & EAN13
+var EAN = function (_Barcode) {
+	_inherits(EAN, _Barcode);
+
+	function EAN(data, options) {
+		_classCallCheck(this, EAN);
+
+		// Make sure the font is not bigger than the space between the guard bars
+		var _this = _possibleConstructorReturn(this, (EAN.__proto__ || Object.getPrototypeOf(EAN)).call(this, data, options));
+
+		_this.fontSize = !options.flat && options.fontSize > options.width * 10 ? options.width * 10 : options.fontSize;
+
+		// Make the guard bars go down half the way of the text
+		_this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
+		return _this;
+	}
+
+	_createClass(EAN, [{
+		key: 'encode',
+		value: function encode() {
+			return this.options.flat ? this.encodeFlat() : this.encodeGuarded();
+		}
+	}, {
+		key: 'leftText',
+		value: function leftText(from, to) {
+			return this.text.substr(from, to);
+		}
+	}, {
+		key: 'leftEncode',
+		value: function leftEncode(data, structure) {
+			return (0, _encoder2.default)(data, structure);
+		}
+	}, {
+		key: 'rightText',
+		value: function rightText(from, to) {
+			return this.text.substr(from, to);
+		}
+	}, {
+		key: 'rightEncode',
+		value: function rightEncode(data, structure) {
+			return (0, _encoder2.default)(data, structure);
+		}
+	}, {
+		key: 'encodeGuarded',
+		value: function encodeGuarded() {
+			var textOptions = { fontSize: this.fontSize };
+			var guardOptions = { height: this.guardHeight };
+
+			return [{ data: _constants.SIDE_BIN, options: guardOptions }, { data: this.leftEncode(), text: this.leftText(), options: textOptions }, { data: _constants.MIDDLE_BIN, options: guardOptions }, { data: this.rightEncode(), text: this.rightText(), options: textOptions }, { data: _constants.SIDE_BIN, options: guardOptions }];
+		}
+	}, {
+		key: 'encodeFlat',
+		value: function encodeFlat() {
+			var data = [_constants.SIDE_BIN, this.leftEncode(), _constants.MIDDLE_BIN, this.rightEncode(), _constants.SIDE_BIN];
+
+			return {
+				data: data.join(''),
+				text: this.text
+			};
+		}
+	}]);
+
+	return EAN;
+}(_Barcode3.default);
+
+exports.default = EAN;

+ 119 - 0
components/tki-barcode/barcodes/EAN_UPC/EAN13.js

@@ -0,0 +1,119 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
+
+var _constants = require('./constants');
+
+var _EAN2 = require('./EAN');
+
+var _EAN3 = _interopRequireDefault(_EAN2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
+// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Binary_encoding_of_data_digits_into_EAN-13_barcode
+
+// Calculate the checksum digit
+// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
+var checksum = function checksum(number) {
+	var res = number.substr(0, 12).split('').map(function (n) {
+		return +n;
+	}).reduce(function (sum, a, idx) {
+		return idx % 2 ? sum + a * 3 : sum + a;
+	}, 0);
+
+	return (10 - res % 10) % 10;
+};
+
+var EAN13 = function (_EAN) {
+	_inherits(EAN13, _EAN);
+
+	function EAN13(data, options) {
+		_classCallCheck(this, EAN13);
+
+		// Add checksum if it does not exist
+		if (data.search(/^[0-9]{12}$/) !== -1) {
+			data += checksum(data);
+		}
+
+		// Adds a last character to the end of the barcode
+		var _this = _possibleConstructorReturn(this, (EAN13.__proto__ || Object.getPrototypeOf(EAN13)).call(this, data, options));
+
+		_this.lastChar = options.lastChar;
+		return _this;
+	}
+
+	_createClass(EAN13, [{
+		key: 'valid',
+		value: function valid() {
+			return this.data.search(/^[0-9]{13}$/) !== -1 && +this.data[12] === checksum(this.data);
+		}
+	}, {
+		key: 'leftText',
+		value: function leftText() {
+			return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'leftText', this).call(this, 1, 6);
+		}
+	}, {
+		key: 'leftEncode',
+		value: function leftEncode() {
+			var data = this.data.substr(1, 6);
+			var structure = _constants.EAN13_STRUCTURE[this.data[0]];
+			return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'leftEncode', this).call(this, data, structure);
+		}
+	}, {
+		key: 'rightText',
+		value: function rightText() {
+			return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightText', this).call(this, 7, 6);
+		}
+	}, {
+		key: 'rightEncode',
+		value: function rightEncode() {
+			var data = this.data.substr(7, 6);
+			return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightEncode', this).call(this, data, 'RRRRRR');
+		}
+
+		// The "standard" way of printing EAN13 barcodes with guard bars
+
+	}, {
+		key: 'encodeGuarded',
+		value: function encodeGuarded() {
+			var data = _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'encodeGuarded', this).call(this);
+
+			// Extend data with left digit & last character
+			if (this.options.displayValue) {
+				data.unshift({
+					data: '000000000000',
+					text: this.text.substr(0, 1),
+					options: { textAlign: 'left', fontSize: this.fontSize }
+				});
+
+				if (this.options.lastChar) {
+					data.push({
+						data: '00'
+					});
+					data.push({
+						data: '00000',
+						text: this.options.lastChar,
+						options: { fontSize: this.fontSize }
+					});
+				}
+			}
+
+			return data;
+		}
+	}]);
+
+	return EAN13;
+}(_EAN3.default);
+
+exports.default = EAN13;

+ 58 - 0
components/tki-barcode/barcodes/EAN_UPC/EAN2.js

@@ -0,0 +1,58 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _constants = require('./constants');
+
+var _encoder = require('./encoder');
+
+var _encoder2 = _interopRequireDefault(_encoder);
+
+var _Barcode2 = require('../Barcode');
+
+var _Barcode3 = _interopRequireDefault(_Barcode2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
+// https://en.wikipedia.org/wiki/EAN_2#Encoding
+
+var EAN2 = function (_Barcode) {
+	_inherits(EAN2, _Barcode);
+
+	function EAN2(data, options) {
+		_classCallCheck(this, EAN2);
+
+		return _possibleConstructorReturn(this, (EAN2.__proto__ || Object.getPrototypeOf(EAN2)).call(this, data, options));
+	}
+
+	_createClass(EAN2, [{
+		key: 'valid',
+		value: function valid() {
+			return this.data.search(/^[0-9]{2}$/) !== -1;
+		}
+	}, {
+		key: 'encode',
+		value: function encode() {
+			// Choose the structure based on the number mod 4
+			var structure = _constants.EAN2_STRUCTURE[parseInt(this.data) % 4];
+			return {
+				// Start bits + Encode the two digits with 01 in between
+				data: '1011' + (0, _encoder2.default)(this.data, structure, '01'),
+				text: this.text
+			};
+		}
+	}]);
+
+	return EAN2;
+}(_Barcode3.default);
+
+exports.default = EAN2;

+ 65 - 0
components/tki-barcode/barcodes/EAN_UPC/EAN5.js

@@ -0,0 +1,65 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _constants = require('./constants');
+
+var _encoder = require('./encoder');
+
+var _encoder2 = _interopRequireDefault(_encoder);
+
+var _Barcode2 = require('../Barcode');
+
+var _Barcode3 = _interopRequireDefault(_Barcode2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
+// https://en.wikipedia.org/wiki/EAN_5#Encoding
+
+var checksum = function checksum(data) {
+	var result = data.split('').map(function (n) {
+		return +n;
+	}).reduce(function (sum, a, idx) {
+		return idx % 2 ? sum + a * 9 : sum + a * 3;
+	}, 0);
+	return result % 10;
+};
+
+var EAN5 = function (_Barcode) {
+	_inherits(EAN5, _Barcode);
+
+	function EAN5(data, options) {
+		_classCallCheck(this, EAN5);
+
+		return _possibleConstructorReturn(this, (EAN5.__proto__ || Object.getPrototypeOf(EAN5)).call(this, data, options));
+	}
+
+	_createClass(EAN5, [{
+		key: 'valid',
+		value: function valid() {
+			return this.data.search(/^[0-9]{5}$/) !== -1;
+		}
+	}, {
+		key: 'encode',
+		value: function encode() {
+			var structure = _constants.EAN5_STRUCTURE[checksum(this.data)];
+			return {
+				data: '1011' + (0, _encoder2.default)(this.data, structure, '01'),
+				text: this.text
+			};
+		}
+	}]);
+
+	return EAN5;
+}(_Barcode3.default);
+
+exports.default = EAN5;

+ 81 - 0
components/tki-barcode/barcodes/EAN_UPC/EAN8.js

@@ -0,0 +1,81 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
+
+var _EAN2 = require('./EAN');
+
+var _EAN3 = _interopRequireDefault(_EAN2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
+// http://www.barcodeisland.com/ean8.phtml
+
+// Calculate the checksum digit
+var checksum = function checksum(number) {
+	var res = number.substr(0, 7).split('').map(function (n) {
+		return +n;
+	}).reduce(function (sum, a, idx) {
+		return idx % 2 ? sum + a : sum + a * 3;
+	}, 0);
+
+	return (10 - res % 10) % 10;
+};
+
+var EAN8 = function (_EAN) {
+	_inherits(EAN8, _EAN);
+
+	function EAN8(data, options) {
+		_classCallCheck(this, EAN8);
+
+		// Add checksum if it does not exist
+		if (data.search(/^[0-9]{7}$/) !== -1) {
+			data += checksum(data);
+		}
+
+		return _possibleConstructorReturn(this, (EAN8.__proto__ || Object.getPrototypeOf(EAN8)).call(this, data, options));
+	}
+
+	_createClass(EAN8, [{
+		key: 'valid',
+		value: function valid() {
+			return this.data.search(/^[0-9]{8}$/) !== -1 && +this.data[7] === checksum(this.data);
+		}
+	}, {
+		key: 'leftText',
+		value: function leftText() {
+			return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'leftText', this).call(this, 0, 4);
+		}
+	}, {
+		key: 'leftEncode',
+		value: function leftEncode() {
+			var data = this.data.substr(0, 4);
+			return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'leftEncode', this).call(this, data, 'LLLL');
+		}
+	}, {
+		key: 'rightText',
+		value: function rightText() {
+			return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'rightText', this).call(this, 4, 4);
+		}
+	}, {
+		key: 'rightEncode',
+		value: function rightEncode() {
+			var data = this.data.substr(4, 4);
+			return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'rightEncode', this).call(this, data, 'RRRR');
+		}
+	}]);
+
+	return EAN8;
+}(_EAN3.default);
+
+exports.default = EAN8;

+ 165 - 0
components/tki-barcode/barcodes/EAN_UPC/UPC.js

@@ -0,0 +1,165 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+exports.checksum = checksum;
+
+var _encoder = require("./encoder");
+
+var _encoder2 = _interopRequireDefault(_encoder);
+
+var _Barcode2 = require("../Barcode.js");
+
+var _Barcode3 = _interopRequireDefault(_Barcode2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
+// https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
+
+var UPC = function (_Barcode) {
+	_inherits(UPC, _Barcode);
+
+	function UPC(data, options) {
+		_classCallCheck(this, UPC);
+
+		// Add checksum if it does not exist
+		if (data.search(/^[0-9]{11}$/) !== -1) {
+			data += checksum(data);
+		}
+
+		var _this = _possibleConstructorReturn(this, (UPC.__proto__ || Object.getPrototypeOf(UPC)).call(this, data, options));
+
+		_this.displayValue = options.displayValue;
+
+		// Make sure the font is not bigger than the space between the guard bars
+		if (options.fontSize > options.width * 10) {
+			_this.fontSize = options.width * 10;
+		} else {
+			_this.fontSize = options.fontSize;
+		}
+
+		// Make the guard bars go down half the way of the text
+		_this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
+		return _this;
+	}
+
+	_createClass(UPC, [{
+		key: "valid",
+		value: function valid() {
+			return this.data.search(/^[0-9]{12}$/) !== -1 && this.data[11] == checksum(this.data);
+		}
+	}, {
+		key: "encode",
+		value: function encode() {
+			if (this.options.flat) {
+				return this.flatEncoding();
+			} else {
+				return this.guardedEncoding();
+			}
+		}
+	}, {
+		key: "flatEncoding",
+		value: function flatEncoding() {
+			var result = "";
+
+			result += "101";
+			result += (0, _encoder2.default)(this.data.substr(0, 6), "LLLLLL");
+			result += "01010";
+			result += (0, _encoder2.default)(this.data.substr(6, 6), "RRRRRR");
+			result += "101";
+
+			return {
+				data: result,
+				text: this.text
+			};
+		}
+	}, {
+		key: "guardedEncoding",
+		value: function guardedEncoding() {
+			var result = [];
+
+			// Add the first digit
+			if (this.displayValue) {
+				result.push({
+					data: "00000000",
+					text: this.text.substr(0, 1),
+					options: { textAlign: "left", fontSize: this.fontSize }
+				});
+			}
+
+			// Add the guard bars
+			result.push({
+				data: "101" + (0, _encoder2.default)(this.data[0], "L"),
+				options: { height: this.guardHeight }
+			});
+
+			// Add the left side
+			result.push({
+				data: (0, _encoder2.default)(this.data.substr(1, 5), "LLLLL"),
+				text: this.text.substr(1, 5),
+				options: { fontSize: this.fontSize }
+			});
+
+			// Add the middle bits
+			result.push({
+				data: "01010",
+				options: { height: this.guardHeight }
+			});
+
+			// Add the right side
+			result.push({
+				data: (0, _encoder2.default)(this.data.substr(6, 5), "RRRRR"),
+				text: this.text.substr(6, 5),
+				options: { fontSize: this.fontSize }
+			});
+
+			// Add the end bits
+			result.push({
+				data: (0, _encoder2.default)(this.data[11], "R") + "101",
+				options: { height: this.guardHeight }
+			});
+
+			// Add the last digit
+			if (this.displayValue) {
+				result.push({
+					data: "00000000",
+					text: this.text.substr(11, 1),
+					options: { textAlign: "right", fontSize: this.fontSize }
+				});
+			}
+
+			return result;
+		}
+	}]);
+
+	return UPC;
+}(_Barcode3.default);
+
+// Calulate the checksum digit
+// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
+
+
+function checksum(number) {
+	var result = 0;
+
+	var i;
+	for (i = 1; i < 11; i += 2) {
+		result += parseInt(number[i]);
+	}
+	for (i = 0; i < 11; i += 2) {
+		result += parseInt(number[i]) * 3;
+	}
+
+	return (10 - result % 10) % 10;
+}
+
+exports.default = UPC;

+ 185 - 0
components/tki-barcode/barcodes/EAN_UPC/UPCE.js

@@ -0,0 +1,185 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _encoder = require('./encoder');
+
+var _encoder2 = _interopRequireDefault(_encoder);
+
+var _Barcode2 = require('../Barcode.js');
+
+var _Barcode3 = _interopRequireDefault(_Barcode2);
+
+var _UPC = require('./UPC.js');
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
+// https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
+//
+// UPC-E documentation:
+// https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E
+
+var EXPANSIONS = ["XX00000XXX", "XX10000XXX", "XX20000XXX", "XXX00000XX", "XXXX00000X", "XXXXX00005", "XXXXX00006", "XXXXX00007", "XXXXX00008", "XXXXX00009"];
+
+var PARITIES = [["EEEOOO", "OOOEEE"], ["EEOEOO", "OOEOEE"], ["EEOOEO", "OOEEOE"], ["EEOOOE", "OOEEEO"], ["EOEEOO", "OEOOEE"], ["EOOEEO", "OEEOOE"], ["EOOOEE", "OEEEOO"], ["EOEOEO", "OEOEOE"], ["EOEOOE", "OEOEEO"], ["EOOEOE", "OEEOEO"]];
+
+var UPCE = function (_Barcode) {
+	_inherits(UPCE, _Barcode);
+
+	function UPCE(data, options) {
+		_classCallCheck(this, UPCE);
+
+		var _this = _possibleConstructorReturn(this, (UPCE.__proto__ || Object.getPrototypeOf(UPCE)).call(this, data, options));
+		// Code may be 6 or 8 digits;
+		// A 7 digit code is ambiguous as to whether the extra digit
+		// is a UPC-A check or number system digit.
+
+
+		_this.isValid = false;
+		if (data.search(/^[0-9]{6}$/) !== -1) {
+			_this.middleDigits = data;
+			_this.upcA = expandToUPCA(data, "0");
+			_this.text = options.text || '' + _this.upcA[0] + data + _this.upcA[_this.upcA.length - 1];
+			_this.isValid = true;
+		} else if (data.search(/^[01][0-9]{7}$/) !== -1) {
+			_this.middleDigits = data.substring(1, data.length - 1);
+			_this.upcA = expandToUPCA(_this.middleDigits, data[0]);
+
+			if (_this.upcA[_this.upcA.length - 1] === data[data.length - 1]) {
+				_this.isValid = true;
+			} else {
+				// checksum mismatch
+				return _possibleConstructorReturn(_this);
+			}
+		} else {
+			return _possibleConstructorReturn(_this);
+		}
+
+		_this.displayValue = options.displayValue;
+
+		// Make sure the font is not bigger than the space between the guard bars
+		if (options.fontSize > options.width * 10) {
+			_this.fontSize = options.width * 10;
+		} else {
+			_this.fontSize = options.fontSize;
+		}
+
+		// Make the guard bars go down half the way of the text
+		_this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
+		return _this;
+	}
+
+	_createClass(UPCE, [{
+		key: 'valid',
+		value: function valid() {
+			return this.isValid;
+		}
+	}, {
+		key: 'encode',
+		value: function encode() {
+			if (this.options.flat) {
+				return this.flatEncoding();
+			} else {
+				return this.guardedEncoding();
+			}
+		}
+	}, {
+		key: 'flatEncoding',
+		value: function flatEncoding() {
+			var result = "";
+
+			result += "101";
+			result += this.encodeMiddleDigits();
+			result += "010101";
+
+			return {
+				data: result,
+				text: this.text
+			};
+		}
+	}, {
+		key: 'guardedEncoding',
+		value: function guardedEncoding() {
+			var result = [];
+
+			// Add the UPC-A number system digit beneath the quiet zone
+			if (this.displayValue) {
+				result.push({
+					data: "00000000",
+					text: this.text[0],
+					options: { textAlign: "left", fontSize: this.fontSize }
+				});
+			}
+
+			// Add the guard bars
+			result.push({
+				data: "101",
+				options: { height: this.guardHeight }
+			});
+
+			// Add the 6 UPC-E digits
+			result.push({
+				data: this.encodeMiddleDigits(),
+				text: this.text.substring(1, 7),
+				options: { fontSize: this.fontSize }
+			});
+
+			// Add the end bits
+			result.push({
+				data: "010101",
+				options: { height: this.guardHeight }
+			});
+
+			// Add the UPC-A check digit beneath the quiet zone
+			if (this.displayValue) {
+				result.push({
+					data: "00000000",
+					text: this.text[7],
+					options: { textAlign: "right", fontSize: this.fontSize }
+				});
+			}
+
+			return result;
+		}
+	}, {
+		key: 'encodeMiddleDigits',
+		value: function encodeMiddleDigits() {
+			var numberSystem = this.upcA[0];
+			var checkDigit = this.upcA[this.upcA.length - 1];
+			var parity = PARITIES[parseInt(checkDigit)][parseInt(numberSystem)];
+			return (0, _encoder2.default)(this.middleDigits, parity);
+		}
+	}]);
+
+	return UPCE;
+}(_Barcode3.default);
+
+function expandToUPCA(middleDigits, numberSystem) {
+	var lastUpcE = parseInt(middleDigits[middleDigits.length - 1]);
+	var expansion = EXPANSIONS[lastUpcE];
+
+	var result = "";
+	var digitIndex = 0;
+	for (var i = 0; i < expansion.length; i++) {
+		var c = expansion[i];
+		if (c === 'X') {
+			result += middleDigits[digitIndex++];
+		} else {
+			result += c;
+		}
+	}
+
+	result = '' + numberSystem + result;
+	return '' + result + (0, _UPC.checksum)(result);
+}
+
+exports.default = UPCE;

+ 30 - 0
components/tki-barcode/barcodes/EAN_UPC/constants.js

@@ -0,0 +1,30 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+// Standard start end and middle bits
+var SIDE_BIN = exports.SIDE_BIN = '101';
+var MIDDLE_BIN = exports.MIDDLE_BIN = '01010';
+
+var BINARIES = exports.BINARIES = {
+	'L': [// The L (left) type of encoding
+	'0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'],
+	'G': [// The G type of encoding
+	'0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111'],
+	'R': [// The R (right) type of encoding
+	'1110010', '1100110', '1101100', '1000010', '1011100', '1001110', '1010000', '1000100', '1001000', '1110100'],
+	'O': [// The O (odd) encoding for UPC-E
+	'0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'],
+	'E': [// The E (even) encoding for UPC-E
+	'0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111']
+};
+
+// Define the EAN-2 structure
+var EAN2_STRUCTURE = exports.EAN2_STRUCTURE = ['LL', 'LG', 'GL', 'GG'];
+
+// Define the EAN-5 structure
+var EAN5_STRUCTURE = exports.EAN5_STRUCTURE = ['GGLLL', 'GLGLL', 'GLLGL', 'GLLLG', 'LGGLL', 'LLGGL', 'LLLGG', 'LGLGL', 'LGLLG', 'LLGLG'];
+
+// Define the EAN-13 structure
+var EAN13_STRUCTURE = exports.EAN13_STRUCTURE = ['LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL'];

+ 27 - 0
components/tki-barcode/barcodes/EAN_UPC/encoder.js

@@ -0,0 +1,27 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _constants = require('./constants');
+
+// Encode data string
+var encode = function encode(data, structure, separator) {
+	var encoded = data.split('').map(function (val, idx) {
+		return _constants.BINARIES[structure[idx]];
+	}).map(function (val, idx) {
+		return val ? val[data[idx]] : '';
+	});
+
+	if (separator) {
+		var last = data.length - 1;
+		encoded = encoded.map(function (val, idx) {
+			return idx < last ? val + separator : val;
+		});
+	}
+
+	return encoded.join('');
+};
+
+exports.default = encode;

+ 39 - 0
components/tki-barcode/barcodes/EAN_UPC/index.js

@@ -0,0 +1,39 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.UPCE = exports.UPC = exports.EAN2 = exports.EAN5 = exports.EAN8 = exports.EAN13 = undefined;
+
+var _EAN = require('./EAN13.js');
+
+var _EAN2 = _interopRequireDefault(_EAN);
+
+var _EAN3 = require('./EAN8.js');
+
+var _EAN4 = _interopRequireDefault(_EAN3);
+
+var _EAN5 = require('./EAN5.js');
+
+var _EAN6 = _interopRequireDefault(_EAN5);
+
+var _EAN7 = require('./EAN2.js');
+
+var _EAN8 = _interopRequireDefault(_EAN7);
+
+var _UPC = require('./UPC.js');
+
+var _UPC2 = _interopRequireDefault(_UPC);
+
+var _UPCE = require('./UPCE.js');
+
+var _UPCE2 = _interopRequireDefault(_UPCE);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+exports.EAN13 = _EAN2.default;
+exports.EAN8 = _EAN4.default;
+exports.EAN5 = _EAN6.default;
+exports.EAN2 = _EAN8.default;
+exports.UPC = _UPC2.default;
+exports.UPCE = _UPCE2.default;

+ 55 - 0
components/tki-barcode/barcodes/GenericBarcode/index.js

@@ -0,0 +1,55 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+exports.GenericBarcode = undefined;
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _Barcode2 = require("../Barcode.js");
+
+var _Barcode3 = _interopRequireDefault(_Barcode2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var GenericBarcode = function (_Barcode) {
+	_inherits(GenericBarcode, _Barcode);
+
+	function GenericBarcode(data, options) {
+		_classCallCheck(this, GenericBarcode);
+
+		return _possibleConstructorReturn(this, (GenericBarcode.__proto__ || Object.getPrototypeOf(GenericBarcode)).call(this, data, options)); // Sets this.data and this.text
+	}
+
+	// Return the corresponding binary numbers for the data provided
+
+
+	_createClass(GenericBarcode, [{
+		key: "encode",
+		value: function encode() {
+			return {
+				data: "10101010101010101010101010101010101010101",
+				text: this.text
+			};
+		}
+
+		// Resturn true/false if the string provided is valid for this encoder
+
+	}, {
+		key: "valid",
+		value: function valid() {
+			return true;
+		}
+	}]);
+
+	return GenericBarcode;
+}(_Barcode3.default);
+
+exports.GenericBarcode = GenericBarcode;

+ 69 - 0
components/tki-barcode/barcodes/ITF/ITF.js

@@ -0,0 +1,69 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _constants = require('./constants');
+
+var _Barcode2 = require('../Barcode');
+
+var _Barcode3 = _interopRequireDefault(_Barcode2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var ITF = function (_Barcode) {
+	_inherits(ITF, _Barcode);
+
+	function ITF() {
+		_classCallCheck(this, ITF);
+
+		return _possibleConstructorReturn(this, (ITF.__proto__ || Object.getPrototypeOf(ITF)).apply(this, arguments));
+	}
+
+	_createClass(ITF, [{
+		key: 'valid',
+		value: function valid() {
+			return this.data.search(/^([0-9]{2})+$/) !== -1;
+		}
+	}, {
+		key: 'encode',
+		value: function encode() {
+			var _this2 = this;
+
+			// Calculate all the digit pairs
+			var encoded = this.data.match(/.{2}/g).map(function (pair) {
+				return _this2.encodePair(pair);
+			}).join('');
+
+			return {
+				data: _constants.START_BIN + encoded + _constants.END_BIN,
+				text: this.text
+			};
+		}
+
+		// Calculate the data of a number pair
+
+	}, {
+		key: 'encodePair',
+		value: function encodePair(pair) {
+			var second = _constants.BINARIES[pair[1]];
+
+			return _constants.BINARIES[pair[0]].split('').map(function (first, idx) {
+				return (first === '1' ? '111' : '1') + (second[idx] === '1' ? '000' : '0');
+			}).join('');
+		}
+	}]);
+
+	return ITF;
+}(_Barcode3.default);
+
+exports.default = ITF;

+ 55 - 0
components/tki-barcode/barcodes/ITF/ITF14.js

@@ -0,0 +1,55 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _ITF2 = require('./ITF');
+
+var _ITF3 = _interopRequireDefault(_ITF2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+// Calculate the checksum digit
+var checksum = function checksum(data) {
+	var res = data.substr(0, 13).split('').map(function (num) {
+		return parseInt(num, 10);
+	}).reduce(function (sum, n, idx) {
+		return sum + n * (3 - idx % 2 * 2);
+	}, 0);
+
+	return Math.ceil(res / 10) * 10 - res;
+};
+
+var ITF14 = function (_ITF) {
+	_inherits(ITF14, _ITF);
+
+	function ITF14(data, options) {
+		_classCallCheck(this, ITF14);
+
+		// Add checksum if it does not exist
+		if (data.search(/^[0-9]{13}$/) !== -1) {
+			data += checksum(data);
+		}
+		return _possibleConstructorReturn(this, (ITF14.__proto__ || Object.getPrototypeOf(ITF14)).call(this, data, options));
+	}
+
+	_createClass(ITF14, [{
+		key: 'valid',
+		value: function valid() {
+			return this.data.search(/^[0-9]{14}$/) !== -1 && +this.data[13] === checksum(this.data);
+		}
+	}]);
+
+	return ITF14;
+}(_ITF3.default);
+
+exports.default = ITF14;

+ 9 - 0
components/tki-barcode/barcodes/ITF/constants.js

@@ -0,0 +1,9 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+var START_BIN = exports.START_BIN = '1010';
+var END_BIN = exports.END_BIN = '11101';
+
+var BINARIES = exports.BINARIES = ['00110', '10001', '01001', '11000', '00101', '10100', '01100', '00011', '10010', '01010'];

+ 19 - 0
components/tki-barcode/barcodes/ITF/index.js

@@ -0,0 +1,19 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.ITF14 = exports.ITF = undefined;
+
+var _ITF = require('./ITF');
+
+var _ITF2 = _interopRequireDefault(_ITF);
+
+var _ITF3 = require('./ITF14');
+
+var _ITF4 = _interopRequireDefault(_ITF3);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+exports.ITF = _ITF2.default;
+exports.ITF14 = _ITF4.default;

+ 74 - 0
components/tki-barcode/barcodes/MSI/MSI.js

@@ -0,0 +1,74 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _Barcode2 = require("../Barcode.js");
+
+var _Barcode3 = _interopRequireDefault(_Barcode2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation
+// https://en.wikipedia.org/wiki/MSI_Barcode#Character_set_and_binary_lookup
+
+var MSI = function (_Barcode) {
+	_inherits(MSI, _Barcode);
+
+	function MSI(data, options) {
+		_classCallCheck(this, MSI);
+
+		return _possibleConstructorReturn(this, (MSI.__proto__ || Object.getPrototypeOf(MSI)).call(this, data, options));
+	}
+
+	_createClass(MSI, [{
+		key: "encode",
+		value: function encode() {
+			// Start bits
+			var ret = "110";
+
+			for (var i = 0; i < this.data.length; i++) {
+				// Convert the character to binary (always 4 binary digits)
+				var digit = parseInt(this.data[i]);
+				var bin = digit.toString(2);
+				bin = addZeroes(bin, 4 - bin.length);
+
+				// Add 100 for every zero and 110 for every 1
+				for (var b = 0; b < bin.length; b++) {
+					ret += bin[b] == "0" ? "100" : "110";
+				}
+			}
+
+			// End bits
+			ret += "1001";
+
+			return {
+				data: ret,
+				text: this.text
+			};
+		}
+	}, {
+		key: "valid",
+		value: function valid() {
+			return this.data.search(/^[0-9]+$/) !== -1;
+		}
+	}]);
+
+	return MSI;
+}(_Barcode3.default);
+
+function addZeroes(number, n) {
+	for (var i = 0; i < n; i++) {
+		number = "0" + number;
+	}
+	return number;
+}
+
+exports.default = MSI;

+ 33 - 0
components/tki-barcode/barcodes/MSI/MSI10.js

@@ -0,0 +1,33 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _MSI2 = require('./MSI.js');
+
+var _MSI3 = _interopRequireDefault(_MSI2);
+
+var _checksums = require('./checksums.js');
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var MSI10 = function (_MSI) {
+	_inherits(MSI10, _MSI);
+
+	function MSI10(data, options) {
+		_classCallCheck(this, MSI10);
+
+		return _possibleConstructorReturn(this, (MSI10.__proto__ || Object.getPrototypeOf(MSI10)).call(this, data + (0, _checksums.mod10)(data), options));
+	}
+
+	return MSI10;
+}(_MSI3.default);
+
+exports.default = MSI10;

+ 35 - 0
components/tki-barcode/barcodes/MSI/MSI1010.js

@@ -0,0 +1,35 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _MSI2 = require('./MSI.js');
+
+var _MSI3 = _interopRequireDefault(_MSI2);
+
+var _checksums = require('./checksums.js');
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var MSI1010 = function (_MSI) {
+	_inherits(MSI1010, _MSI);
+
+	function MSI1010(data, options) {
+		_classCallCheck(this, MSI1010);
+
+		data += (0, _checksums.mod10)(data);
+		data += (0, _checksums.mod10)(data);
+		return _possibleConstructorReturn(this, (MSI1010.__proto__ || Object.getPrototypeOf(MSI1010)).call(this, data, options));
+	}
+
+	return MSI1010;
+}(_MSI3.default);
+
+exports.default = MSI1010;

+ 33 - 0
components/tki-barcode/barcodes/MSI/MSI11.js

@@ -0,0 +1,33 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _MSI2 = require('./MSI.js');
+
+var _MSI3 = _interopRequireDefault(_MSI2);
+
+var _checksums = require('./checksums.js');
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var MSI11 = function (_MSI) {
+	_inherits(MSI11, _MSI);
+
+	function MSI11(data, options) {
+		_classCallCheck(this, MSI11);
+
+		return _possibleConstructorReturn(this, (MSI11.__proto__ || Object.getPrototypeOf(MSI11)).call(this, data + (0, _checksums.mod11)(data), options));
+	}
+
+	return MSI11;
+}(_MSI3.default);
+
+exports.default = MSI11;

+ 35 - 0
components/tki-barcode/barcodes/MSI/MSI1110.js

@@ -0,0 +1,35 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _MSI2 = require('./MSI.js');
+
+var _MSI3 = _interopRequireDefault(_MSI2);
+
+var _checksums = require('./checksums.js');
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var MSI1110 = function (_MSI) {
+	_inherits(MSI1110, _MSI);
+
+	function MSI1110(data, options) {
+		_classCallCheck(this, MSI1110);
+
+		data += (0, _checksums.mod11)(data);
+		data += (0, _checksums.mod10)(data);
+		return _possibleConstructorReturn(this, (MSI1110.__proto__ || Object.getPrototypeOf(MSI1110)).call(this, data, options));
+	}
+
+	return MSI1110;
+}(_MSI3.default);
+
+exports.default = MSI1110;

+ 29 - 0
components/tki-barcode/barcodes/MSI/checksums.js

@@ -0,0 +1,29 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+exports.mod10 = mod10;
+exports.mod11 = mod11;
+function mod10(number) {
+	var sum = 0;
+	for (var i = 0; i < number.length; i++) {
+		var n = parseInt(number[i]);
+		if ((i + number.length) % 2 === 0) {
+			sum += n;
+		} else {
+			sum += n * 2 % 10 + Math.floor(n * 2 / 10);
+		}
+	}
+	return (10 - sum % 10) % 10;
+}
+
+function mod11(number) {
+	var sum = 0;
+	var weights = [2, 3, 4, 5, 6, 7];
+	for (var i = 0; i < number.length; i++) {
+		var n = parseInt(number[number.length - 1 - i]);
+		sum += weights[i % weights.length] * n;
+	}
+	return (11 - sum % 11) % 11;
+}

+ 34 - 0
components/tki-barcode/barcodes/MSI/index.js

@@ -0,0 +1,34 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.MSI1110 = exports.MSI1010 = exports.MSI11 = exports.MSI10 = exports.MSI = undefined;
+
+var _MSI = require('./MSI.js');
+
+var _MSI2 = _interopRequireDefault(_MSI);
+
+var _MSI3 = require('./MSI10.js');
+
+var _MSI4 = _interopRequireDefault(_MSI3);
+
+var _MSI5 = require('./MSI11.js');
+
+var _MSI6 = _interopRequireDefault(_MSI5);
+
+var _MSI7 = require('./MSI1010.js');
+
+var _MSI8 = _interopRequireDefault(_MSI7);
+
+var _MSI9 = require('./MSI1110.js');
+
+var _MSI10 = _interopRequireDefault(_MSI9);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+exports.MSI = _MSI2.default;
+exports.MSI10 = _MSI4.default;
+exports.MSI11 = _MSI6.default;
+exports.MSI1010 = _MSI8.default;
+exports.MSI1110 = _MSI10.default;

+ 92 - 0
components/tki-barcode/barcodes/codabar/index.js

@@ -0,0 +1,92 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+exports.codabar = undefined;
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _Barcode2 = require("../Barcode.js");
+
+var _Barcode3 = _interopRequireDefault(_Barcode2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding specification:
+// http://www.barcodeisland.com/codabar.phtml
+
+var codabar = function (_Barcode) {
+	_inherits(codabar, _Barcode);
+
+	function codabar(data, options) {
+		_classCallCheck(this, codabar);
+
+		if (data.search(/^[0-9\-\$\:\.\+\/]+$/) === 0) {
+			data = "A" + data + "A";
+		}
+
+		var _this = _possibleConstructorReturn(this, (codabar.__proto__ || Object.getPrototypeOf(codabar)).call(this, data.toUpperCase(), options));
+
+		_this.text = _this.options.text || _this.text.replace(/[A-D]/g, '');
+		return _this;
+	}
+
+	_createClass(codabar, [{
+		key: "valid",
+		value: function valid() {
+			return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/) !== -1;
+		}
+	}, {
+		key: "encode",
+		value: function encode() {
+			var result = [];
+			var encodings = this.getEncodings();
+			for (var i = 0; i < this.data.length; i++) {
+				result.push(encodings[this.data.charAt(i)]);
+				// for all characters except the last, append a narrow-space ("0")
+				if (i !== this.data.length - 1) {
+					result.push("0");
+				}
+			}
+			return {
+				text: this.text,
+				data: result.join('')
+			};
+		}
+	}, {
+		key: "getEncodings",
+		value: function getEncodings() {
+			return {
+				"0": "101010011",
+				"1": "101011001",
+				"2": "101001011",
+				"3": "110010101",
+				"4": "101101001",
+				"5": "110101001",
+				"6": "100101011",
+				"7": "100101101",
+				"8": "100110101",
+				"9": "110100101",
+				"-": "101001101",
+				"$": "101100101",
+				":": "1101011011",
+				"/": "1101101011",
+				".": "1101101101",
+				"+": "101100110011",
+				"A": "1011001001",
+				"B": "1001001011",
+				"C": "1010010011",
+				"D": "1010011001"
+			};
+		}
+	}]);
+
+	return codabar;
+}(_Barcode3.default);
+
+exports.codabar = codabar;

+ 34 - 0
components/tki-barcode/barcodes/index.js

@@ -0,0 +1,34 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+
+var _CODE = require('./CODE39/');
+
+var _CODE2 = require('./CODE128/');
+
+var _EAN_UPC = require('./EAN_UPC/');
+
+var _ITF = require('./ITF/');
+
+var _MSI = require('./MSI/');
+
+var _pharmacode = require('./pharmacode/');
+
+var _codabar = require('./codabar');
+
+var _GenericBarcode = require('./GenericBarcode/');
+
+exports.default = {
+	CODE39: _CODE.CODE39,
+	CODE128: _CODE2.CODE128, CODE128A: _CODE2.CODE128A, CODE128B: _CODE2.CODE128B, CODE128C: _CODE2.CODE128C,
+	EAN13: _EAN_UPC.EAN13, EAN8: _EAN_UPC.EAN8, EAN5: _EAN_UPC.EAN5, EAN2: _EAN_UPC.EAN2, 
+	UPC: _EAN_UPC.UPC, UPCE: _EAN_UPC.UPCE,
+	ITF14: _ITF.ITF14,
+	ITF: _ITF.ITF,
+	MSI: _MSI.MSI, MSI10: _MSI.MSI10, MSI11: _MSI.MSI11, MSI1010: _MSI.MSI1010, MSI1110: _MSI.MSI1110,
+	PHARMACODE: _pharmacode.pharmacode,
+	CODABAR: _codabar.codabar,
+	GENERICBARCODE: _GenericBarcode.GenericBarcode
+};

+ 73 - 0
components/tki-barcode/barcodes/pharmacode/index.js

@@ -0,0 +1,73 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+	value: true
+});
+exports.pharmacode = undefined;
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _Barcode2 = require("../Barcode.js");
+
+var _Barcode3 = _interopRequireDefault(_Barcode2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation
+// http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf
+
+var pharmacode = function (_Barcode) {
+	_inherits(pharmacode, _Barcode);
+
+	function pharmacode(data, options) {
+		_classCallCheck(this, pharmacode);
+
+		var _this = _possibleConstructorReturn(this, (pharmacode.__proto__ || Object.getPrototypeOf(pharmacode)).call(this, data, options));
+
+		_this.number = parseInt(data, 10);
+		return _this;
+	}
+
+	_createClass(pharmacode, [{
+		key: "encode",
+		value: function encode() {
+			var z = this.number;
+			var result = "";
+
+			// http://i.imgur.com/RMm4UDJ.png
+			// (source: http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf, page: 34)
+			while (!isNaN(z) && z != 0) {
+				if (z % 2 === 0) {
+					// Even
+					result = "11100" + result;
+					z = (z - 2) / 2;
+				} else {
+					// Odd
+					result = "100" + result;
+					z = (z - 1) / 2;
+				}
+			}
+
+			// Remove the two last zeroes
+			result = result.slice(0, -2);
+
+			return {
+				data: result,
+				text: this.text
+			};
+		}
+	}, {
+		key: "valid",
+		value: function valid() {
+			return this.number >= 3 && this.number <= 131070;
+		}
+	}]);
+
+	return pharmacode;
+}(_Barcode3.default);
+
+exports.pharmacode = pharmacode;

+ 234 - 0
components/tki-barcode/tki-barcode.vue

@@ -0,0 +1,234 @@
+<template xlang="wxml" minapp="mpvue">
+  <view class="tki-barcode">
+    <!-- #ifndef MP-ALIPAY -->
+    <canvas
+      class="tki-barcode-canvas"
+      :canvas-id="cid"
+      :style="{ width: canvasWidth + 'px', height: canvasHeight + 'px' }"
+    />
+    <!-- #endif -->
+    <!-- #ifdef MP-ALIPAY -->
+    <canvas
+      :id="cid"
+      :width="canvasWidth"
+      :height="canvasHeight"
+      class="tki-barcode-canvas"
+    />
+    <!-- #endif -->
+    <image
+      v-show="show"
+      :src="result"
+      :style="{ width: canvasWidth + 'px', height: canvasHeight + 'px' }"
+    />
+  </view>
+</template>
+
+<script>
+// const barcode = require('./barcode.js');
+import barCode from "./barcode.js";
+const opations = {
+  // format: "CODE128",//选择要使用的条形码类型 微信支持的条码类型有 code128\code39\ena13\ean8\upc\itf14\
+  width: 4, //设置条之间的宽度
+  height: 120, //高度
+  displayValue: true, //是否在条形码下方显示文字
+  // text: "1234567890",//覆盖显示的文本
+  textAlign: "center", //设置文本的水平对齐方式
+  textPosition: "bottom", //设置文本的垂直位置
+  textMargin: 0, //设置条形码和文本之间的间距
+  fontSize: 24, //设置文本的大小
+  fontColor: "#000000", //设置文本的颜色
+  lineColor: "#000000", //设置条形码的颜色
+  background: "#FFFFFF", //设置条形码的背景色
+  margin: 0, //设置条形码周围的空白边距
+  marginTop: undefined, //设置条形码周围的上边距
+  marginBottom: undefined, //设置条形码周围的下边距
+  marginLeft: undefined, //设置条形码周围的左边距
+  marginRight: undefined, //设置条形码周围的右边距
+};
+export default {
+  name: "tkiBarcode",
+  props: {
+    show: {
+      type: Boolean,
+      default: true,
+    },
+    cid: {
+      type: String,
+      default: "tki-barcode-canvas",
+    },
+    unit: {
+      type: String,
+      default: "upx",
+    },
+    val: {
+      type: String,
+      default: "1234567890128",
+    },
+    format: {
+      type: String,
+      default: "CODE128",
+    },
+    opations: {
+      type: Object,
+      default: function () {
+        return {};
+      },
+    },
+    onval: {
+      type: Boolean,
+      default: false,
+    },
+    loadMake: {
+      type: Boolean,
+      default: true,
+    },
+  },
+  data() {
+    return {
+      result: "",
+      canvasWidth: 0,
+      canvasHeight: 0,
+      defaultOpations: Object.assign({}, opations),
+    };
+  },
+  onUnload: function () {},
+  methods: {
+    _makeCode() {
+      let that = this;
+      // 合并参数
+      Object.assign(this.defaultOpations, this.opations);
+      if (that.unit == "upx") {
+        if (that.defaultOpations.width) {
+          that.defaultOpations.width = uni.upx2px(that.defaultOpations.width);
+        }
+        if (that.defaultOpations.height) {
+          that.defaultOpations.height = uni.upx2px(that.defaultOpations.height);
+        }
+        if (that.defaultOpations.fontSize) {
+          that.defaultOpations.fontSize = uni.upx2px(
+            that.defaultOpations.fontSize
+          );
+        }
+      }
+      if (that._empty(that.defaultOpations.text)) {
+        that.defaultOpations.text = that.val;
+      }
+      if (that._empty(that.defaultOpations.format)) {
+        that.defaultOpations.format = that.format;
+      }
+      // console.log(JSON.stringify(that.defaultOpations))
+      new barCode(
+        that,
+        that.cid,
+        that.defaultOpations,
+        function (res) {
+          // 生成条形码款高回调
+          that.canvasWidth = res.width;
+          that.canvasHeight = res.height;
+        },
+        function (res) {
+          // 生成条形码的回调
+          // 返回值
+          that._result(res);
+          // 重置默认参数
+          that.defaultOpations = opations;
+        }
+      );
+    },
+    _clearCode() {
+      this._result("");
+    },
+    _saveCode() {
+      let that = this;
+      if (this.result != "") {
+        uni.saveImageToPhotosAlbum({
+          filePath: that.result,
+          success: function () {
+            uni.showToast({
+              title: "条形码保存成功",
+              icon: "success",
+              duration: 2000,
+            });
+          },
+        });
+      }
+    },
+    _result(res) {
+      this.result = res;
+      this.$emit("result", res);
+    },
+    _result(res) {
+      this.result = res;
+      this.$emit("result", res);
+    },
+    _empty(v) {
+      let tp = typeof v,
+        rt = false;
+      if (tp == "number" && String(v) == "") {
+        rt = true;
+      } else if (tp == "undefined") {
+        rt = true;
+      } else if (tp == "object") {
+        if (JSON.stringify(v) == "{}" || JSON.stringify(v) == "[]" || v == null)
+          rt = true;
+      } else if (tp == "string") {
+        if (
+          v == "" ||
+          v == "undefined" ||
+          v == "null" ||
+          v == "{}" ||
+          v == "[]"
+        )
+          rt = true;
+      } else if (tp == "function") {
+        rt = false;
+      }
+      return rt;
+    },
+  },
+  watch: {
+    val(n, o) {
+      if (this.onval) {
+        if (n != o && !this._empty(n)) {
+          setTimeout(() => {
+            this._makeCode();
+          }, 0);
+        }
+      }
+    },
+    opations: {
+      handler(n, o) {
+        if (this.onval) {
+          if (!this._empty(n)) {
+            setTimeout(() => {
+              this._makeCode();
+            }, 0);
+          }
+        }
+      },
+      deep: true,
+    },
+  },
+  mounted: function () {
+    if (this.loadMake) {
+      if (!this._empty(this.val)) {
+        console.log("条形码生成");
+        setTimeout(() => {
+          this._makeCode();
+        }, 0);
+      }
+    }
+  },
+};
+</script>
+<style>
+.tki-barcode {
+  position: relative;
+}
+.tki-barcode-canvas {
+  position: fixed;
+  top: -99999upx;
+  left: -99999upx;
+  z-index: -99999;
+}
+</style>

+ 3 - 1
main.js

@@ -10,7 +10,9 @@ import {
 import store from "@/common/store";
 import common from "@/common";
 import uView from '@/uni_modules/uview-ui'
-
+//打印
+import Printer from './plugins/printer'
+Vue.use(Printer);
 // 引入uView对小程序分享的mixin封装
 let mpShare = require('@/uni_modules/uview-ui/libs/mixin/mpShare.js');
 Vue.mixin(mpShare)

+ 13 - 4
manifest.json

@@ -2,8 +2,8 @@
     "name" : "pdaApp-test",
     "appid" : "__UNI__7E491C0",
     "description" : "pdaApp",
-    "versionName" : "1.0.4",
-    "versionCode" : 104,
+    "versionName" : "1.0.5",
+    "versionCode" : 105,
     "transformPx" : false,
     /* 5+App特有相关 */
     "app-plus" : {
@@ -22,7 +22,8 @@
         /* 模块配置 */
         "modules" : {
             "Camera" : {},
-            "Barcode" : {}
+            "Barcode" : {},
+            "Bluetooth" : {}
         },
         /* 应用发布信息 */
         "distribute" : {
@@ -44,7 +45,15 @@
                     "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
                     "<uses-feature android:name=\"android.hardware.camera\"/>",
                     "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
-                    "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>"
+                    "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
+										"<uses-permission android:name=\"android.permission.BLUETOOTH_CONNECT\"/>",
+										"<uses-permission android:name=\"android.permission.BLUETOOTH\" />",
+										"<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\" />",
+										"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
+										"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
+										"<uses-permission android:name=\"android.permission.BLUETOOTH_SCAN\"/>",
+										"<uses-permission android:name=\"android.permission.ACCESS_LOCATION_EXTRA_COMMANDS\"/>",
+										"<uses-permission android:name=\"android.permission.BLUETOOTH_PRIVILEGED\"/>"
                 ],
                 "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ],
                 "schemes" : "fapai",

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 465 - 158
package-lock.json


+ 5 - 1
package.json

@@ -20,6 +20,10 @@
     "uni-read-pages": "^1.0.5",
     "uni-simple-router": "^2.0.6",
     "unplugin-vue2-script-setup": "^0.11.4",
-    "weixin-js-sdk": "^1.6.5"
+    "weixin-js-sdk": "^1.6.5",
+    "@psdk/cpcl": "^0.6.1",
+    "@psdk/device-ble-uniapp": "^0.6.1",
+    "@psdk/esc": "^0.6.1",
+    "@psdk/tspl": "^0.6.1"
   }
 }

+ 1 - 7
pages/inventory-task/detail.vue

@@ -268,15 +268,9 @@ export default {
         fontSize: "32rpx",
         borderRadius: "8rpx",
       },
-      pageTitle: "2025年中心仓第三季度食品盘点",
       pageNum: 1,
       pageSize: 10,
-      inventoryInfo: {
-        code: "2024202244",
-        operator: "刘双秀",
-        progress: 105,
-        total: 604,
-      },
+      inventoryInfo: {},
       loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
       goodsList: [],
       filterPopupVisible: false,

+ 139 - 0
pages/picking-task/components/ble-tip-pop.vue

@@ -0,0 +1,139 @@
+<template>
+  <view>
+    <u-popup
+      :show="errorShow"
+      :closeOnClickOverlay="false"
+      :safeAreaInsetBottom="false"
+      @close="closeClick"
+      mode="center"
+      :round="10"
+    >
+      <view class="error-box">
+        <view class="flex_box flex_row_center">
+          <u-image
+            src="@/static/image/error-img.png"
+            width="112rpx"
+            height="112rpx"
+          ></u-image>
+        </view>
+        <view :class="['tips-value', { 'is-center': isCenter }]">
+          <view>{{ content }}</view>
+          <view class="tips-value-extra" v-if="extraText">{{ extraText }}</view>
+        </view>
+        <view class="btn-box">
+          <u-button
+            class="no-btn"
+            type="primary"
+            :plain="true"
+            :text="cancelBtnText"
+            @click="closeClick"
+          ></u-button>
+          <u-button
+            class="yes-btn"
+            type="primary"
+            :text="confirmBtnText"
+            @click="confirmClick"
+          ></u-button>
+        </view>
+      </view>
+    </u-popup>
+  </view>
+</template>
+
+<script>
+export default {
+  props: {
+    value: {
+      type: Boolean,
+      default: false,
+    },
+    content: {
+      type: String,
+      default: "",
+    },
+    extraText: {
+      type: String,
+      default: "",
+    },
+    cancelBtnText: {
+      type: String,
+      default: "否",
+    },
+    confirmBtnText: {
+      type: String,
+      default: "是",
+    },
+    isCenter: {
+      type: Boolean,
+      default: false,
+    },
+  },
+  watch: {
+    value: {
+      handler(val) {
+        this.errorShow = val;
+      },
+      immediate: true,
+    },
+  },
+  data() {
+    return {
+      errorShow: false,
+    };
+  },
+  methods: {
+    closeClick() {
+      this.$emit("close");
+      this.$emit("input", false);
+    },
+    confirmClick() {
+      this.$emit("confirm");
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.error-box {
+  width: 580rpx;
+  padding: 48rpx 36rpx 48rpx;
+  .tips-value {
+    color: #1d212a;
+    font-family: "PingFang SC";
+    font-size: 32rpx;
+    font-style: normal;
+    font-weight: bold;
+    margin-top: 32rpx;
+
+    &.is-center {
+      text-align: center;
+    }
+
+    &-extra {
+      font-weight: 400;
+      font-size: 28rpx;
+      color: rgba(153, 153, 153, 1);
+      margin-top: 10rpx;
+    }
+  }
+
+  .btn-box {
+    display: flex;
+    justify-content: space-between;
+    margin-top: 60rpx;
+    .no-btn {
+      width: 244rpx;
+      border-radius: 16rpx;
+      border: 1px solid #bfc8db;
+      color: #86909c;
+      font-size: 32rpx;
+    }
+    .yes-btn {
+      width: 244rpx;
+      border-radius: 16rpx;
+      background: #0256ff;
+      font-size: 32rpx;
+    }
+  }
+}
+</style>

+ 41 - 1
pages/picking-task/delivery.vue

@@ -103,6 +103,11 @@
 								</view> -->
 							</u-number-box>
 						</view>
+						<view class="action-btn-box">
+							<view class="print-btn" @click="handlePrint(item)">
+								打印条码
+							</view>
+						</view>
 					</good-item>
 				</block>
 			</view>
@@ -123,6 +128,12 @@
 		<scaned-pop v-if="scanedShow" v-model="scanedShow" :scanNum="scanNum" @close="scanedShow = false" @confirm="scanConfirm"></scaned-pop>
 		
 		<goods-pop v-model="goodsShow" @close="goodsShow = false"></goods-pop>
+		<!-- 打印条码弹框 -->
+		<print-pop :show.sync="blePrintPop.show" :info="blePrintPop.data" @confirm="startPrint"></print-pop>
+		<!-- 选择蓝牙设备弹框 -->
+		<ble-pop :show.sync="bleSelectPop.show" :list="discoveredDevices" @close="closeBleSelectPop" @refresh="refreshBleDevice" @selectItem="handleSelectBle"></ble-pop>
+
+    <ble-tip-pop v-model="bleErrorTipPop.show" :is-center="true" @confirm="bleErrorTipConfirm" :content="bleErrorTipPop.content" :extraText="bleErrorTipPop.extraText"> </ble-tip-pop>
 	</view>
 </template>
 
@@ -132,15 +143,23 @@
 	import successPop from '@/components/success-pop/success-pop.vue'
 	import scanedPop from '@/components/scaned-pop/scaned-pop.vue'
 	import goodsPop from '@/components/goods-pop/goods-pop.vue'
+	import printPop from '@/components/print-pop/print-pop.vue'
+	import blePop from '@/components/ble-pop/ble-pop.vue'
+	import bleTipPop from './components/ble-tip-pop.vue'
 	import {orderDetail, orderInfo, orderSubmit} from '@/common/request/apis/purchase'
 	import {mapGetters} from 'vuex'
+	import blePrintMixin from '@/common/mixins/blePrintMixin.js'
 	export default {
+		mixins: [blePrintMixin],
 		components: {
 			goodItem,
 			errorPop,
 			successPop,
 			scanedPop,
-			goodsPop
+			goodsPop,
+			printPop,
+			blePop,
+			bleTipPop
 		},
 		data() {
 			return {
@@ -274,6 +293,7 @@
 							item.materialNumber = 0
 						})
 						this.goodsList = res.data.rows
+					  console.log('goodsList==========',this.goodsList )
 					}
 				})
 			},
@@ -333,6 +353,14 @@
 				uni.navigateTo({
 					url:`/pages/goods/detail?id=${val.id}&name=${val.materialName}`
 				})
+			},
+			//条码逻辑
+			handlePrint(item) {
+				this.openBlePrintPop(item)
+			},
+			//开始打印
+			startPrint(data){
+				this.writeData(data)
 			}
 		}
 	}
@@ -561,5 +589,17 @@
 				margin: 0;
 			}
 		}
+		
+	}
+	.action-btn-box{
+		text-align: right;
+		padding: 30rpx 48rpx 0 26rpx;
+		
+		.print-btn{
+			font-family: PingFang SC;
+			font-weight: 500;
+			font-size: 28rpx;
+			color: #0256FF;
+		}
 	}
 </style>

+ 476 - 0
plugins/BluetoothTool.js

@@ -0,0 +1,476 @@
+//#ifdef APP-PLUS
+let BluetoothAdapter = plus.android.importClass(
+  "android.bluetooth.BluetoothAdapter"
+);
+let Intent = plus.android.importClass("android.content.Intent");
+let IntentFilter = plus.android.importClass("android.content.IntentFilter");
+let BluetoothDevice = plus.android.importClass(
+  "android.bluetooth.BluetoothDevice"
+);
+let UUID = plus.android.importClass("java.util.UUID");
+let Toast = plus.android.importClass("android.widget.Toast");
+//连接串口设备的 UUID
+let MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
+
+let invoke = plus.android.invoke;
+let btAdapter = BluetoothAdapter.getDefaultAdapter();
+let activity = plus.android.runtimeMainActivity();
+
+let btSocket = null;
+let btInStream = null;
+let btOutStream = null;
+let setIntervalId = 0;
+
+let btFindReceiver = null; //蓝牙搜索广播接收器
+let btStatusReceiver = null; //蓝牙状态监听广播
+//#endif
+/**
+ * 构造对象
+ */
+var blueToothTool = {
+  state: {
+    bluetoothEnable: false, //蓝牙是否开启
+    bluetoothState: "", //当前蓝牙状态
+    discoveryDeviceState: false, //是否正在搜索蓝牙设备
+    readThreadState: false, //数据读取线程状态
+  },
+  options: {
+    /**
+     * 监听蓝牙状态回调
+     * @param {String} state
+     */
+    listenBTStatusCallback: function (state) {},
+    /**
+     * 搜索到新的蓝牙设备回调
+     * @param {Device} newDevice
+     */
+    discoveryDeviceCallback: function (newDevice) {},
+    /**
+     * 蓝牙搜索完成回调
+     */
+    discoveryFinishedCallback: function () {},
+    /**
+     * 接收到数据回调
+     * @param {Array} dataByteArr
+     */
+    readDataCallback: function (dataByteArr) {},
+    /**
+     * 蓝牙连接中断回调
+     * @param {Exception} e
+     */
+    connExceptionCallback: function (e) {},
+  },
+  init(setOptions) {
+    Object.assign(this.options, setOptions);
+    this.state.bluetoothEnable = this.getBluetoothStatus();
+    this.listenBluetoothStatus();
+  },
+  shortToast(msg) {
+    Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show();
+  },
+  /**
+   * 是否支持蓝牙
+   * @return {boolean}
+   */
+  isSupportBluetooth() {
+    if (btAdapter != null) {
+      return true;
+    }
+    return false;
+  },
+  /**
+   * 获取蓝牙的状态
+   * @return {boolean} 是否已开启
+   */
+  getBluetoothStatus() {
+    if (btAdapter != null) {
+      return btAdapter.isEnabled();
+    }
+    return false;
+  },
+  /**
+   * 打开蓝牙
+   * @param activity
+   * @param requestCode
+   */
+  turnOnBluetooth() {
+    if (btAdapter == null) {
+      shortToast("没有蓝牙");
+      return;
+    }
+    if (!btAdapter.isEnabled()) {
+      if (activity == null) {
+        shortToast("未获取到activity");
+        return;
+      } else {
+        let intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+        let requestCode = 1;
+        activity.startActivityForResult(intent, requestCode);
+        return;
+      }
+    } else {
+      shortToast("蓝牙已经打开");
+    }
+  },
+  /**
+   * 关闭蓝牙
+   */
+  turnOffBluetooth() {
+    if (btAdapter != null && btAdapter.isEnabled()) {
+      btAdapter.disable();
+    }
+    if (btFindReceiver != null) {
+      try {
+        activity.unregisterReceiver(btFindReceiver);
+      } catch (e) {}
+      btFindReceiver = null;
+    }
+    this.state.bluetoothEnable = false;
+    this.cancelDiscovery();
+    closeBtSocket();
+
+    if (btAdapter != null && btAdapter.isEnabled()) {
+      btAdapter.disable();
+      shortToast("蓝牙关闭成功");
+    } else {
+      shortToast("蓝牙已经关闭");
+    }
+  },
+  /**
+   * 获取已经配对的设备
+   * @return {Array} connetedDevices
+   */
+  getPairedDevices() {
+    let pairedDevices = [];
+
+    //蓝牙连接android原生对象,是一个set集合
+    let pairedDevicesAndroid = null;
+    if (btAdapter != null && btAdapter.isEnabled()) {
+      pairedDevicesAndroid = btAdapter.getBondedDevices();
+    } else {
+      shortToast("蓝牙未开启");
+    }
+
+    if (!pairedDevicesAndroid) {
+      return pairedDevices;
+    }
+
+    //遍历连接设备的set集合,转换为js数组
+    let it = invoke(pairedDevicesAndroid, "iterator");
+    while (invoke(it, "hasNext")) {
+      let device = invoke(it, "next");
+      pairedDevices.push({
+        name: invoke(device, "getName"),
+        address: invoke(device, "getAddress"),
+      });
+    }
+    return pairedDevices;
+  },
+  /**
+   * 发现设备
+   */
+  discoveryNewDevice() {
+    if (btFindReceiver != null) {
+      try {
+        activity.unregisterReceiver(btFindReceiver);
+      } catch (e) {
+        console.error(e);
+      }
+      btFindReceiver = null;
+      this.cancelDiscovery();
+    }
+    let Build = plus.android.importClass("android.os.Build");
+
+    //6.0以后的如果需要利用本机查找周围的wifi和蓝牙设备, 申请权限
+    if (Build.VERSION.SDK_INT >= 6.0) {
+    }
+    let options = this.options;
+    btFindReceiver = plus.android.implements(
+      "io.dcloud.android.content.BroadcastReceiver",
+      {
+        onReceive: function (context, intent) {
+          plus.android.importClass(context);
+          plus.android.importClass(intent);
+          let action = intent.getAction();
+
+          if (BluetoothDevice.ACTION_FOUND == action) {
+            // 找到设备
+            let device = intent.getParcelableExtra(
+              BluetoothDevice.EXTRA_DEVICE
+            );
+            let newDevice = {
+              name: plus.android.invoke(device, "getName"),
+              address: plus.android.invoke(device, "getAddress"),
+            };
+            options.discoveryDeviceCallback &&
+              options.discoveryDeviceCallback(newDevice);
+          }
+          if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED == action) {
+            // 搜索完成
+            cancelDiscovery();
+            options.discoveryFinishedCallback &&
+              options.discoveryFinishedCallback();
+          }
+        },
+      }
+    );
+    let filter = new IntentFilter();
+    filter.addAction(BluetoothDevice.ACTION_FOUND);
+    filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
+    activity.registerReceiver(btFindReceiver, filter);
+    btAdapter.startDiscovery(); //开启搜索
+    this.state.discoveryDeviceState = true;
+  },
+  /**
+   * 蓝牙状态监听
+   * @param {Activity} activity
+   */
+  listenBluetoothStatus() {
+    if (btStatusReceiver != null) {
+      try {
+        activity.unregisterReceiver(btStatusReceiver);
+      } catch (e) {
+        console.error(e);
+      }
+      btStatusReceiver = null;
+    }
+    btStatusReceiver = plus.android.implements(
+      "io.dcloud.android.content.BroadcastReceiver",
+      {
+        onReceive: (context, intent) => {
+          plus.android.importClass(context);
+          plus.android.importClass(intent);
+
+          let action = intent.getAction();
+          switch (action) {
+            case BluetoothAdapter.ACTION_STATE_CHANGED:
+              let blueState = intent.getIntExtra(
+                BluetoothAdapter.EXTRA_STATE,
+                0
+              );
+              let stateStr = "";
+              switch (blueState) {
+                case BluetoothAdapter.STATE_TURNING_ON:
+                  stateStr = "STATE_TURNING_ON";
+                  break;
+                case BluetoothAdapter.STATE_ON:
+                  this.state.bluetoothEnable = true;
+                  stateStr = "STATE_ON";
+                  break;
+                case BluetoothAdapter.STATE_TURNING_OFF:
+                  stateStr = "STATE_TURNING_OFF";
+                  break;
+                case BluetoothAdapter.STATE_OFF:
+                  stateStr = "STATE_OFF";
+                  this.state.bluetoothEnable = false;
+                  break;
+              }
+              this.state.bluetoothState = stateStr;
+              this.options.listenBTStatusCallback &&
+                this.options.listenBTStatusCallback(stateStr);
+              break;
+          }
+        },
+      }
+    );
+    let filter = new IntentFilter();
+    filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
+    activity.registerReceiver(btStatusReceiver, filter);
+    // 首次连接 状态回调
+    if (this.state.bluetoothEnable) {
+      this.options.listenBTStatusCallback &&
+        this.options.listenBTStatusCallback("STATE_ON");
+    }
+  },
+  /**
+   * 根据蓝牙地址,连接设备
+   * @param {Stirng} address
+   * @return {Boolean}
+   */
+  connDevice(address, callback) {
+    let InputStream = plus.android.importClass("java.io.InputStream");
+    let OutputStream = plus.android.importClass("java.io.OutputStream");
+    let BluetoothSocket = plus.android.importClass(
+      "android.bluetooth.BluetoothSocket"
+    );
+
+    this.cancelDiscovery();
+    if (btSocket != null) {
+      this.closeBtSocket();
+    }
+    this.state.readThreadState = false;
+
+    try {
+      let device = invoke(btAdapter, "getRemoteDevice", address);
+      btSocket = invoke(device, "createRfcommSocketToServiceRecord", MY_UUID);
+    } catch (e) {
+      console.error(e);
+      shortToast("连接失败,获取Socket失败!");
+      callback(false);
+      return false;
+    }
+    try {
+      invoke(btSocket, "connect");
+      if (!btSocket.isConnected()) {
+        this.shortToast("连接失败");
+        callback(false);
+        try {
+          btSocket.close();
+          btSocket = null;
+        } catch (e1) {
+          console.error(e1);
+        }
+        return false;
+      }
+      this.readData(); //读数据
+      this.shortToast("连接成功");
+      callback(true);
+    } catch (e) {
+      console.error(e);
+      this.shortToast("连接失败");
+      callback(false);
+      try {
+        btSocket.close();
+        btSocket = null;
+      } catch (e1) {
+        console.error(e1);
+      }
+      return false;
+    }
+    return true;
+  },
+  /**
+   * 断开连接设备
+   * @param {Object} address
+   * @return {Boolean}
+   */
+  disConnDevice() {
+    if (btSocket != null) {
+      this.closeBtSocket();
+    }
+    this.state.readThreadState = false;
+    this.shortToast("断开连接成功");
+  },
+  /**
+   * 断开连接设备
+   * @param {Object} address
+   * @return {Boolean}
+   */
+  closeBtSocket() {
+    this.state.readThreadState = false;
+    if (!btSocket) {
+      return;
+    }
+    try {
+      btSocket.close();
+    } catch (e) {
+      console.error(e);
+      btSocket = null;
+    }
+  },
+  /**
+   * 取消发现
+   */
+  cancelDiscovery() {
+    if (btAdapter.isDiscovering()) {
+      btAdapter.cancelDiscovery();
+    }
+    if (btFindReceiver != null) {
+      activity.unregisterReceiver(btFindReceiver);
+      btFindReceiver = null;
+    }
+    this.state.discoveryDeviceState = false;
+  },
+  /**
+   * 读取数据
+   * @param {Object} activity
+   * @param {Function} callback
+   * @return {Boolean}
+   */
+  readData() {
+    if (!btSocket) {
+      this.shortToast("请先连接蓝牙设备!");
+      return false;
+    }
+    try {
+      btInStream = invoke(btSocket, "getInputStream");
+      btOutStream = invoke(btSocket, "getOutputStream");
+    } catch (e) {
+      console.error(e);
+      this.shortToast("创建输入输出流失败!");
+      this.closeBtSocket();
+      return false;
+    }
+    this.read();
+    this.state.readThreadState = true;
+    return true;
+  },
+  /**
+   * 模拟java多线程读取数据
+   */
+  read() {
+    let setTimeCount = 0;
+    clearInterval(setIntervalId);
+    setIntervalId = setInterval(() => {
+      setTimeCount++;
+      if (this.state.readThreadState) {
+        let t = new Date().getTime();
+        //心跳检测
+        if (setTimeCount % 20 == 0) {
+          try {
+            btOutStream.write([0b00]);
+          } catch (e) {
+            this.state.readThreadState = false;
+            this.options.connExceptionCallback &&
+              this.options.connExceptionCallback(e);
+          }
+        }
+        let dataArr = [];
+        while (invoke(btInStream, "available") !== 0) {
+          let data = invoke(btInStream, "read");
+          dataArr.push(data);
+          let ct = new Date().getTime();
+          if (ct - t > 100) {
+            break;
+          }
+        }
+        if (dataArr.length > 0) {
+          this.options.readDataCallback &&
+            this.options.readDataCallback(dataArr);
+        }
+      }
+    }, 40);
+  },
+  /**
+   * 发送数据
+   * @param {String} dataStr
+   * @return {Boolean}
+   */
+  sendData(dataStr) {
+    if (!btOutStream) {
+      this.shortToast("创建输出流失败!");
+      return;
+    }
+    let bytes = invoke(dataStr, "getBytes", "gbk");
+    try {
+      btOutStream.write(bytes);
+    } catch (e) {
+      return false;
+    }
+    return true;
+  },
+  sendByteData(byteData) {
+    if (!btOutStream) {
+      this.shortToast("创建输出流失败!");
+      return;
+    }
+    try {
+      btOutStream.write(byteData);
+    } catch (e) {
+      return false;
+    }
+    return true;
+  },
+};
+
+module.exports = blueToothTool;

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 85 - 0
plugins/gb2312ToBase64.js


+ 69 - 0
plugins/permission.js

@@ -0,0 +1,69 @@
+const androidPermissions = {
+  camera: "android.permission.CAMERA", // 摄像头权限
+  bluetooth: {
+    coarse: "android.permission.ACCESS_COARSE_LOCATION", // 位置权限
+    fine: "android.permission.ACCESS_FINE_LOCATION",
+    extra: "android.permission.ACCESS_LOCATION_EXTRA_COMMANDS",
+    scan: "android.permission.BLUETOOTH_SCAN",
+    connect: "android.permission.BLUETOOTH_CONNECT",
+  },
+  storage: {
+    read: "android.permission.READ_EXTERNAL_STORAGE", // 存储读取权限
+    write: "android.permission.WRITE_EXTERNAL_STORAGE", // 存储写入权限
+  },
+};
+
+const permissionCheck = {
+  getPermissionList(permissionID) {
+    const id = androidPermissions[permissionID];
+    const list = [];
+    if (typeof id == "string") {
+      list[0] = id;
+    } else {
+      for (let key in id) {
+        list.push(id[key]);
+      }
+    }
+    return list;
+  },
+  androidPermissionCheck(permissionID) {
+    return new Promise((resolve, reject) => {
+      if (plus) {
+        let ids = this.getPermissionList(permissionID);
+        plus.android.requestPermissions(
+          ids,
+          function (result) {
+            let res = 0;
+            for (let i = 0; i < result.granted.length; i++) {
+              let permission = result.granted[i];
+              console.log("已获取的权限:", permission);
+              res = 1;
+            }
+            for (let i = 0; i < result.deniedPresent.length; i++) {
+              let permission = result.deniedPresent[i];
+              console.log("本次已拒绝的权限:", permission);
+              res = 0;
+            }
+            for (let i = 0; i < result.deniedAlways.length; i++) {
+              let permission = result.deniedAlways[i];
+              console.log("永久拒绝的权限:", result);
+              res = -1;
+            }
+            resolve({
+              code: 1,
+              data: res,
+            });
+          },
+          (error) => {
+            reject({
+              code: 2,
+              data: `code:${error.code},msg:${error.message}!`,
+            });
+          }
+        );
+      }
+    });
+  },
+};
+
+export default permissionCheck;

+ 46 - 0
plugins/printer.ts

@@ -0,0 +1,46 @@
+import Vue from "vue";
+import { ConnectedDevice, Lifecycle } from "@psdk/frame-father";
+import { CPCL, GenericCPCL } from "@psdk/cpcl";
+import { GenericTSPL, TSPL } from "@psdk/tspl";
+import { ESC, GenericESC } from "@psdk/esc";
+
+class Printer {
+  private _connectedDevice?: ConnectedDevice;
+  private _cpcl?: GenericCPCL;
+  private _tspl?: GenericTSPL;
+  private _esc?: GenericESC;
+  init(connectedDevice: ConnectedDevice) {
+    this._connectedDevice = connectedDevice;
+    const lifecycle = new Lifecycle(connectedDevice);
+    this._cpcl = CPCL.generic(lifecycle);
+    this._tspl = TSPL.generic(lifecycle);
+    this._esc = ESC.generic(lifecycle);
+  }
+
+  isConnected(): boolean {
+    return this._connectedDevice != null;
+  }
+
+  connectedDevice(): ConnectedDevice | undefined {
+    return this._connectedDevice;
+  }
+
+  cpcl(): GenericCPCL {
+    if (!this._connectedDevice) throw Error("The device is not connected");
+    return this._cpcl!;
+  }
+  tspl(): GenericTSPL {
+    if (!this._connectedDevice) throw Error("The device is not connected");
+    return this._tspl!;
+  }
+  esc(): GenericESC {
+    if (!this._connectedDevice) throw Error("The device is not connected");
+    return this._esc!;
+  }
+}
+
+export default {
+  install: function () {
+    Vue.prototype.$printer = new Printer();
+  },
+};

+ 247 - 0
plugins/usbTool.js

@@ -0,0 +1,247 @@
+/**
+ * 初始化参数
+ */
+//#ifdef APP-PLUS
+let UsbManager = plus.android.importClass("android.hardware.usb.UsbManager");
+let IntentFilter = plus.android.importClass("android.content.IntentFilter");
+let PendingIntent = plus.android.importClass("android.app.PendingIntent");
+let UsbConstants = plus.android.importClass(
+  "android.hardware.usb.UsbConstants"
+);
+let UsbInterface = plus.android.importClass(
+  "android.hardware.usb.UsbInterface"
+);
+let Intent = plus.android.importClass("android.content.Intent");
+let Context = plus.android.importClass("android.content.Context");
+let HashMap = plus.android.importClass("java.util.HashMap");
+let Toast = plus.android.importClass("android.widget.Toast");
+
+let invoke = plus.android.invoke;
+let activity = plus.android.runtimeMainActivity();
+const VIDQR = 0x09c5;
+const VIDMY = 0x09c6;
+const VIDIP = 0x353d;
+const deviceList = [];
+let mPermissionIntent = null;
+let mUsbManager = null;
+let currentDevice = null;
+let mUsbDeviceConnection = null;
+let mUsbInterface = null;
+let mUsbEndpointIn = null;
+let mUsbEndpointOut = null;
+let usbStatusReceiver = null; //usb状态监听广播
+let isOpen = false;
+//#endif
+/**
+ * 构造对象
+ */
+var usbTool = {
+  state: {
+    USBState: "",
+    readThreadState: false, //数据读取线程状态
+  },
+  options: {
+    /**
+     * 监听USB状态回调
+     * @param {String} state
+     */
+    listenUSBStatusCallback: function (state) {},
+    /**
+     * 接收到数据回调
+     * @param {Array} dataByteArr
+     */
+    readDataCallback: function (dataByteArr) {},
+  },
+  init(setOptions) {
+    Object.assign(this.options, setOptions);
+    this.listenUsbStatus();
+    mUsbManager = activity.getSystemService(Context.USB_SERVICE);
+    mPermissionIntent = PendingIntent.getBroadcast(
+      activity,
+      0,
+      new Intent("com.application.usbhost.USB_PERMISSION"),
+      PendingIntent.FLAG_IMMUTABLE
+    );
+  },
+  shortToast(msg) {
+    Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show();
+  },
+  // 打开设备
+  async openUsb() {
+    let mDevices = new HashMap();
+    mDevices = mUsbManager.getDeviceList();
+    if (mDevices === null) return false;
+    const devicesSize = invoke(mDevices, "size"); //获取几个长度
+    if (devicesSize === 0) return false;
+    const values = invoke(mDevices, "values");
+    const iterator = invoke(values, "iterator");
+    while (invoke(iterator, "hasNext")) {
+      const device = invoke(iterator, "next");
+      const vendorId = invoke(device, "getVendorId"); // 获取vendorId
+      if (vendorId == VIDQR || vendorId == VIDMY || vendorId == VIDIP) {
+        currentDevice = device;
+        if (!mUsbManager.hasPermission(currentDevice)) {
+          // 获取权限弹框
+          mUsbManager.requestPermission(currentDevice, mPermissionIntent);
+          for (let i = 10; i > 0; i--) {
+            await this.delay(1000);
+            if (i == 1 && !mUsbManager.hasPermission(currentDevice)) {
+              return false;
+            }
+            if (mUsbManager.hasPermission(currentDevice)) {
+              break;
+            }
+          }
+        }
+        if (
+          this.initCommunication(currentDevice, UsbConstants.USB_CLASS_PRINTER)
+        ) {
+          return true;
+        }
+      }
+    }
+    return false;
+  },
+  delay(ms) {
+    return new Promise((resolve) => setTimeout(resolve, ms));
+  },
+  initCommunication(device, type) {
+    const interfaceCount = invoke(device, "getInterfaceCount"); //获取接口数量
+    for (
+      let interfaceIndex = 0;
+      interfaceIndex < interfaceCount;
+      interfaceIndex++
+    ) {
+      const usbInterface = invoke(device, "getInterface", interfaceIndex); // 遍历获取接口
+      const interfaceClass = invoke(usbInterface, "getInterfaceClass");
+      if (type != interfaceClass) {
+        continue;
+      }
+      mUsbInterface = usbInterface;
+      for (let i = 0; i < invoke(usbInterface, "getEndpointCount"); i++) {
+        const ep = invoke(usbInterface, "getEndpoint", i);
+        if (invoke(ep, "getType") == UsbConstants.USB_ENDPOINT_XFER_BULK) {
+          if (invoke(ep, "getDirection") == UsbConstants.USB_DIR_OUT) {
+            mUsbEndpointOut = ep;
+          } else if (invoke(ep, "getDirection") == UsbConstants.USB_DIR_IN) {
+            mUsbEndpointIn = ep;
+          }
+        }
+      }
+      if (null == mUsbEndpointIn || null == mUsbEndpointOut) {
+        mUsbEndpointIn = null;
+        mUsbEndpointOut = null;
+        isOpen = false;
+        return false;
+      } else {
+        if (!mUsbManager.hasPermission(currentDevice)) {
+          isOpen = false;
+          return false;
+        } else {
+          isOpen = true;
+          return true;
+        }
+      }
+    }
+    return false;
+  },
+  /**
+   * usb状态监听
+   * @param {Activity} activity
+   */
+  listenUsbStatus() {
+    if (usbStatusReceiver != null) {
+      try {
+        activity.unregisterReceiver(usbStatusReceiver);
+      } catch (e) {
+        console.error(e);
+      }
+      usbStatusReceiver = null;
+    }
+    usbStatusReceiver = plus.android.implements(
+      "io.dcloud.android.content.BroadcastReceiver",
+      {
+        onReceive: (context, intent) => {
+          plus.android.importClass(context);
+          plus.android.importClass(intent);
+
+          let action = intent.getAction();
+          switch (action) {
+            case UsbManager.ACTION_USB_DEVICE_ATTACHED:
+              this.options.listenUSBStatusCallback &&
+                this.options.listenUSBStatusCallback(
+                  "ACTION_USB_DEVICE_ATTACHED"
+                );
+              break;
+            case UsbManager.ACTION_USB_DEVICE_DETACHED:
+              isOpen = false;
+              this.options.listenUSBStatusCallback &&
+                this.options.listenUSBStatusCallback(
+                  "ACTION_USB_DEVICE_DETACHED"
+                );
+              break;
+          }
+        },
+      }
+    );
+    let filter = new IntentFilter();
+    filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
+    filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
+    activity.registerReceiver(usbStatusReceiver, filter);
+  },
+  /**
+   * 关闭usb
+   */
+  closeUsb() {
+    mUsbEndpointIn = null;
+    mUsbEndpointOut = null;
+    if (mUsbDeviceConnection != null) {
+      mUsbDeviceConnection.releaseInterface(mUsbInterface);
+      mUsbDeviceConnection.close();
+      mUsbDeviceConnection = null;
+      isOpen = false;
+    }
+  },
+  /**
+   * 获得usb打开状态
+   *
+   * @return true:USB打开 false:USB关闭
+   */
+  isOpened() {
+    return isOpen;
+  },
+  sendByteData(byteData) {
+    if (currentDevice == null) {
+      console.log("未检测到打印机设备");
+      return false;
+    }
+    if (mUsbDeviceConnection == null) {
+      mUsbManager.requestPermission(currentDevice, mPermissionIntent);
+      mUsbDeviceConnection = mUsbManager.openDevice(currentDevice);
+      const ret = invoke(
+        mUsbDeviceConnection,
+        "claimInterface",
+        mUsbInterface,
+        true
+      );
+    }
+    if (mUsbEndpointOut == null) {
+      return false;
+    }
+    const result = invoke(
+      mUsbDeviceConnection,
+      "bulkTransfer",
+      mUsbEndpointOut,
+      byteData,
+      byteData.length,
+      1500
+    );
+    if (result == -1) {
+      return false;
+    } else {
+      return true;
+    }
+  },
+};
+
+module.exports = usbTool;

BIN
static/image/refresh-icon.png


BIN
static/image/shebei-icon.png


Vissa filer visades inte eftersom för många filer har ändrats