微信小程序 SOTER 生物認(rèn)證DEMO 指紋識(shí)別功能
今天項(xiàng)目嘗試使用微信小程序指紋認(rèn)證功能
以下為測試demo
index.js
Page({ /** * 頁面的初始數(shù)據(jù) */ data: { isfingerPrint : false, //可否使用指紋識(shí)別 默認(rèn)false isfacial: false, //可否使用人臉識(shí)別 默認(rèn)false }, /** * 生命周期函數(shù)--監(jiān)聽頁面加載 */ onLoad: function (options) { var that = this //查看支持的生物認(rèn)證 比如ios的指紋識(shí)別 安卓部分機(jī)器是不能用指紋識(shí)別的 wx.checkIsSupportSoterAuthentication({ success(res) { for (var i in res.supportMode){ if (res.supportMode[i] == 'fingerPrint'){ console.log("支持指紋識(shí)別", res.supportMode[i]); that.setData({ isfingerPrint : true }) } else if (res.supportMode[i] == 'facial'){ console.log("支持人臉識(shí)別", res.supportMode[i]); } } } }) }, //是否可以指紋識(shí)別 checkIsFingerPrint:function(){ var boole = this.data.isfingerPrint var txt = "不可以使用指紋識(shí)別" if (boole) { txt = "可以使用指紋識(shí)別" } show("提示",txt,false); }, //是否可以人臉識(shí)別 checkIsFacial: function () { var boole = this.data.isfacial var txt = "不可以使用人臉識(shí)別" if (boole){ txt = "可以使用人臉識(shí)別" } function SUCC() { console.log("用戶點(diǎn)擊確定") } function FAIL() { console.log("用戶點(diǎn)擊取消") } show("提示", txt, true,SUCC,FAIL); }, //進(jìn)行指紋識(shí)別 FingerPrint: function(){ wx.startSoterAuthentication({ requestAuthModes: ['fingerPrint'], challenge: '123456', authContent: '請(qǐng)用指紋', success(res) { console.log("識(shí)別成功",res) show("提示", "識(shí)別成功", false); }, fail(res){ console.log("識(shí)別失敗",res) show("提示", "識(shí)別失敗", false); } }) }, //是否有指紋 HaveFingerPrint:function(){ wx.checkIsSoterEnrolledInDevice({ checkAuthMode: 'fingerPrint', success(res) { if (res.isEnrolled == 1){ show("提示", "有指紋", false); } else if (res.isEnrolled == 0){ show("提示", "無指紋", false); } }, fail(res){ show("提示", "異常", fail); } }) } })
/** * 顯示提示信息 * tit 提示的標(biāo)題 * msg 提示的內(nèi)容 * q 是否有取消按鈕(布爾值) * succ 用戶點(diǎn)擊確定的回調(diào)(非必須) * fail 用戶點(diǎn)擊取消的回調(diào)(非必須) * */ function show(tit,msg,q,succ,fail){ wx.showModal({ title: tit, content: msg, showCancel:q, success: function (res) { if (res.confirm) { if (succ){ succ(); } } else if (res.cancel) { if (fail) { fail(); } } } }) }
WXML
<view > <button type="primary" bindtap="checkIsFingerPrint"> 檢測是否可以指紋識(shí)別 </button> <button type="primary" bindtap="checkIsFacial"> 檢測是否可以人臉識(shí)別 </button> <button type="primary" bindtap="HaveFingerPrint"> 該設(shè)備是否錄入指紋 </button> <button type="primary" bindtap="FingerPrint"> 識(shí)別指紋 </button> </view>
總結(jié)
以上所述是小編給大家介紹的微信小程序 SOTER 生物認(rèn)證DEMO 指紋識(shí)別功能,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
相關(guān)文章
js實(shí)現(xiàn)時(shí)鐘定時(shí)器
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)時(shí)鐘定時(shí)器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-03-03用 javascript 實(shí)現(xiàn)的點(diǎn)擊復(fù)制代碼
用 javascript 實(shí)現(xiàn)的點(diǎn)擊復(fù)制代碼,需要的朋友可以參考一下2007-03-03純CSS3代碼實(shí)現(xiàn)滑動(dòng)開關(guān)效果
CSS33D炫酷左右滑動(dòng)開關(guān)按鈕是一款非常酷的CSS3 3D開關(guān)按鈕,點(diǎn)擊按鈕可以左右滑動(dòng),就像開關(guān)打開閉合一樣的效果,通過本篇文章給大家介紹純CSS3代碼實(shí)現(xiàn)滑動(dòng)開關(guān)效果,需要的朋友可以參考下2015-08-08對(duì)layui中的onevent 和event的使用詳解
今天小編就為大家分享一篇對(duì)layui中的onevent 和event的使用詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-09-09