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>

效果展示:

相关推荐
家里有只小肥猫11 小时前
uniApp小程序保存canvas图片
前端·小程序·uni-app
小徐_233311 小时前
从空白到交互:用Trae快速搭建uni-app AI对话小程序页面
前端·uni-app·trae
貂蝉空大14 小时前
uni-app开发安卓和ios app 真机调试
android·ios·uni-app
程楠楠&M14 小时前
uni-app(位置1)
前端·javascript·uni-app·node.js
破z晓14 小时前
uniapp 整合openlayers 编辑图形文件并上传到服务器
前端·javascript·uni-app
寰宇软件18 小时前
PHP房屋出租出售高效预约系统小程序源码
前端·小程序·uni-app·vue·php
尚学教辅学习资料19 小时前
基于SpringBoot的宠物服务系统+uniapp小程序+LW参考示例
spring boot·uni-app·宠物
真的不想写实验19 小时前
uniapp引入ucharts组件不显示
uni-app
烂蜻蜓20 小时前
深入解析 Uniapp 的页面结构
前端·css·vue.js·uni-app·html·html5
Little_Code20 小时前
关于uniapp使用renderJS中调用父类方法和参数的使用
前端·javascript·uni-app