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
f1c8fc67
Commit
f1c8fc67
authored
Dec 15, 2020
by
zeven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信刷脸自动保存输入的手机号
parent
3e50cc82
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
14 deletions
+41
-14
android
android
+1
-1
FacePage.js
src/pages/FacePage.js
+28
-10
store.js
src/services/store.js
+10
-2
validity.js
src/utils/validity.js
+2
-1
No files found.
android
@
4c28e562
Subproject commit
ae144fb06f21278eac9ee5357c0dd64ba36079c0
Subproject commit
4c28e562126ae5cc53882fd42320875f460e7c6a
src/pages/FacePage.js
View file @
f1c8fc67
...
@@ -22,6 +22,7 @@ import {width, setSpText, scaleSize} from '../utils/screen';
...
@@ -22,6 +22,7 @@ import {width, setSpText, scaleSize} from '../utils/screen';
import
{
qrHost
}
from
'../utils/config'
;
import
{
qrHost
}
from
'../utils/config'
;
import
Icons
from
'react-native-vector-icons/MaterialIcons'
;
import
Icons
from
'react-native-vector-icons/MaterialIcons'
;
import
AutoClick
from
'../utils/AutoClick'
;
import
AutoClick
from
'../utils/AutoClick'
;
import
validity
from
'../utils/validity'
;
@
connect
(({
admin
})
=>
({
admin
}))
@
connect
(({
admin
})
=>
({
admin
}))
class
FacePage
extends
Component
{
class
FacePage
extends
Component
{
...
@@ -46,6 +47,8 @@ class FacePage extends Component {
...
@@ -46,6 +47,8 @@ class FacePage extends Component {
setting
:
false
,
setting
:
false
,
};
};
phone
=
''
;
// 监听用户输入手机
async
componentWillMount
()
{
async
componentWillMount
()
{
this
.
storeKey
=
await
AsyncStorage
.
getItem
(
'KEY'
);
this
.
storeKey
=
await
AsyncStorage
.
getItem
(
'KEY'
);
let
contact
=
await
AsyncStorage
.
getItem
(
'CONTACT'
);
let
contact
=
await
AsyncStorage
.
getItem
(
'CONTACT'
);
...
@@ -61,8 +64,22 @@ class FacePage extends Component {
...
@@ -61,8 +64,22 @@ class FacePage extends Component {
}
}
const
setting
=
await
AutoClick
.
isSettingsOn
();
const
setting
=
await
AutoClick
.
isSettingsOn
();
if
(
!
setting
)
this
.
setState
({
setting
:
true
});
// 展示按钮
if
(
!
setting
)
this
.
setState
({
setting
:
true
});
// 展示按钮
DeviceEventEmitter
.
addListener
(
'wxpayfaceRegister'
,
()
=>
{
DeviceEventEmitter
.
addListener
(
'wxpayfaceRegister'
,
async
()
=>
{
this
.
wechatFace
();
// 点击开通重新调用
if
(
this
.
faceBusy
)
return
;
this
.
faceBusy
=
true
;
await
this
.
wechatFace
();
// 点击开通重新调用
this
.
faceBusy
=
false
;
});
// 监听微信输入手机号事件
DeviceEventEmitter
.
addListener
(
'wxpayfaceInput'
,
({
text
})
=>
{
if
(
!
text
)
return
;
const
match
=
/^
\[(
.+
)\]
$/
.
exec
(
text
);
if
(
!
match
)
return
;
text
=
match
[
1
];
if
(
text
===
'删除'
)
this
.
phone
=
this
.
phone
.
substr
(
0
,
this
.
phone
.
length
-
1
);
else
this
.
phone
+=
text
;
if
(
this
.
phone
.
length
>
11
)
this
.
phone
=
this
.
phone
.
substr
(
-
11
);
});
});
}
}
...
@@ -340,29 +357,30 @@ class FacePage extends Component {
...
@@ -340,29 +357,30 @@ class FacePage extends Component {
// 返回错误自动重新识别
// 返回错误自动重新识别
res
=
(
await
WxFacepay
.
faceinfo
(
params
))
||
{};
res
=
(
await
WxFacepay
.
faceinfo
(
params
))
||
{};
}
}
if
(
!
res
.
openid
)
{
// 返回错误出现二维码扫码
Speech
.
speak
(
'请扫码开门'
);
this
.
setQrcode
({
action
:
this
.
action
,
tip
:
'请扫码开门'
,
qrcode
:
true
});
}
if
(
window
.
socket
)
{
if
(
window
.
socket
)
{
// 返回结果,立即重新连接socket
// 返回结果,立即重新连接socket
window
.
socket
.
connect
();
window
.
socket
.
connect
();
}
}
if
(
!
res
.
openid
)
{
if
(
!
res
.
openid
)
{
// 没识别到人脸不开门
// 返回错误出现二维码扫码
this
.
phone
=
''
;
Speech
.
speak
(
'请扫码开门'
);
this
.
setQrcode
({
action
:
this
.
action
,
tip
:
'请扫码开门'
,
qrcode
:
true
});
return
;
return
;
}
}
if
(
res
.
sub_openid
)
{
if
(
res
.
sub_openid
)
{
res
.
openid
=
res
.
sub_openid
;
res
.
openid
=
res
.
sub_openid
;
}
}
this
.
loading
(
true
);
this
.
loading
(
true
);
const
ret
=
await
this
.
props
.
dispatch
(
{
const
action
=
{
type
:
'store/wxdoor'
,
type
:
'store/wxdoor'
,
openid
:
res
.
openid
,
openid
:
res
.
openid
,
wxtoken
:
res
.
token
,
wxtoken
:
res
.
token
,
nickname
:
res
.
nickname
,
nickname
:
res
.
nickname
,
});
};
if
(
validity
.
phone
.
test
(
this
.
phone
))
action
.
phone
=
this
.
phone
;
const
ret
=
await
this
.
props
.
dispatch
(
action
);
this
.
phone
=
''
;
this
.
loading
(
false
);
this
.
loading
(
false
);
this
.
handleDoorLogin
(
ret
);
this
.
handleDoorLogin
(
ret
);
}
}
...
...
src/services/store.js
View file @
f1c8fc67
...
@@ -35,10 +35,18 @@ export function door({userId}) {
...
@@ -35,10 +35,18 @@ export function door({userId}) {
return
axios
.
post
(
'/store/door'
,
qs
.
stringify
({
userId
}));
return
axios
.
post
(
'/store/door'
,
qs
.
stringify
({
userId
}));
}
}
export
function
wxdoor
({
userId
,
openid
,
wxtoken
,
nickname
,
alipayUid
,
fToken
})
{
export
function
wxdoor
({
userId
,
openid
,
wxtoken
,
nickname
,
alipayUid
,
fToken
,
phone
,
})
{
return
axios
.
post
(
return
axios
.
post
(
'/store/wxdoor'
,
'/store/wxdoor'
,
qs
.
stringify
({
userId
,
openid
,
wxtoken
,
nickname
,
alipayUid
,
fToken
}),
qs
.
stringify
({
userId
,
openid
,
wxtoken
,
nickname
,
alipayUid
,
fToken
,
phone
}),
);
);
}
}
...
...
src/utils/validity.js
View file @
f1c8fc67
export
const
total
=
/^
(\d
+
)(
.
\d{0,2})?
$/
;
export
const
total
=
/^
(\d
+
)(
.
\d{0,2})?
$/
;
export
default
{
total
};
export
const
phone
=
/^1
[
3-9
]\d{9}
$/
;
export
default
{
total
,
phone
};
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