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
ba38a958
Commit
ba38a958
authored
Jun 30, 2020
by
修福龙
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
e4b4948f
360778c1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
24 deletions
+68
-24
android
android
+1
-1
App.js
src/App.js
+26
-0
admin.js
src/models/admin.js
+3
-6
FacePage.js
src/pages/FacePage.js
+15
-6
Installer.js
src/utils/Installer.js
+3
-0
socketio.js
src/utils/socketio.js
+20
-11
No files found.
android
@
24e88792
Subproject commit
ea22824f4000883940b000f1e1854893e7463f1e
Subproject commit
24e88792277dde5f5560c1ae701ffbdcb9e47969
src/App.js
View file @
ba38a958
...
...
@@ -10,6 +10,7 @@ import router from './router';
import
models
from
'./models'
;
import
dva
from
'./utils/dva'
;
import
Restart
from
'./utils/Restart'
;
import
Installer
from
'./utils/Installer'
;
import
{
counterInterval
}
from
'./utils/authInterval'
;
import
{
host
}
from
'./utils/config'
;
...
...
@@ -88,6 +89,31 @@ class App extends React.Component {
dispatch
({
type
:
'admin/version'
});
});
}
if
(
!
window
.
socket
.
hasListeners
(
'installApp'
))
{
window
.
socket
.
on
(
'installApp'
,
({
url
})
=>
{
if
(
!
url
)
{
Toast
.
show
(
'下载链接不能为空'
);
return
;
}
const
match
=
url
.
match
(
/http
(
s*
)
:
\/\/
.+
\/(
.+
)
/
);
if
(
!
match
)
{
Toast
.
show
(
'下载链接错误'
);
return
;
}
const
file
=
match
[
2
];
Installer
.
download
(
url
,
file
).
then
(
apk
=>
{
if
(
apk
)
{
Installer
.
install
(
apk
);
}
});
});
}
if
(
!
window
.
socket
.
hasListeners
(
'uninstallApp'
))
{
window
.
socket
.
on
(
'uninstallApp'
,
({
pkg
})
=>
{
// packageName eg: com.vsu.package
Installer
.
uninstall
(
pkg
);
});
}
};
refresh
=
async
()
=>
{
...
...
src/models/admin.js
View file @
ba38a958
import
AsyncStorage
from
'@react-native-community/async-storage'
;
import
axios
from
'axios'
;
import
*
as
api
from
'../services/admin'
;
import
SocketIO
from
'../utils/socketio'
;
export
default
{
namespace
:
'admin'
,
...
...
@@ -21,11 +20,9 @@ export default {
};
}
else
{
// 使用原生SocketIO
window
.
socket
.
disconnect
();
window
.
socket
=
new
SocketIO
(
`
${
axios
.
defaults
.
baseURL
}
/socket.io/?token=
${
window
.
auth
.
token
}
`
,
);
window
.
socket
.
connect
();
window
.
socket
=
window
.
socket
.
initialize
({
query
:
`token=
${
window
.
auth
.
token
}
`
,
});
}
}
AsyncStorage
.
setItem
(
'auth'
,
JSON
.
stringify
(
auth
));
...
...
src/pages/FacePage.js
View file @
ba38a958
...
...
@@ -272,7 +272,7 @@ class FacePage extends Component {
authinfo
=
async
()
=>
{
const
rawdata
=
await
WxFacepay
.
rawdata
();
const
{
data
}
=
await
this
.
props
.
dispatch
({
type
:
'goods/
wxauth
info'
,
type
:
'goods/
face
info'
,
rawdata
,
});
return
data
;
...
...
@@ -286,13 +286,19 @@ class FacePage extends Component {
const
tipText
=
'正在人脸识别,请看向屏幕,靠中间站稳'
;
Speech
.
speak
(
tipText
);
this
.
setState
({
tip
:
tipText
});
const
auth
=
(
await
this
.
authinfo
())
||
{};
if
(
auth
.
return_code
===
'SUCCESS'
)
{
let
auth
=
(
await
this
.
authinfo
())
||
{};
if
(
auth
.
return_code
===
'SUCCESS'
||
(
auth
.
code
===
1
&&
auth
.
data
.
bizCode
===
'0000'
)
)
{
if
(
auth
.
data
)
{
auth
=
auth
.
data
;
}
const
params
=
{
appid
:
auth
.
appid
,
mch_id
:
auth
.
mch_id
,
appid
:
auth
.
appid
||
auth
.
subAppId
,
mch_id
:
auth
.
mch_id
||
auth
.
subMchId
,
store_id
:
this
.
storeKey
,
authinfo
:
auth
.
authinfo
,
authinfo
:
auth
.
authinfo
||
auth
.
authInfo
,
face_authtype
:
'FACEID-ONCE'
,
ask_unionid
:
1
,
};
...
...
@@ -309,6 +315,9 @@ class FacePage extends Component {
if
(
!
res
.
openid
)
{
return
;
}
// 没识别到人脸不开门
if
(
res
.
sub_openid
)
{
res
.
openid
=
res
.
sub_openid
;
}
const
ret
=
await
this
.
props
.
dispatch
({
type
:
'store/wxdoor'
,
openid
:
res
.
openid
,
...
...
src/utils/Installer.js
0 → 100644
View file @
ba38a958
import
{
NativeModules
}
from
'react-native'
;
export
default
NativeModules
.
Installer
;
src/utils/socketio.js
View file @
ba38a958
import
{
DeviceEventEmitter
,
NativeModules
,
Platform
}
from
'react-native'
;
import
{
debounce
}
from
'throttle-debounce'
;
let
SocketIO
=
NativeModules
.
SocketIO
;
...
...
@@ -17,10 +16,7 @@ class Socket {
this
.
handlers
=
{};
this
.
onAnyHandler
=
null
;
this
.
deviceEventSubscription
=
DeviceEventEmitter
.
addListener
(
'socketEvent'
,
this
.
_handleEvent
.
bind
(
this
),
);
DeviceEventEmitter
.
addListener
(
'socketEvent'
,
this
.
_handleEvent
.
bind
(
this
));
// Set default handlers
this
.
defaultHandlers
=
{
...
...
@@ -37,15 +33,11 @@ class Socket {
};
// Set initial configuration
this
.
host
=
host
;
this
.
config
=
config
;
this
.
sockets
.
initialize
(
host
,
config
);
}
debounceHandler
=
debounce
(
1000
,
true
,
event
=>
{
console
.
warn
(
event
.
name
);
const
res
=
event
.
hasOwnProperty
(
'items'
)
?
event
.
items
[
0
]
:
{};
this
.
handlers
[
event
.
name
](
res
);
});
_handleEvent
(
event
)
{
if
(
this
.
defaultHandlers
.
hasOwnProperty
(
event
.
name
))
{
this
.
defaultHandlers
[
event
.
name
](
event
);
...
...
@@ -63,10 +55,27 @@ class Socket {
return
this
.
handlers
.
hasOwnProperty
(
eventName
);
}
initialize
(
config
)
{
config
=
{...
this
.
config
,
...
config
};
this
.
disconnect
();
DeviceEventEmitter
.
removeAllListeners
(
'socketEvent'
);
const
socket
=
new
Socket
(
this
.
host
,
config
);
Object
.
keys
(
this
.
handlers
).
map
(
event
=>
{
const
handler
=
this
.
handlers
[
event
];
socket
.
on
(
event
,
handler
);
});
socket
.
connect
();
return
socket
;
}
getId
()
{
return
this
.
sockets
.
getId
();
}
updateQuery
(
query
)
{
return
this
.
sockets
.
updateQuery
(
query
);
}
connect
()
{
this
.
sockets
.
connect
();
}
...
...
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