uniapp生物识别示例(人脸识别、指纹识别)

准备工作:

mainfest.json设置勾选:

勾选完成后打 App自定义调试基座测试包

示例代码:

html 复制代码
<template>
	<view class="content">
		<button v-if="supportSoterAuthenticationArray.includes('facial')" @click="SoterAuthenticationFunction('facial')">人脸识别</button>
		<button v-if="supportSoterAuthenticationArray.includes('fingerPrint')" @click="SoterAuthenticationFunction('fingerPrint')">指纹识别</button>
	</view>
</template>

<script setup>
	import { onShow } from '@dcloudio/uni-app'
	import { ref } from 'vue';
	
	onShow(()=>{
		checkIsSupportSoterAuthentication()
	})
	
	const supportSoterAuthenticationArray = ref([])
	const checkIsSupportSoterAuthentication = () => {
		uni.checkIsSupportSoterAuthentication({
			success(res) {
				supportSoterAuthenticationArray.value = res.supportMode
			}
		})
	}
	
	const SoterAuthenticationFunction = (type) => {
		uni.checkIsSoterEnrolledInDevice({
			checkAuthMode: type,
			success(res) {
				res.isEnrolled && uni.startSoterAuthentication({
					requestAuthModes: [type],
					challenge: '123456',
					authContent: '生物解锁',
					success(res) {
						console.log(res,'成功回调','执行相关逻辑');
					}
				})
			}
		})
	}
</script>

<style lang="scss" scoped>
	
</style>

效果展示:

相关推荐
_斯洛伐克2 小时前
uniapp 知识点
前端·javascript·uni-app
Dark_programmer2 小时前
uni-app - - - - - 实现锚点定位和滚动监听功能(滚动监听功能暂未添加,待后续更新)
uni-app
美酒没故事°2 小时前
uni-app canvas文本自动换行
uni-app·canva可画
雪芽蓝域zzs9 小时前
uniapp EChars图表
arcgis·uni-app
快起来搬砖了11 小时前
创意实现!在uni-app小程序商品详情页轮播中嵌入视频播放功能
小程序·uni-app·商城
qq_5302451911 小时前
uniapp自定义底部tabBar
uni-app·自定义tabbar
酷盖机车男11 小时前
封装轮播图 (因为基于微博小程序,语法可能有些出入,如需使用需改标签)
前端·javascript·小程序·uni-app
Jiaberrr12 小时前
uniapp实战教程:如何封装一个可复用的表单组件
javascript·笔记·前端框架·uni-app·表单
用户05272770211712 小时前
Uni app 离线 OCR android 实现 MLKIT
uni-app