Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bh_face_counter
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄天晨
bh_face_counter
Commits
3919a2b1
Commit
3919a2b1
authored
Jan 16, 2021
by
zeven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自动点击模块支持动态配置
parent
f7fe935e
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
126 additions
and
18 deletions
+126
-18
.eslintrc.js
.eslintrc.js
+1
-0
android
android
+1
-1
searchGoods.js
src/components/searchGoods.js
+2
-1
FacePage.js
src/pages/FacePage.js
+5
-4
VerticalPage.js
src/pages/VerticalPage.js
+7
-11
AutoClick.js
src/utils/AutoClick.js
+60
-1
mitt.js
src/utils/mitt.js
+50
-0
No files found.
.eslintrc.js
View file @
3919a2b1
...
...
@@ -2,6 +2,7 @@ module.exports = {
root
:
true
,
extends
:
'@react-native-community'
,
rules
:
{
"eslint-comments/no-unlimited-disable"
:
0
,
"react-native/no-inline-styles"
:
0
,
"no-unused-vars"
:
2
,
"no-eval"
:
0
,
...
...
android
@
1fbbb7eb
Subproject commit
03b417e84da4ae78717555dce2d9e414f036d6e4
Subproject commit
1fbbb7eba77679e3f994946bbff48304a7206ea8
src/components/searchGoods.js
View file @
3919a2b1
...
...
@@ -60,7 +60,8 @@ class SearchGoods extends React.Component {
<
Text
style
=
{
styles
.
searchBtn
}
onPress
=
{()
=>
{
cancelSearch
(),
this
.
setState
({
goodsArr
:
[]});
cancelSearch
();
this
.
setState
({
goodsArr
:
[]});
}}
>
取消
<
/Text
>
...
...
src/pages/FacePage.js
View file @
3919a2b1
import
React
,
{
Component
}
from
'react'
;
import
{
View
,
Text
,
Image
,
DeviceEventEmitter
}
from
'react-native'
;
import
{
View
,
Text
,
Image
}
from
'react-native'
;
import
AsyncStorage
from
'@react-native-community/async-storage'
;
import
{
connect
}
from
'react-redux'
;
// import RtcEngine from 'react-native-agora';
...
...
@@ -64,14 +64,15 @@ class FacePage extends Component {
}
const
setting
=
await
AutoClick
.
isSettingsOn
();
if
(
!
setting
)
this
.
setState
({
setting
:
true
});
// 展示按钮
DeviceEventEmitter
.
addListener
(
'wxpayfaceRegister'
,
async
()
=>
{
AutoClick
.
on
(
'wxpayfaceRegister'
,
async
()
=>
{
await
AutoClick
.
clickBackKey
();
if
(
this
.
faceBusy
)
return
;
this
.
faceBusy
=
true
;
await
this
.
wechatFace
();
// 点击开通重新调用
this
.
faceBusy
=
false
;
});
// 监听微信输入手机号事件
DeviceEventEmitter
.
addListener
(
'wxpayfaceInput
'
,
({
text
})
=>
{
AutoClick
.
on
(
'AccessibilityClick
'
,
({
text
})
=>
{
if
(
!
text
)
return
;
const
match
=
/^
\[(
.+
)
]$/
.
exec
(
text
);
if
(
!
match
)
return
;
...
...
@@ -314,7 +315,7 @@ class FacePage extends Component {
Speech
.
speak
(
tipText
);
if
(
ret
.
code
!==
1
)
{
this
.
setState
({
tip
:
tipText
,
tipsModal
:
true
,
loadingModal
:
false
});
}
}
else
if
(
this
.
sense
)
this
.
setState
({
loadingModal
:
false
});
}
}
else
{
Speech
.
speak
(
'正在重新识别,请靠中间站稳'
);
...
...
src/pages/VerticalPage.js
View file @
3919a2b1
import
React
,
{
Component
}
from
'react'
;
import
{
View
,
Text
,
Image
,
FlatList
,
Modal
,
Button
,
DeviceEventEmitter
,
}
from
'react-native'
;
import
{
View
,
Text
,
Image
,
FlatList
,
Modal
,
Button
}
from
'react-native'
;
import
AsyncStorage
from
'@react-native-community/async-storage'
;
import
Swiper
from
'react-native-swiper'
;
import
QRCode
from
'react-native-qrcode-svg'
;
...
...
@@ -65,8 +57,12 @@ class VerticalPage extends Component {
}
}
this
.
initSetting
();
DeviceEventEmitter
.
addListener
(
'wxpayfaceRegister'
,
()
=>
{
this
.
wxFacepay
();
// 点击开通重新调用
AutoClick
.
on
(
'wxpayfaceRegister'
,
async
()
=>
{
await
AutoClick
.
clickBackKey
();
if
(
this
.
faceBusy
)
return
;
this
.
faceBusy
=
true
;
await
this
.
wxFacepay
();
// 点击开通重新调用
this
.
faceBusy
=
false
;
});
}
...
...
src/utils/AutoClick.js
View file @
3919a2b1
import
{
NativeModules
}
from
'react-native'
;
import
{
NativeModules
,
DeviceEventEmitter
}
from
'react-native'
;
import
mitt
from
'../utils/mitt'
;
// 事件常数值参考:https://www.apiref.com/android-zh/android/view/accessibility/AccessibilityEvent.html
let
AutoClick
=
{};
const
emitter
=
mitt
();
if
(
!
NativeModules
.
AutoClick
)
{
AutoClick
=
{
...
...
@@ -14,7 +18,62 @@ if (!NativeModules.AutoClick) {
return
enable
;
},
goSetting
:
NativeModules
.
AutoClick
.
goSetting
,
clickBackKey
:
()
=>
{
const
{
clickBackKey
}
=
NativeModules
.
AutoClick
;
return
clickBackKey
&&
clickBackKey
();
},
setEvent
:
(...
arg
)
=>
{
const
{
setEvent
}
=
NativeModules
.
AutoClick
;
setEvent
&&
setEvent
(...
arg
);
},
...
emitter
,
};
const
wxPkg
=
'com.tencent.wxpayface'
;
const
alPkg
=
'com.alipay.zoloz.smile'
;
const
events
=
{
wxpayfaceConfirm
:
{
pkgName
:
wxPkg
,
method
:
'clickByText'
,
search
:
'确认支付'
,
parent
:
true
,
},
wxpayfaceRegister
:
{
pkgName
:
wxPkg
,
method
:
'clickById'
,
search
:
`
${
wxPkg
}
:id/container_register_allow_button`
,
parent
:
false
,
},
smileConfirm
:
{
pkgName
:
alPkg
,
method
:
'clickByExact'
,
search
:
'确认'
,
parent
:
true
,
},
smilePayConfirm
:
{
pkgName
:
alPkg
,
method
:
'clickByExact'
,
search
:
'确认支付'
,
parent
:
true
,
},
};
Object
.
keys
(
events
).
map
(
key
=>
{
AutoClick
.
setEvent
(
key
,
events
[
key
]);
});
DeviceEventEmitter
.
addListener
(
'AccessibilityEvent'
,
e
=>
{
if
(
e
&&
e
.
key
)
emitter
.
emit
(
e
.
key
);
});
DeviceEventEmitter
.
addListener
(
'AccessibilityClick'
,
e
=>
{
emitter
.
emit
(
'AccessibilityClick'
,
e
);
});
// 兼容旧版本代码
DeviceEventEmitter
.
addListener
(
'wxpayfaceInput'
,
e
=>
{
emitter
.
emit
(
'AccessibilityClick'
,
e
);
});
DeviceEventEmitter
.
addListener
(
'wxpayfaceRegister'
,
()
=>
{
emitter
.
emit
(
'wxpayfaceRegister'
);
});
}
export
default
AutoClick
;
src/utils/mitt.js
0 → 100644
View file @
3919a2b1
/* eslint-disable */
/** Mitt: Tiny (~200b) functional event emitter / pubsub.
* @name mitt
* @returns {Mitt}
*/
function
mitt
(
all
)
{
all
=
all
||
Object
.
create
(
null
);
return
{
/**
* Register an event handler for the given type.
*
* @param {String} type Type of event to listen for, or `"*"` for all events
* @param {Function} handler Function to call in response to given event
* @memberOf mitt
*/
on
:
function
on
(
type
,
handler
)
{
(
all
[
type
]
||
(
all
[
type
]
=
[])).
push
(
handler
);
},
/**
* Remove an event handler for the given type.
*
* @param {String} type Type of event to unregister `handler` from, or `"*"`
* @param {Function} handler Handler function to remove
* @memberOf mitt
*/
off
:
function
off
(
type
,
handler
)
{
if
(
all
[
type
])
{
all
[
type
].
splice
(
all
[
type
].
indexOf
(
handler
)
>>>
0
,
1
);
}
},
/**
* Invoke all handlers for the given type.
* If present, `"*"` handlers are invoked after type-matched handlers.
*
* @param {String} type The event type to invoke
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
* @memberOf mitt
*/
emit
:
function
emit
(
type
,
evt
)
{
(
all
[
type
]
||
[]).
slice
().
map
(
function
(
handler
)
{
handler
(
evt
);
});
(
all
[
'*'
]
||
[]).
slice
().
map
(
function
(
handler
)
{
handler
(
type
,
evt
);
});
},
};
}
module
.
exports
=
mitt
;
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