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
4afa48be
Commit
4afa48be
authored
Sep 10, 2020
by
zeven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接支付宝刷脸进店接口
parent
6ab0a404
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
16 deletions
+62
-16
FacePage.js
src/pages/FacePage.js
+60
-14
store.js
src/services/store.js
+2
-2
No files found.
src/pages/FacePage.js
View file @
4afa48be
...
...
@@ -10,8 +10,10 @@ import OrderDetailsModal from '../components/OrderDetailsModal';
import
delay
from
'../utils/delay'
;
import
Speech
from
'../utils/Speech'
;
import
WxFacepay
from
'../utils/WxFacepay'
;
import
Smilepay
from
'../utils/Smilepay'
;
import
phone
from
'../assets/Vertical/phone.png'
;
import
{
onTalkCall
,
leaveTalkCall
}
from
'../utils/agora'
;
import
Toast
from
'../components/Toast'
;
const
{
width
}
=
Dimensions
.
get
(
'screen'
);
...
...
@@ -28,18 +30,21 @@ class FacePage extends Component {
current
:
1
,
tip
:
''
,
tipsModal
:
false
,
faceType
:
'wxpay'
,
};
async
componentWillMount
()
{
this
.
storeKey
=
await
AsyncStorage
.
getItem
(
'KEY'
);
let
contact
=
await
AsyncStorage
.
getItem
(
'CONTACT'
);
let
storeName
=
await
AsyncStorage
.
getItem
(
'NAME'
);
this
.
setState
({
contact
,
storeName
,
});
this
.
setState
({
contact
,
storeName
});
if
(
!
this
.
init
)
{
this
.
init
=
await
WxFacepay
.
init
();
if
(
!
this
.
init
)
{
// 微信刷脸失败,启动支付宝刷脸
this
.
init
=
true
;
this
.
setState
({
faceType
:
'alipay'
});
}
}
}
...
...
@@ -169,11 +174,15 @@ class FacePage extends Component {
}
};
face
=
()
=>
{
this
.
state
.
faceType
===
'wxpay'
?
this
.
wechatFace
()
:
this
.
smileFace
();
};
// device 代表当前打开的门
handleScaleChange
=
async
({
count
})
=>
{
if
(
count
===
-
1
)
{
// 重力感应开始识别
this
.
wechatF
ace
();
this
.
f
ace
();
}
else
if
(
count
===
0
)
{
// 重力感应归零
this
.
leaveC
();
...
...
@@ -281,6 +290,39 @@ class FacePage extends Component {
}
};
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
;
};
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'
,
fToken
:
res
.
fToken
,
});
this
.
handleDoorLogin
(
ret
);
}
};
// 语音通话请求
onCall
=
async
()
=>
{
const
{
talkCall
}
=
this
.
state
;
...
...
@@ -341,6 +383,11 @@ class FacePage extends Component {
tipsModal
,
}
=
this
.
state
;
let
{
dispatch
}
=
this
.
props
;
if
(
this
.
state
.
faceType
===
'alipay'
)
{
styles
.
header
=
{...
styles
.
header
,
backgroundColor
:
'#1b7dc7'
};
styles
.
btnCome
=
{...
styles
.
btnCome
,
backgroundColor
:
'#1b7dc7'
};
// styles.footer = {...styles.footer, backgroundColor: '#1b7dc7'};
}
return
(
<
View
style
=
{
styles
.
content
}
>
<
PhoneModal
...
...
@@ -396,10 +443,7 @@ class FacePage extends Component {
<
/View
>
<
View
style
=
{
styles
.
face
}
>
<
View
style
=
{
styles
.
faceRecogn
}
>
<
Touch
style
=
{
styles
.
faceGif
}
onPress
=
{()
=>
this
.
wechatFace
()}
feedback
=
{
false
}
>
<
Touch
style
=
{
styles
.
faceGif
}
onPress
=
{
this
.
face
}
feedback
=
{
false
}
>
<
Image
source
=
{
require
(
'../assets/Vertical/face.gif'
)}
style
=
{{
flex
:
1
,
width
}}
...
...
@@ -428,14 +472,16 @@ class FacePage extends Component {
<
/View
>
)}
<
/View
>
<
Touch
onPress
=
{()
=>
this
.
wechatFace
()}
style
=
{
styles
.
btnCome
}
feedback
=
{
false
}
>
<
Touch
onPress
=
{
this
.
face
}
style
=
{
styles
.
btnCome
}
feedback
=
{
false
}
>
<
View
style
=
{
styles
.
click
}
>
<
Image
source
=
{
require
(
'../assets/wxpay.png'
)}
source
=
{
this
.
state
.
faceType
===
'wxpay'
?
require
(
'../assets/wxpay.png'
)
:
require
(
'../assets/Vertical/alipay01.png'
)
}
style
=
{
styles
.
wxpay
}
tintColor
=
"white"
/>
<
Text
style
=
{
styles
.
clickText
}
>
点击进入
<
/Text
>
<
Image
source
=
{
require
(
'../assets/up.png'
)}
style
=
{
styles
.
up
}
/
>
...
...
src/services/store.js
View file @
4afa48be
...
...
@@ -35,10 +35,10 @@ export function door({userId}) {
return
axios
.
post
(
'/store/door'
,
qs
.
stringify
({
userId
}));
}
export
function
wxdoor
({
userId
,
openid
,
wxtoken
,
nickname
})
{
export
function
wxdoor
({
userId
,
openid
,
wxtoken
,
nickname
,
fToken
})
{
return
axios
.
post
(
'/store/wxdoor'
,
qs
.
stringify
({
userId
,
openid
,
wxtoken
,
nickname
}),
qs
.
stringify
({
userId
,
openid
,
wxtoken
,
nickname
,
fToken
}),
);
}
...
...
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