# cordova-plugin-cipherlab-scanner **Repository Path**: 1428915751/cordova-plugin-cipherlab-scanner ## Basic Information - **Project Name**: cordova-plugin-cipherlab-scanner - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-08-02 - **Last Updated**: 2021-08-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## cordova项目 - npm install -g cordova@v9.0.0 安装cordova依赖 - cordova create C:\project\sitAndroid com.biz.pda sitPda 创建cordova项目 - cordova platform add android 添加android - cordova plugin remove cordova-plugin-cipherlab-scanner 删除cipherlab插件 - cordova plugin add https://gitee.com/1428915751/cordova-plugin-cipherlab-scanner.git 添加cipherlab插件 - 在www文件下执行cordova build android 命令 打包apk文件 ## 调试cordova项目 - 打开cordova项目里 platforms\android 进行调试 - \platforms\android\app\libs 插件的jar包 - \platforms\android\app\src\main\assets\www 打包后的静态资源文件 - \platforms\android\app\src\main\java\com\pobing\cipherlab\CipherLabScannerPlugin.java 调用sdk的java文件,主要修改此文件 - \platforms\android\platform_www\plugins\cordova-plugin-cipherlab-scanner\www\CipherLabScannerPlugin.js 插件的主要js - 调试的时候可以直接修改CipherLabScannerPlugin.java和CipherLabScannerPlugin.js,运行cordova build android命令,修改文件可以生效,方便调试。 ## 插件的制作 - https://www.jianshu.com/p/4792aa465a36 - https://developer.android.google.cn/studio/ ## 目前主要支持版本 - cipherlab R25 android7.1.2 ## vue文件使用cipherlab - 在vue的入口加入监听 deviceready 事件 ```py created() { document.addEventListener("deviceready", this.onDeviceReady, false); }, methods: { onDeviceReady() { this.initScanEvent(this.$config.scanner); if (this.pdaUseEnable) { this.pdaScanner.nativeListen(window.plugins, this.scanSuccessEvent, this.scanFailEvent); } } } ``` - 执行\src\utils\scanner\index.js中的nativeListen ```py if (this.type === "cipherlab") { if (plugin.cipherlab != null && plugin.cipherlab != undefined) { plugin.cipherlab.nativeListen( data => { dataFunction(data); }, error => { errorFunction(error); } ); } } ``` - 在vue文件中监听扫描枪扫描值,并且将扫描枪扫描值赋值给vue变量中。 ```py watch: { pdaScanData: { handler(data) { let input = document.activeElement.id; if (input == "username") { this.username = data.data; this.passwordFocus(); } else if (input == "password") { this.password = data.data; this.handleAction(); } }, deep: true } }, ``` ## cipherlab扫描枪设置 - 扫描枪无法调试设置:在cipherlab扫描枪中sofrware trigger的软件,进去退出即可 ![avatar](image/1.jpg) - 扫描枪69码设置:cipherlab扫描枪Readerconfig中,数据输出里的显示条码类型和显示条码长度,不要勾选 ![avatar](image/2.jpg)