如何在uniapp小程序和app中支持pad扫码枪
🙂前言
扫条码通常直接调用uniapp的官方api接口拉起摄像头来实现,但是新出的平板型pda扫码枪中,操作员可能更习惯pda操作模式,而不是通过点击UI交互使用摄像头,这时应该如何在uniapp小程序和app中支持pad扫码枪?本文分享实现uniapp小程序和app中支持pad扫码枪的方法步骤。
基于vue2项目代码中添加,vue3语法糖的组合式写法差异点业务代码页面,其他都是一致的,晚点小波会同步更新在vue3+vite+typescript+pinia+uni-ui+pnpm项目中。
🙂第一步:utils文件夹创建个pdaScan.js文件
1 |
|
🧐第二步:入口main.js文件添加代码
1 |
|
🤔第三步:业务代码文件x.vue中调用
1 |
|
😚常见pda扫码枪对应的广播名称code
引用: 常见扫码枪广播名称[1]
品牌 | 品牌名称 | 型号 | 版本号 | 广播名 | 广播接收名 |
---|---|---|---|---|---|
智联天地 | alps | simphone | base_v1.3.13 | android.intent.action.RECEIVE_SCANDATA_BROADCAST | android.intent.extra.SCAN_BROADCAST_DATA |
智联天地 | alps | simphone | base-m8_v1.6.13 | android.intent.action.RECEIVE_SCANDATA_BROADCAST | android.intent.extra.SCAN_BROADCAST_DATA |
智联天地 | alps | thimfone | android.intent.action.RECEIVE_SCANDATA_BROADCAST | android.intent.extra.SCAN_BROADCAST_DATA | |
智联天地 | alps | N5 | android.intent.action.RECEIVE_SCANDATA_BROADCAST | android.intent.extra.SCAN_BROADCAST_DATA | |
智联天地 | alps | n5 | android.intent.action.RECEIVE_SCANDATA_BROADCAST | android.intent.extra.SCAN_BROADCAST_DATA | |
智联天地 | N5S | ||||
智联天地 | zltd | N7e | nlscan.action.SCANNER_RESULT | SCAN_BARCODE1 | |
智联天地 | NEOLEX | android.intent.action.SCANRESULT | value | ||
智联天地 | Android TD | android.intent.action.SCANRESULT | value | ||
智联天地 | Alps Android | android.intent.action.SCANRESULT | value | ||
智联天地 | Android | android.intent.action.SCANRESULT | value | ||
智联天地 | X7 | android.intent.action.SCANRESULT | value | ||
新大陆 | Newland | NLS-MT65W | nlscan.action.SCANNER_RESULT | SCAN_BARCODE1或SCAN_BARCODE2 | |
新大陆 | NEWLAND | NLS-MT60 | android.intent.action.RECEIVE_SCANDATA_BROADCAST | android.intent.extra.SCAN_BROADCAST_DATA | |
新大陆 | NEWLAND | n5 | android.intent.action.RECEIVE_SCANDATA_BROADCAST | android.intent.extra.SCAN_BROADCAST_DATA | |
新大陆 | NEWLAND | simphone | android.intent.action.RECEIVE_SCANDATA_BROADCAST | android.intent.extra.SCAN_BROADCAST_DATA | |
新大陆 | NEWLAND | N5 | android.intent.action.RECEIVE_SCANDATA_BROADCAST | android.intent.extra.SCAN_BROADCAST_DATA | |
新大陆 | NEWLAND | N5S | android.intent.action.RECEIVE_SCANDATA_BROADCAST | android.intent.extra.SCAN_BROADCAST_DATA | |
新大陆 | NEWLAND | NLS-MT60E | ACTION_BAR_SCAN EXTRA_SCAN_DATA | ||
新大陆 | NEWLAND | thimfone | nlscan.action.SCANNER_RESULT | SCAN_BARCODE1,SCAN_BARCODE2 | |
新大陆 | NEWLAND | MT65 | nlscan.action.SCANNER_RESULT | SCAN_BARCODE1,SCAN_BARCODE3 | |
新大陆 | NEWLAND | NLS-MT65 | nlscan.action.SCANNER_RESULT | SCAN_BARCODE1,SCAN_BARCODE4 | |
新大陆 | NEWLAND | NLS-MT66 | nlscan.action.SCANNER_RESULT | SCAN_BARCODE1,SCAN_BARCODE5 | |
新大陆 | NEWLAND | NLS-MT90 | nlscan.action.SCANNER_RESULT | SCAN_BARCODE1,SCAN_BARCODE6 | |
东大 | AUTOID Q7 | com.android.server.scannerservice.broadcast,com.android.server.aa | scannerdata | ||
东大 | AUTOID | msm8610 | com.android.server.scannerservice.broadcast,com.android.server.aa | scannerdata | |
东大 | AUTOID | PDT-900 | com.android.server.scannerservice.broadcast,com.android.server.aa | scannerdata | |
东大 | AUTOID | PDT-90P | com.android.server.scannerservice.broadcast,com.android.server.aa | scannerdata | |
东大 | AUTOID | AUTOID9 | com.android.server.scannerservice.broadcast,com.android.server.aa | scannerdata | |
东大 | AUTOID | PDT-90F | com.android.server.scannerservice.broadcast,com.android.server.aa | scannerdata | |
东大 | SEUIC | AUTOID Q9 | com.android.server.scannerservice.broadcast,com.android.server.aa | scannerdata | |
东大 | SEUIC | D310C | com.android.server.scannerservice.broadcast,com.android.server.aa | scannerdata | |
东大 | SEUIC | CRUISE Ge | com.android.server.scannerservice.broadcast,com.android.server.aa | scannerdata | |
优博讯 | qcom | Android Handheld Terminal | com.barcode.sendBroadcast | BARCODE | |
优博讯 | qcom | CRUISE | com.android.server.scannerservice.broadcast,com.android.server.aa | scannerdata | |
优博讯 | qcom | i6200S | android.intent.ACTION_DECODE_DATA | barcode_string,scannerdata | |
优博讯 | qcom | i6200A | android.intent.ACTION_DECODE_DATA | barcode_string,scannerdata | |
优博讯 | qcom | I6200A | android.intent.ACTION_DECODE_DATA | barcode_string,scannerdata | |
优博讯 | qcom | i6200S | 安卓4.1版本 | urovo.rcv.message | barcode |
优博讯 | Urovo | DT40 | android.intent.ACTION_DECODE_DATA | barcode_string | |
肖邦 | SUPOIN | PDA | com.android.server.scannerservice.broadcast | scannerdata | |
肖邦 | SUPOIN | SHT30 | com.android.server.scannerservice.broadcast | scannerdata | |
肖邦 | SUPOIN | SHT36 | com.android.server.scannerservice.broadcast | scannerdata | |
霍尼韦尔 | Honeywell | EDA | com.honeywell.scan.broadcast | data | |
捷宝 | JB | com.jb.action.GET_SCANDATA | data | ||
商米 | SUNMI | L2 | com.sunmi.scanner.ACTION_DATA_CODE_RECEIVED | data | |
商米 | SUNMI | V2_PRO | com.sunmi.scanner.ACTION_DATA_CODE_RECEIVED | data | |
凯立 | KAICOM,kaicom | W660 | com.android.receive_scan_action | data | |
凯立 | KAICOM,kaicom | K211 | com.android.receive_scan_action | data | |
凯立 | KAICOM,kaicom | K7 | com.android.receive_scan_action | data | |
盈达 | iData | K1 | android.intent.action.SCANRESULT | value | |
盈达 | Android | android.intent.action.SCANRESULT | value | ||
思必拓 | KT40 se4500 | KT40 se4500 | 条码action=com.se4500.onDecodeComplete,string数据key=se4500,开启扫描action=com.geomobile.se4500barcode,停止扫描action=com.geomobile.se4500barcode.poweroff | se4500 | |
得景 | 条码action=techain.intent.action.DISPLAY_SCAN_RESULT,string数据key=decode_data | decode_data | |||
新石器 | 条码action=techain.intent.action.DISPLAY_SCAN_RESULT,string数据key=decode_data | decode_data | |||
安能定制广播 | 条码action=com.android.receive_scan_action,string数据key=data | data | |||
圆通定制广播 | 条码action=com.yto.action.GET_SCANDATA,string数据key=data,开启扫描action=com.yto.action.SCAN_SWITCH,开启扫描传值int,key=extra,值=1,关闭扫描action=com.yto.action.SCAN_SWITCH,关闭扫描传值int,key=extra,值=0 | data |
😊总结
思路很简单,就是uniapp小程序启动时调用pda的广播函数,业务代码中直接获取对应pda返回的条码信息即可。
😊来自小波的 bilibili 视频教程
🙂相关参考资料链接
『旅行者』,帮小波关注一波公众号吧。
小波需要100位关注者才能申请红包封面设计资格,万分感谢!
关注后可微信小波,前66的童鞋可以申请专属红包封面设计。
微信
支付宝