Commit e3989226 authored by jiangjiantao's avatar jiangjiantao

兼容摄像头

parent ae1a50ed
...@@ -38,12 +38,12 @@ Page({ ...@@ -38,12 +38,12 @@ Page({
success: (res) => { success: (res) => {
console.info(`onBuddyMessage success: ${JSON.stringify(res)}`); console.info(`onBuddyMessage success: ${JSON.stringify(res)}`);
if (res.action == ACTION_GO_SCAN) { if (res.action == ACTION_GO_SCAN) {
if (res.data.printEnabled != null) { // if (res.data.printEnabled != null) {
my.setStorageSync({ // my.setStorageSync({
key: 'printEnabled', // key: 'printEnabled',
data: { enabled: res.data.printEnabled } // data: { enabled: res.data.printEnabled }
}) // })
} // }
my.ix.sendBuddyMessage({ my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID // 填入目标小程序的 AppID
......
...@@ -20,36 +20,20 @@ export default class scan { ...@@ -20,36 +20,20 @@ export default class scan {
my.ix.onKeyEventChange(page._keyEventListener = (r) => { my.ix.onKeyEventChange(page._keyEventListener = (r) => {
let cur = getCurrentPages().slice(-1)[0]; let cur = getCurrentPages().slice(-1)[0];
if (cur && cur.onKeyPress) { if (cur && cur.onKeyPress) {
if (isScaning == false) {
if (k >= 7 && k <= 16) { isScaning = true
// 将 keyCode 的值转换为扫描的实际数值。 code = (r.keyCode - 7) + ''
if (this._barcode === undefined) setTimeout(() => {
code = ''; //兼容扫描枪
code += (k - 7).toString(); cur.onKeyPress.call(cur, code);
return; isScaning = false
} else if (k === 66) { }, 700);
// 末尾追加 Enter 确认。 } else {
console.log('Scan Barcode', code); //特殊处理 keycode需要减7
code = ''; if (r.keyCode >= 7 && r.keyCode <= 16) {
return; code = code + (r.keyCode - 7)
}
} }
// if (isScaning == false) {
// isScaning = true
// code = (r.keyCode - 7) + ''
// setTimeout(() => {
// //兼容扫描枪
// if(code.endsWith("5913")){
// code = code.substring(0,code.length - 4)
// }
// cur.onKeyPress.call(cur, code);
// isScaning = false
// }, 700);
// } else {
// //特殊处理 keycode需要减7
// code = code + (r.keyCode - 7)
// }
} }
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment