剩余模块:生产退料

This commit is contained in:
2025-06-03 02:55:51 +08:00
parent a12f56d2be
commit a59dd54c27
24 changed files with 9139 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
## 1.0.02022-12-17
create

View File

@@ -0,0 +1,73 @@
<template>
<view></view>
</template>
<script>
import scaninput from './scanInput.js'
// #ifdef APP-PLUS
scaninput.initScan()
scaninput.startScan()
// #endif
export default {
name:"scan-listener",
created() {
scaninput.install(this.scanHandle)
uni.$on('scan_handle', this.scanHandle)
},
beforeDestroy() {
scaninput.uninstall(this.scanHandle)
},
methods: {
changeFun(str) {
if (this.debounceTimer !== null) clearTimeout(this.debounceTimer)
this.debounceTimer = setTimeout(() => {
this.$emit('scan', this.inputVal)
this.inputVal = ''
}, 500)
},
onEvent(event) {
console.log(event);
if (event.key != 'Enter' && event.key != 'PrintScreen' && event.key != 'Shift' && event.key != 'Unidentified') { // 拼接输入的值Enter与PrintScreen是物理按钮要排除
this.inputVal = this.inputVal + event.key
}
if(this.inputVal) {
this.changeFun(this.inputVal)
}
},
scanHandle(code) {
this.$emit('scan', code)
}
},
data() {
return {
inputVal: '',
debounceTimer:null
};
}
}
</script>
<script module="keyboard" lang="renderjs">
export default {
mounted () {
const onKey = (event) => {
const keys1 = ['type', 'timeStamp']
const keys2 = ['altKey', 'code', 'ctrlKey', 'isComposing', 'key', 'location', 'metaKey', 'repeat', 'shiftKey']
const keys3 = ['char', 'charCode', 'keyCode', 'keyIdentifier', 'keyLocation', 'which']
const data = {}
keys1.concat(keys2, keys3).forEach(key => {
data[key] = event[key]
})
this.$ownerInstance.callMethod('onEvent', data)
}
const names = ['keyup'] //'keydown',
names.forEach(name => {
document.addEventListener(name, onKey, false)
})
}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,55 @@
let main, receiver, filter, _codeQueryTag = false, temp = [], init = false, start = false;
export default {
initScan() {
if(init) return
let _this = this;
main = plus.android.runtimeMainActivity(); //获取activity
var IntentFilter = plus.android.importClass('android.content.IntentFilter');
filter = new IntentFilter();
//android.intent.ACTION_DECODE_DATA
filter.addAction("com.uniappPda.ACTION"); // 换你的广播动作你的pda设备里面看
receiver = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
onReceive: function(context, intent) {
plus.android.importClass(intent);
let code = intent.getStringExtra("com.uniapp.gatedge"); // 换你的广播标签你的pda设备里面看
_this.queryCode(code);
}
});
init = true
},
startScan() {
if(!start) {
start = true
main.registerReceiver(receiver, filter);
}
},
stopScan() {
if(start) {
start = false
main.unregisterReceiver(receiver);
}
},
install(fn) {
if(typeof fn == 'function' && !~temp.indexOf(fn)) temp.push(fn)
},
uninstall(fn) {
if(typeof fn == 'function') {
const index = temp.find(i=>i == fn)
if(~index) temp.splice(index, 1)
}
},
queryCode: function(code) {
//防重复
// if (_codeQueryTag) return false;
// _codeQueryTag = true;
// setTimeout(function() {
// _codeQueryTag = false;
// }, 150);
if(temp && temp.length) {
temp[temp.length - 1](code)
}
uni.vibrateShort()
uni.$emit("qs_scanlistener_handle", code);
}
}

View File

@@ -0,0 +1,82 @@
{
"id": "qs-scanlistener",
"displayName": "qs-scanlistener PDA扫码",
"version": "1.0.0",
"description": "PDA扫码 兼容广播和键盘",
"keywords": [
"pda",
"扫码"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"type": "component-vue",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "y"
},
"App": {
"app-vue": "y",
"app-nvue": "n"
},
"H5-mobile": {
"Safari": "n",
"Android Browser": "n",
"微信浏览器(Android)": "n",
"QQ浏览器(Android)": "n"
},
"H5-pc": {
"Chrome": "n",
"IE": "n",
"Edge": "n",
"Firefox": "n",
"Safari": "n"
},
"小程序": {
"微信": "n",
"阿里": "n",
"百度": "n",
"字节跳动": "n",
"QQ": "n",
"钉钉": "n",
"快手": "n",
"飞书": "n",
"京东": "n"
},
"快应用": {
"华为": "n",
"联盟": "n"
}
}
}
}
}

View File

@@ -0,0 +1,20 @@
## qs-scanlistener PDA扫码
## 支持广播和键盘
---
### 广播动作可在main.js设置uni._qs_scanlistener_action = 你的广播动作名称, 默认android.intent.ACTION_DECODE_DATA
### 广播标签可在main.js设置uni._qs_scanlistener_label = 你的广播标签名称, 默认barcode_string
---
### 扫码结果也可以uni.$on('qs_scanlistener_handle', code=>{}) 中获取
---
Template
```html
<qs-scanlistener @scan="scan"></qs-scanlistener>
```
js
```javascript
methods: {
scan(code) {
console.log(code)
}
}
```