|
| 1 | +<template> |
| 2 | + <view> |
| 3 | + <page-head :title="title"></page-head> |
| 4 | + <view class="uni-padding-wrap uni-common-mt"> |
| 5 | + <view class="uni-btn-v"> |
| 6 | + <button type="primary" @click="checkIsSupportSoterAuthentication">检查支持的认证方式</button> |
| 7 | + <button type="primary" @click="checkIsSoterEnrolledInDeviceFingerPrint">检查是否录入指纹</button> |
| 8 | + <button type="primary" @click="checkIsSoterEnrolledInDeviceFaceID">检查是否录入FaceID</button> |
| 9 | + <button type="primary" @click="startSoterAuthenticationFingerPrint">开始指纹认证</button> |
| 10 | + <button type="primary" @click="startSoterAuthenticationFaceID">开始FaceID认证</button> |
| 11 | + </view> |
| 12 | + <view style="width: 100%;text-align: center;">{{ result }}</view> |
| 13 | + </view> |
| 14 | + </view> |
| 15 | +</template> |
| 16 | + |
| 17 | +<script> |
| 18 | +export default { |
| 19 | + data() { |
| 20 | + return { |
| 21 | + title: '生物认证', |
| 22 | + result: '' |
| 23 | + }; |
| 24 | + }, |
| 25 | + onLoad() { |
| 26 | +
|
| 27 | + }, |
| 28 | + methods: { |
| 29 | + checkIsSupportSoterAuthentication() { |
| 30 | + uni.checkIsSupportSoterAuthentication({ |
| 31 | + success(res) { |
| 32 | + uni.showModal({ |
| 33 | + content: '支持的认证方式:' + res.supportMode, |
| 34 | + showCancel: false |
| 35 | + }) |
| 36 | + console.log(res); |
| 37 | + }, |
| 38 | + fail(err) { |
| 39 | + console.log(err); |
| 40 | + } |
| 41 | + }) |
| 42 | + }, |
| 43 | + checkIsSoterEnrolledInDeviceFingerPrint() { |
| 44 | + uni.checkIsSoterEnrolledInDevice({ |
| 45 | + checkAuthMode: 'fingerPrint', |
| 46 | + success(res) { |
| 47 | + if(res.isEnrolled) { |
| 48 | + uni.showToast({ |
| 49 | + icon: 'none', |
| 50 | + title: '已录入指纹' |
| 51 | + }) |
| 52 | + }else { |
| 53 | + uni.showModal({ |
| 54 | + content: '未录入指纹', |
| 55 | + showCancel: false |
| 56 | + }) |
| 57 | + } |
| 58 | + console.log(res); |
| 59 | + }, |
| 60 | + fail(err) { |
| 61 | + uni.showModal({ |
| 62 | + content: '未录入指纹', |
| 63 | + showCancel: false |
| 64 | + }) |
| 65 | + console.log(err); |
| 66 | + } |
| 67 | + }) |
| 68 | + }, |
| 69 | + checkIsSoterEnrolledInDeviceFaceID() { |
| 70 | + uni.checkIsSoterEnrolledInDevice({ |
| 71 | + checkAuthMode: 'facial', |
| 72 | + success(res) { |
| 73 | + if(res.isEnrolled) { |
| 74 | + uni.showToast({ |
| 75 | + icon: 'none', |
| 76 | + title: '已录入FaceID' |
| 77 | + }) |
| 78 | + }else { |
| 79 | + uni.showModal({ |
| 80 | + content: '未录入FaceID', |
| 81 | + showCancel: false |
| 82 | + }) |
| 83 | + } |
| 84 | + console.log(res); |
| 85 | + }, |
| 86 | + fail(err) { |
| 87 | + uni.showModal({ |
| 88 | + content: '未录入FaceID', |
| 89 | + showCancel: false |
| 90 | + }) |
| 91 | + console.log(err); |
| 92 | + } |
| 93 | + }) |
| 94 | + }, |
| 95 | + startSoterAuthenticationFingerPrint() { |
| 96 | + uni.startSoterAuthentication({ |
| 97 | + requestAuthModes: ['fingerPrint'], |
| 98 | + challenge: '123456', |
| 99 | + authContent: '请用指纹解锁', |
| 100 | + success(res) { |
| 101 | + uni.showToast({ |
| 102 | + icon: 'none', |
| 103 | + title: '指纹验证成功' |
| 104 | + }) |
| 105 | + console.log(res); |
| 106 | + }, |
| 107 | + fail(err) { |
| 108 | + uni.showModal({ |
| 109 | + content: '指纹验证失败,errCode:' + err.errCode, |
| 110 | + showCancel: false |
| 111 | + }) |
| 112 | + console.log(err); |
| 113 | + } |
| 114 | + }) |
| 115 | + }, |
| 116 | + startSoterAuthenticationFaceID() { |
| 117 | + uni.startSoterAuthentication({ |
| 118 | + requestAuthModes: ['facial'], |
| 119 | + challenge: '123456', |
| 120 | + authContent: '请用FaceID解锁', |
| 121 | + success(res) { |
| 122 | + uni.showToast({ |
| 123 | + icon: 'none', |
| 124 | + title: 'FaceID验证成功' |
| 125 | + }) |
| 126 | + console.log(res); |
| 127 | + }, |
| 128 | + fail(err) { |
| 129 | + uni.showModal({ |
| 130 | + content: 'FaceID验证失败,errCode:' + err.errCode, |
| 131 | + showCancel: false |
| 132 | + }) |
| 133 | + console.log(err); |
| 134 | + } |
| 135 | + }) |
| 136 | + } |
| 137 | + } |
| 138 | +}; |
| 139 | +</script> |
| 140 | + |
| 141 | +<style></style> |
0 commit comments