You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
55 lines
1.7 KiB
2 years ago
|
"use strict";
|
||
|
const common_vendor = require("../common/vendor.js");
|
||
|
const _sfc_main = {
|
||
|
setup() {
|
||
|
let details = common_vendor.reactive({
|
||
|
activity: null,
|
||
|
receiver: null,
|
||
|
intentFilter: null
|
||
|
});
|
||
|
common_vendor.onLoad(() => {
|
||
|
initScan();
|
||
|
startScan();
|
||
|
});
|
||
|
common_vendor.onHide(() => {
|
||
|
stopScan();
|
||
|
});
|
||
|
common_vendor.onUnload(() => {
|
||
|
details.stopScan();
|
||
|
common_vendor.index.$off("scancodedate");
|
||
|
});
|
||
|
function initScan() {
|
||
|
if (plus) {
|
||
|
details.activity = plus.android.runtimeMainActivity();
|
||
|
var IntentFilter = plus.android.importClass("android.content.IntentFilter");
|
||
|
details.intentFilter = new IntentFilter();
|
||
|
details.intentFilter.addAction("com.android.server.scannerservice.broadcast");
|
||
|
details.receiver = plus.android.implements("io.dcloud.feature.internal.reflect.BroadcastReceiver", {
|
||
|
onReceive: function(context, intent) {
|
||
|
console.log("intent", intent);
|
||
|
plus.android.importClass(intent);
|
||
|
let content = intent.getStringExtra("scannerdata");
|
||
|
common_vendor.index.$emit("scancodedate", content.replace(/\n/g, ""));
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
function startScan() {
|
||
|
details.activity.registerReceiver(details.receiver, details.intentFilter);
|
||
|
}
|
||
|
function stopScan() {
|
||
|
details.activity.unregisterReceiver(details.receiver);
|
||
|
}
|
||
|
return {
|
||
|
startScan,
|
||
|
stopScan,
|
||
|
initScan
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||
|
return {};
|
||
|
}
|
||
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "F:/物流/logPm/compoment/saomiao2.vue"]]);
|
||
|
wx.createComponent(Component);
|