Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
doublescreen-front
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pengguangpu
doublescreen-front
Commits
3a05fea7
Commit
3a05fea7
authored
Feb 03, 2020
by
jiangjiantao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
扫码枪工具类
parent
c48667ff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
scan.js
utils/scan.js
+43
-0
No files found.
utils/scan.js
0 → 100644
View file @
3a05fea7
export
default
class
scan
{
static
Page
(
page
)
{
[
'onShow'
,
'onHide'
,
'onUnload'
].
forEach
((
f
)
=>
{
const
raw
=
page
[
f
];
var
code
=
''
;
var
isScaning
=
false
;
page
[
f
]
=
(...
args
)
=>
{
if
(
f
===
'onShow'
)
{
if
(
!
page
.
_keyEventListener
)
{
my
.
ix
.
onKeyEventChange
(
page
.
_keyEventListener
=
(
r
)
=>
{
let
cur
=
getCurrentPages
().
slice
(
-
1
)[
0
];
if
(
cur
&&
cur
.
onKeyPress
){
if
(
isScaning
==
false
)
{
isScaning
=
true
code
=
(
r
.
keyCode
-
7
)
+
''
setTimeout
(()
=>
{
cur
.
onKeyPress
.
call
(
cur
,
code
);
isScaning
=
false
},
500
);
}
else
{
//特殊处理 keycode需要减7
code
=
code
+
(
r
.
keyCode
-
7
)
}
}
});
}
}
else
if
(
f
===
'onHide'
||
f
===
'onUnload'
)
{
if
(
page
.
_keyEventListener
)
{
my
.
ix
.
offKeyEventChange
(
page
.
_keyEventListener
);
page
.
_keyEventListener
=
null
;
}
}
if
(
raw
instanceof
Function
)
{
let
cur
=
getCurrentPages
().
slice
(
-
1
)[
0
];
raw
.
call
(
cur
,
...
args
);
}
};
});
return
Page
(
page
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment