扫码JSSDK载入
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import './polyfill';
|
||||
import _global from './polyfill/_global';
|
||||
import { setConfig, getVersion } from './services/config';
|
||||
import { onScanListener, offScanListener, setStatusListener, getStatus, startScan, stopScan, clear } from './services/provider/scan';
|
||||
import { initWxJssdk } from './services/wx';
|
||||
@@ -8,10 +7,6 @@ import { printDebug } from './utils/logger';
|
||||
let _readyPromise = null;
|
||||
let _calledReady = false;
|
||||
|
||||
(function () {
|
||||
_global.__IScanReady__ && _global.__IScanReady__();
|
||||
})();
|
||||
|
||||
export function isReadyCalled() {
|
||||
return _calledReady;
|
||||
}
|
||||
@@ -24,9 +19,9 @@ function config(config) {
|
||||
return _readyPromise;
|
||||
}
|
||||
_readyPromise = Promise.resolve().then(() => {
|
||||
printDebug('-------------------------------');
|
||||
printDebug('-------------------------------------');
|
||||
printDebug('sdk_version:', getVersion());
|
||||
printDebug('-------------------------------');
|
||||
printDebug('-------------------------------------');
|
||||
initWxJssdk();
|
||||
return Promise.resolve().then(() => {
|
||||
_calledReady = true;
|
||||
|
||||
17
src/index.js
17
src/index.js
@@ -1,11 +1,24 @@
|
||||
import core from "./_core";
|
||||
import _global from './polyfill/_global';
|
||||
import { exportSDK } from './_export';
|
||||
|
||||
const IScan = exportSDK(core, null, "config", "setStatusListener", "onScanListener",
|
||||
"offScanListener", "stopScan", "startScan", "clear");
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.IScan = IScan
|
||||
function dispatchIScanReady() {
|
||||
_global.__IScanReady__ && _global.__IScanReady__();
|
||||
if (typeof Event === "function") {
|
||||
_global.dispatchEvent(new Event("IScanReady"));
|
||||
} else {
|
||||
let event = document.createEvent("Event");
|
||||
event.initEvent("IScanReady", true, true);
|
||||
_global.dispatchEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof _global !== 'undefined') {
|
||||
_global.IScan = IScan;
|
||||
dispatchIScanReady();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -47,7 +47,6 @@ function onScannerKeydown(event) {
|
||||
if (result) {
|
||||
stopScannerEvent(event);
|
||||
}
|
||||
console.log("onScannerKeydown", result);
|
||||
clearScannerValue();
|
||||
if (result && _scannerCallback) {
|
||||
_scannerCallback(result);
|
||||
|
||||
Reference in New Issue
Block a user