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
6ab0a404
Commit
6ab0a404
authored
Sep 07, 2020
by
zeven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
集成支付宝刷脸支付
parent
9a7bfa2a
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
9 deletions
+80
-9
.eslintrc.js
.eslintrc.js
+1
-0
android
android
+1
-1
goods.js
src/models/goods.js
+6
-0
CounterMixins.js
src/pages/CounterMixins.js
+4
-2
VerticalPage.js
src/pages/VerticalPage.js
+52
-4
goods.js
src/services/goods.js
+13
-2
Smilepay.js
src/utils/Smilepay.js
+3
-0
No files found.
.eslintrc.js
View file @
6ab0a404
...
...
@@ -5,5 +5,6 @@ module.exports = {
"react-native/no-inline-styles"
:
0
,
"no-unused-vars"
:
2
,
"no-eval"
:
0
,
curly
:
0
,
}
};
android
@
f5d21a87
Subproject commit
3f5301de4268f6fd7567abfcba2646c277fa0d13
Subproject commit
f5d21a876424a9e6b5c618be639dd0e15dae96d0
src/models/goods.js
View file @
6ab0a404
...
...
@@ -80,6 +80,12 @@ export default {
*
faceinfo
(
action
,
{
call
})
{
return
yield
call
(
api
.
faceinfo
,
action
);
},
*
alipayinfo
(
action
,
{
call
})
{
return
yield
call
(
api
.
alipayinfo
,
action
);
},
*
smilepay
(
action
,
{
call
})
{
return
yield
call
(
api
.
smilepay
,
action
);
},
*
wxauthinfo
(
action
,
{
call
})
{
delete
action
.
type
;
return
yield
call
(
api
.
wxauthinfo
,
action
);
...
...
src/pages/CounterMixins.js
View file @
6ab0a404
...
...
@@ -521,12 +521,13 @@ const CounterMixins = ComposeComponent => {
};
// 付款码支付
barcodepay
=
async
(
code
,
facepay
,
openid
)
=>
{
barcodepay
=
async
(
code
,
facepay
,
openid
,
fToken
)
=>
{
if
(
this
.
barcodeBusy
)
{
return
true
;
}
const
isWxpay
=
code
.
toString
().
match
(
/1
[
0-5
]\d{16}
/
);
const
isAlipay
=
code
.
toString
().
match
(
/^
(
2
[
5-9
]
|30
)\d{14,22}
$/
);
const
isAlipay
=
fToken
||
code
.
toString
().
match
(
/^
(
2
[
5-9
]
|30
)\d{14,22}
$/
);
if
(
!
isWxpay
&&
!
isAlipay
)
{
return
false
;
}
...
...
@@ -540,6 +541,7 @@ const CounterMixins = ComposeComponent => {
facepay
,
noBarcode
,
openid
,
fToken
,
});
if
(
res
.
code
!==
1
)
{
await
this
.
setState
({
voiceModal
:
true
,
voiceTitle
:
res
.
msg
});
...
...
src/pages/VerticalPage.js
View file @
6ab0a404
...
...
@@ -18,7 +18,9 @@ import WxFacepay from '../utils/WxFacepay';
import
{
width
}
from
'../utils/screen'
;
import
Speech
from
'../utils/Speech'
;
import
delay
from
'../utils/delay'
;
import
Smilepay
from
'../utils/Smilepay'
;
import
{
leaveTalkCall
,
onTalkCall
}
from
'../utils/agora'
;
import
Toast
from
'../components/Toast'
;
let
pageSize
=
8
;
// 分页大小
window
.
pageSize
=
pageSize
;
...
...
@@ -32,6 +34,7 @@ class VerticalPage extends Component {
maskVisible
:
true
,
visibleActive
:
false
,
talkCall
:
2
,
// 0请求通话,1通话中,2,已挂断通话,待机状态
faceType
:
'wxpay'
,
};
async
componentWillMount
()
{
...
...
@@ -42,6 +45,11 @@ class VerticalPage extends Component {
this
.
storeKey
=
await
AsyncStorage
.
getItem
(
'KEY'
);
if
(
!
this
.
init
)
{
this
.
init
=
await
WxFacepay
.
init
();
if
(
!
this
.
init
)
{
// 微信刷脸失败,启动支付宝刷脸
this
.
init
=
true
;
this
.
setState
({
faceType
:
'alipay'
});
}
}
}
...
...
@@ -104,6 +112,14 @@ class VerticalPage 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
;
};
authinfo
=
async
()
=>
{
const
rawdata
=
await
WxFacepay
.
rawdata
();
const
{
data
}
=
await
this
.
props
.
dispatch
({
type
:
'goods/faceinfo'
,
rawdata
});
...
...
@@ -195,7 +211,6 @@ class VerticalPage extends Component {
}
if
(
res
.
face_code
)
{
await
this
.
props
.
barcodepay
(
res
.
face_code
,
true
,
res
.
sub_openid
);
// const ret = await this.props.barcodepay(res.face_code, true);
// const result = { ...params, payresult: ret };
// if (ret !== 'SUCCESS') result.payresult = 'ERROR';
...
...
@@ -204,6 +219,31 @@ class VerticalPage extends Component {
}
};
smilepay
=
async
()
=>
{
const
{
goodsArr
}
=
this
.
props
;
if
(
goodsArr
.
length
===
0
)
{
this
.
props
.
speak
(
'请先扫描商品条码,再刷脸支付'
,
true
);
return
;
}
await
this
.
alipayinfo
();
if
(
!
this
.
alipayInfo
||
!
this
.
alipayInfo
.
metaInfo
)
{
this
.
props
.
speak
(
'刷脸支付启动失败,请重新刷脸或扫码支付'
,
true
);
return
;
}
const
{
data
}
=
await
this
.
props
.
dispatch
({
type
:
'goods/smilepay'
,
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
;
}
await
this
.
props
.
barcodepay
(
res
.
fToken
,
true
,
null
,
res
.
fToken
);
}
};
onCall
=
async
()
=>
{
const
{
talkCall
}
=
this
.
state
;
if
(
talkCall
===
2
)
{
...
...
@@ -417,6 +457,10 @@ class VerticalPage extends Component {
});
this
.
totalPrice
=
totalPrice
;
this
.
totalCount
=
totalCount
;
if
(
this
.
state
.
faceType
===
'alipay'
)
styles
.
guide
=
{...
styles
.
guide
,
backgroundColor
:
'#1b7dc7'
};
const
facepay
=
this
.
state
.
faceType
===
'wxpay'
?
this
.
wxFacepay
:
this
.
smilepay
;
return
(
<
View
style
=
{
styles
.
main
}
>
<
View
style
=
{
styles
.
header
}
>
...
...
@@ -545,7 +589,7 @@ class VerticalPage extends Component {
{
/* })}*/
}
{
/*</View>*/
}
<
View
style
=
{
styles
.
shadow
}
/
>
<
Touch
onPress
=
{
this
.
wxF
acepay
}
>
<
Touch
onPress
=
{
f
acepay
}
>
<
View
style
=
{
styles
.
guide
}
>
<
Text
style
=
{
styles
.
guideText
}
>
点击进入
<
/Text
>
<
Image
...
...
@@ -583,7 +627,7 @@ class VerticalPage extends Component {
<
/View
>
<
/View
>
<
View
style
=
{
styles
.
faceScan
}
>
<
Touch
onPress
=
{
this
.
wxF
acepay
}
>
<
Touch
onPress
=
{
f
acepay
}
>
<
View
>
<
Image
source
=
{
require
(
'../assets/Vertical/face.gif'
)}
...
...
@@ -592,7 +636,11 @@ class VerticalPage extends Component {
/>
<
View
style
=
{
styles
.
facePay
}
>
<
Image
source
=
{
require
(
'../assets/Vertical/wxpay.png'
)}
source
=
{
this
.
state
.
faceType
===
'wxpay'
?
require
(
'../assets/Vertical/wxpay.png'
)
:
require
(
'../assets/Vertical/alipay01.png'
)
}
style
=
{
styles
.
payImage
}
alt
=
""
/>
...
...
src/services/goods.js
View file @
6ab0a404
...
...
@@ -9,10 +9,10 @@ export function getBags() {
return
axios
.
get
(
'/store/goods/bags'
);
}
export
function
barcodepay
({
ids
,
code
,
facepay
,
noBarcode
,
openid
})
{
export
function
barcodepay
({
ids
,
code
,
facepay
,
noBarcode
,
openid
,
fToken
})
{
return
axios
.
post
(
'/store/goods/barcodepay'
,
qs
.
stringify
({
ids
,
code
,
facepay
,
noBarcode
,
openid
}),
qs
.
stringify
({
ids
,
code
,
facepay
,
noBarcode
,
openid
,
fToken
}),
);
}
...
...
@@ -44,6 +44,17 @@ export function faceinfo({rawdata}) {
return
axios
.
post
(
'/store/goods/faceinfo'
,
qs
.
stringify
({
rawdata
}));
}
export
function
alipayinfo
()
{
return
axios
.
post
(
'/store/goods/alipayinfo'
);
}
export
function
smilepay
({
zimmetainfo
,
service_id
,
service_params
})
{
return
axios
.
post
(
'/store/goods/smilepay'
,
qs
.
stringify
({
zimmetainfo
,
service_id
,
service_params
}),
);
}
export
function
wxauthinfo
(
action
)
{
return
axios
.
post
(
'/common/wxpay/faceAuth'
,
action
);
}
src/utils/Smilepay.js
0 → 100644
View file @
6ab0a404
import
{
NativeModules
}
from
'react-native'
;
export
default
NativeModules
.
Smilepay
;
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