效果图:
实现代码:
<template>
<view>
<button @click="checkIsSupportSoterAuthentication">检查支持的认证方式</button>
<button type="primary" @click="checkIsSoterEnrolledInDeviceFingerPrint">检查是否录入指纹</button>
<button @click="checkIsSoterEnrolledInDeviceFaceID">检查是否录入FaceID</button>
<button type="primary" @click="startSoterAuthenticationFingerPrint">开始指纹认证</button>
<button @click="startSoterAuthenticationFaceID">开始FaceID认证</button>
{
{ result }}
</view>
</template>
<script>
export default {
data() {
return {
result: ''
};
},
onLoad() {},
methods: {
checkIsSupportSoterAuthentication() {
uni.checkIsSupportSoterAuthentication({
success(res) {
uni.showModal({
content: '支持的认证方式:' + res.supportMode,
showCancel: false
});
console.log(res);
},
fail(err) {
console.log(err);
}
});
},
checkIsSoterEnrolledInDeviceFingerPrint() {
uni.checkIsSoterEnrolledInDevice({
checkAuthMode: 'fingerPrint',
success(res) {
if (res.isEnrolled) {
uni.showToast({
icon: 'none',
title: '已录入指纹'
});
} else {
uni.showModal({
content: '未录入指纹',
showCancel: false
});
}
console.log(res);
},
fail(err) {
uni.showModal({
content: '未录入指纹',
showCancel: false
});
console.log(err);
}
});
},
checkIsSoterEnrolledInDeviceFaceID() {
uni.checkIsSoterEnrolledInDevice({
checkAuthMode: 'facial',
success(res) {
if (res.isEnrolled) {
uni.showToast({
icon: 'none',
title: '已录入FaceID'
});
} else {
uni.showModal({
content: '未录入FaceID',
showCancel: false
});
}
console.log(res);
},
fail(err) {
uni.showModal({
content: '未录入FaceID',
showCancel: false
});
console.log(err);
}
});
},
startSoterAuthenticationFingerPrint() {
uni.startSoterAuthentication({
requestAuthModes: ['fingerPrint'],
challenge: '123456',
authContent: '请用指纹解锁',
success(res) {
uni.showToast({
icon: 'none',
title: '指纹验证成功'
});
console.log(res);
},
fail(err) {
uni.showModal({
content: '指纹验证失败,errCode:' + err.errCode,
showCancel: false
});
console.log(err);
}
});
},
startSoterAuthenticationFaceID() {
uni.startSoterAuthentication({
requestAuthModes: ['facial'],
challenge: '123456',
authContent: '请用FaceID解锁',
success(res) {
uni.showToast({
icon: 'none',
title: 'FaceID验证成功'
});
console.log(res);
},
fail(err) {
uni.showModal({
content: 'FaceID验证失败,errCode:' + err.errCode,
showCancel: false
});
console.log(err);
}
});
}
}
};
</script>
<style></style>
还没有评论,来说两句吧...