| 1234567891011121314151617181920212223242526 |
- const modal = uni.requireNativePlugin('modal');
- /**
- * 初始化idata扫描模块
- */
- export function useInit() {
- //获取module
- var barcodeModel = uni.requireNativePlugin("iData-BarcodePlugin-BarcodeModule")
- //使用示例
- barcodeModel.initScan((ret) => {
- console.log('初始化扫描', ret)
- });
- }
- /**
- * 全局监听扫描后结果
- * @param onChange 回调函数
- */
- export function useGlobalEvent(onChange) {
- //页面监听event事件,建议在页面onLoad方法里调用
- var globalEvent = uni.requireNativePlugin('globalEvent');
- globalEvent.addEventListener('iDataBarcodeEvent', function(e) {
- onChange && onChange(e)
- //条码结果示例:{"barcode","条码数据"}
- });
- }
|