更新记录
1.0.20250608(2025-06-08)
初始化项目
平台兼容性
uni-app x
Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
- |
- |
5.0 |
× |
× |
× |
暂时仅支持Andorid, IOS正在开发...
引入插件
- 点击插件试用引入到项目
- 打包自定义基座包
- 按照下方示例测试
- 先插件试用,完全符合需求后购买
import * as biometricUtils from '@/uni_modules/cms-biometric';
插件方法
方法 |
描述 |
参数 |
isSupport() |
是否支持生物识别(强生物/弱生物/中高设备凭据认证) |
IsEnrolled() |
是否录入生物识别(强生物/弱生物/中高设备凭据认证) |
IsSupportForKey(string) |
是否支持某种生物识别 |
strong:强生物 、 weak:弱生物 、credential:中高设备凭据认证 |
IsEnrolledForKey(string) |
是否录入某种生物识别 |
strong:强生物 、 weak:弱生物 、credential:中高设备凭据认证 |
StartAuth(StartAuthOption) |
开始认证 |
StartAuthOption 见下方 |
export type StartAuthOption = {
// 标题
title : string;
// 副标题
subtitle : string;
// 按钮文本
negativeButtonText : string;
// 使用某种生物识别,可空(空时会优先strong/weakcredential)
models ?: string[],
// 成功回调
success : () => void;
// 失败回调
fail : (errCode : number, errMsg : string) => void;
}
区别
- 强生物认证解释: 3D结构光人脸识别、高精度指纹传感器、虹膜识别
- 弱生物认证解释: 2D人脸识别(如普通摄像头)、基础指纹传感器
- 中高设备凭据认证解释: PIN码、图案或密码
- 不同机型代表可能不一致 真我Q3表现为,强生物代表指纹、弱生物代表面容、中高设备凭据认证代表密码
示例页面
<template>
<view style="padding-top: 300rpx;">
<button type="primary" @click="isSupport">是否支持生物识别(下方任意一种)</button>
<button type="primary" @click="IsSupportForKey('strong')">是否支持强生物识别</button>
<button type="primary" @click="IsSupportForKey('weak')">是否支持弱生物识别</button>
<button type="primary" @click="IsSupportForKey('credential')">是否支持中高设备凭据认证</button>
<button type="primary" @click="IsEnrolled">是否录入生物识别</button>
<button type="primary" @click="IsEnrolledForKey('strong')">是否录入强生物识别</button>
<button type="primary" @click="IsEnrolledForKey('weak')">是否录入弱生物识别</button>
<button type="primary" @click="IsEnrolledForKey('credential')">是否录入中高设备凭据认证</button>
<button type="primary" @click="StartAuth">开始验证识别</button>
<view>强生物认证解释: 3D结构光人脸识别、高精度指纹传感器、虹膜识别</view>
<view>弱生物认证解释: 2D人脸识别(如普通摄像头)、基础指纹传感器</view>
<view>中高设备凭据认证解释: PIN码、图案或密码</view>
</view>
</template>
<script>
import * as biometricUtils from '@/uni_modules/cms-biometric';
export default {
data() {
return {}
},
methods: {
showModel(msg) {
uni.showModal({
title: "提示",
showCancel: false,
content: msg
})
},
isSupport() {
this.showModel(`${biometricUtils.IsSupport() ? '支持' : '不支持'}生物识别!`);
},
IsEnrolled() {
this.showModel(`${biometricUtils.IsEnrolled() ? '已录入' : '未录入'}生物识别!`);
},
IsSupportForKey(key) {
this.showModel(`${biometricUtils.IsSupportForKey(key) ? '支持' : '不支持'}${key}!`);
},
IsEnrolledForKey(key) {
this.showModel(`${biometricUtils.IsEnrolledForKey(key) ? '已录入' : '未录入'}${key}!`)
},
StartAuth() {
biometricUtils.StartAuth({
title: "我的title",
subtitle: "我的subtitle",
negativeButtonText: "我的确认",
models: ['strong', 'weak', 'credential'],
success: () => {
this.showModel(`验证成功`);
},
fail: (errCode, errMsg) => {
this.showModel(`验证失败:errCode:${errCode},errMsg:${errMsg}`);
}
})
}
}
}
</script>
需要帮助?有其他插件的需求?联系我!