66 lines
2.1 KiB
JavaScript
66 lines
2.1 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const common_assets = require("../../common/assets.js");
|
|
const stores_scancode = require("../../stores/scancode.js");
|
|
const _sfc_main = {
|
|
__name: "batchscancode",
|
|
props: {
|
|
isOnlyBarCode: {
|
|
type: Boolean,
|
|
default: false
|
|
}
|
|
},
|
|
setup(__props) {
|
|
const type = common_vendor.ref("");
|
|
const list = common_vendor.ref([]);
|
|
const isInitDone = common_vendor.ref(false);
|
|
const flash = common_vendor.ref("off");
|
|
common_vendor.onLoad((options) => {
|
|
if (options.type) {
|
|
type.value = options.type;
|
|
}
|
|
});
|
|
const swithFlash = () => {
|
|
flash.value = flash.value === "off" ? "on" : "off";
|
|
common_vendor.index.vibrateShort();
|
|
};
|
|
const scancode = stores_scancode.useScanCodeStore();
|
|
scancode.clearCode();
|
|
const scanCode = (res) => {
|
|
const {
|
|
result
|
|
} = res.detail;
|
|
if (!list.includes(result)) {
|
|
list.push(result);
|
|
scancode.addCode(result, type.value);
|
|
} else {
|
|
common_vendor.index.showToast({
|
|
icon: "error",
|
|
title: "重复扫码,请返回或扫描下一个"
|
|
});
|
|
common_vendor.index.vibrateShort();
|
|
}
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: isInitDone.value
|
|
}, isInitDone.value ? {
|
|
b: common_assets._imports_0$1,
|
|
c: __props.isOnlyBarCode === true ? "../../static/scan/BarCodeScan.png" : "../../static/scan/scan.png",
|
|
d: flash.value === "off" ? "../../static/scan/flash_close.png" : "../../static/scan/flash_open.png",
|
|
e: common_vendor.n({
|
|
flashOpen: flash.value === "on"
|
|
}),
|
|
f: common_vendor.o(swithFlash)
|
|
} : {}, {
|
|
g: common_vendor.o(scanCode),
|
|
h: flash.value,
|
|
i: isInitDone.value = true
|
|
});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-72d631f3"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/common/batchscancode.js.map
|