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
918bc353
Commit
918bc353
authored
Oct 22, 2020
by
zeven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增烟柜设备刷脸打开货柜
parent
84f29666
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
126 additions
and
1 deletions
+126
-1
App.js
src/App.js
+3
-0
SmokePage.js
src/pages/SmokePage.js
+119
-0
router.js
src/router.js
+2
-0
authLogin.js
src/utils/authLogin.js
+2
-1
No files found.
src/App.js
View file @
918bc353
...
...
@@ -197,6 +197,9 @@ class App extends React.Component {
}
else
if
(
this
.
device
===
'face'
)
{
// 人脸设备
await
this
.
setState
({
curRoute
:
'face'
});
}
else
if
(
this
.
device
===
'faceSmoke'
)
{
// 人脸烟柜设备
await
this
.
setState
({
curRoute
:
'smoke'
});
}
await
counterInterval
(
dispatch
,
res
.
data
.
expiresIn
);
this
.
listen
();
...
...
src/pages/SmokePage.js
0 → 100644
View file @
918bc353
import
React
,
{
Component
}
from
'react'
;
import
{
View
,
Text
,
Image
}
from
'react-native'
;
import
{
connect
}
from
'react-redux'
;
import
Touch
from
'../components/Touch'
;
import
Speech
from
'../utils/Speech'
;
import
Smilepay
from
'../utils/Smilepay'
;
import
Toast
from
'../components/Toast'
;
import
delay
from
'../utils/delay'
;
@
connect
()
class
SmokePage
extends
Component
{
state
=
{
tipText
:
'触摸屏幕,人脸识别,打开货柜'
,
};
async
componentDidMount
()
{
this
.
listen
();
}
listen
=
async
()
=>
{
try
{
while
(
!
window
.
socket
)
{
await
delay
(
1000
);
}
if
(
!
window
.
socket
.
hasListeners
(
'doorLogin'
))
{
// 扫码验证成功
window
.
socket
.
on
(
'doorLogin'
,
this
.
handleDoorLogin
);
}
}
catch
(
e
)
{
console
.
log
(
e
);
}
};
alipayinfo
=
async
()
=>
{
const
{
data
}
=
await
this
.
props
.
dispatch
({
type
:
'goods/alipayinfo'
});
this
.
alipayInfo
=
await
Smilepay
.
init
(
data
);
if
(
this
.
alipayInfo
.
code
===
'1000'
)
this
.
alipayInfo
.
metaInfo
=
JSON
.
parse
(
this
.
alipayInfo
.
metaInfo
);
return
this
.
alipayInfo
;
};
handleDoorLogin
=
async
ret
=>
{
if
(
ret
&&
ret
.
msg
)
{
Speech
.
speak
(
ret
.
msg
);
}
};
smileFace
=
async
()
=>
{
await
this
.
alipayinfo
();
if
(
!
this
.
alipayInfo
||
!
this
.
alipayInfo
.
metaInfo
)
{
this
.
props
.
speak
(
'刷脸支付启动失败,请重新刷脸或扫码支付'
,
true
);
return
;
}
const
{
data
}
=
await
this
.
props
.
dispatch
({
type
:
'goods/smilepay'
,
service_id
:
'auth'
,
zimmetainfo
:
this
.
alipayInfo
.
metaInfo
,
});
if
(
data
.
code
===
1
)
{
const
res
=
await
Smilepay
.
verify
(
JSON
.
parse
(
data
.
data
));
if
(
res
.
code
!==
'1000'
)
{
Toast
.
show
(
res
.
msg
);
return
;
}
const
ret
=
await
this
.
props
.
dispatch
({
type
:
'store/wxdoor'
,
alipayUid
:
res
.
uid
,
});
this
.
handleDoorLogin
(
ret
);
}
};
render
()
{
const
{
tipText
}
=
this
.
state
;
return
(
<
View
style
=
{
styles
.
container
}
>
<
Touch
onPress
=
{
this
.
smileFace
}
>
<
Image
source
=
{
require
(
'../assets/ai/face.gif'
)}
/
>
<
/Touch
>
<
View
style
=
{
styles
.
tip
}
>
<
Image
resizeMode
=
"contain"
style
=
{
styles
.
tipImage
}
source
=
{
require
(
'../assets/Jike/alipay.png'
)}
/
>
<
Text
style
=
{
styles
.
tipText
}
>
{
tipText
}
<
/Text
>
<
/View
>
<
/View
>
);
}
}
const
styles
=
{
container
:
{
flex
:
1
,
justifyContent
:
'center'
,
alignItems
:
'center'
,
backgroundColor
:
'black'
,
},
tip
:
{
position
:
'absolute'
,
flexDirection
:
'row'
,
bottom
:
0
,
width
:
'100%'
,
height
:
80
,
backgroundColor
:
'#FC4000'
,
justifyContent
:
'center'
,
alignItems
:
'center'
,
},
tipImage
:
{
width
:
60
,
},
tipText
:
{
color
:
'white'
,
fontSize
:
20
,
},
};
export
default
SmokePage
;
src/router.js
View file @
918bc353
...
...
@@ -2,6 +2,7 @@ import HomePage from './pages/HomePage';
import
VerticalPage
from
'./pages/VerticalPage'
;
import
AuthPage
from
'./pages/AuthPage'
;
import
FacePage
from
'./pages/FacePage'
;
import
SmokePage
from
'./pages/SmokePage'
;
import
ScalesPage
from
'./pages/test/ScalesPage'
;
import
SocketPage
from
'./pages/test/SocketPage'
;
...
...
@@ -12,4 +13,5 @@ export default {
socket
:
SocketPage
,
auth
:
AuthPage
,
face
:
FacePage
,
smoke
:
SmokePage
,
};
src/utils/authLogin.js
View file @
918bc353
...
...
@@ -34,12 +34,13 @@ export const counterLogin = async ({key, secret, device = 'counter', host}) => {
await
loginError
(
'请输入门店密钥'
);
return
;
}
const
supportDevices
=
[
'counter'
,
'face'
,
'faceEnter'
,
'faceLeave'
];
const
supportDevices
=
[
'counter'
,
'face'
,
'
smoke'
,
'
faceEnter'
,
'faceLeave'
];
if
(
supportDevices
.
indexOf
(
device
)
<
0
)
{
await
loginError
(
'不支持的设备类型'
);
return
;
}
await
Toast
.
loading
(
'授权认证中'
);
if
(
device
===
'smoke'
)
device
=
'faceSmoke'
;
const
action
=
{
type
:
'admin/auth'
,
key
,
secret
,
login
:
device
,
host
};
// const { dispatch } = this.props;
// const res = await dispatch(action);
...
...
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