刚开始的查看了微信小程序生物认证文档,写了代码后发现生物认证接口能用,但是指纹调用就是没有。
很是奇怪,最后查阅生物认证SOTER 指纹支持机型后才明白。附上代码
//index.js
//获取应用实例
const
app
=
getApp
()
Page
({
data:
{
},
onLoad:
function
() {
},
fingerpriter
(
e
){
var
that
=
this
;
if
(
wx
.
canIUse
(
"checkIsSupportSoterAuthentication"
)){
//判断此接口是否可用
console
.
log
(
e
);
wx
.
checkIsSupportSoterAuthentication
({
success:
function
(
res
){
console
.
log
(
'本机支持的 SOTER 生物认证'
,
res
);
var
keys
=
[];
for
(
var
key
in
res
) {
keys
.
push
(
res
[
key
])
}
console
.
log
(
res
)
that
.
setData
({
print:
keys
//页面中输出支持情况
})
if
(
res
.
supportMode
==
"fingerPrint"
){
wx
.
startSoterAuthentication
({
requestAuthModes:
[
'fingerPrint'
],
challenge:
'123456'
,
authContent:
"请用指纹解锁"
,
success:
function
(
res
){
console
.
log
(
'js'
,
res
);
},
fail:
function
(
res
){
that
.
setData
({
c:
"用户取消了指纹识别,或调用出现错误"
})
}
})
}
else
{
that
.
setData
({
b:
"当前该设备不支持指纹识别"
})
}
}
})
}
}
})
SOTER 指纹支持机型地址: