欧美三级国产三级日韩三级_亚洲熟妇丰满大屁股熟妇_欧美亚洲成人一区二区三区_国产精品久久久久久模特

微信小程序之生物識別 - 新聞資訊 - 云南小程序開發(fā)|云南軟件開發(fā)|云南網(wǎng)站建設(shè)-昆明葵宇信息科技有限公司

159-8711-8523

云南網(wǎng)建設(shè)/小程序開發(fā)/軟件開發(fā)

知識

不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價值,我們在追求其視覺表現(xiàn)的同時,更側(cè)重于功能的便捷,營銷的便利,運(yùn)營的高效,讓網(wǎng)站成為營銷工具,讓軟件能切實提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序為后期升級提供便捷的支持!

您當(dāng)前位置>首頁 » 新聞資訊 » 小程序相關(guān) >

微信小程序之生物識別

發(fā)表時間:2022-9-6

發(fā)布人:葵宇科技

瀏覽次數(shù):98

今天閑來沒事,了解下生物識別。

生物識別有三個接口


1、wx.checkIsSupportSoterAuthentication 用來獲取本機(jī)支持的生物識別方式(人臉、指紋、聲紋)

2、wx.startSoterAuthentication 進(jìn)行生物認(rèn)證

3、wx.checkIsSoterEnrolledInDevice 檢測是否錄入生物信息

有興趣的童鞋可以拿代碼去玩玩試試看

wxml代碼

 bindtap="checkIsFingerPrint">檢測是否可以指紋識別
 bindtap="checkIsFacial">檢測是否可以人臉識別
 bindtap="HaveFingerPrint">該設(shè)備是否錄入指紋
 bindtap="FingerPrint">識別指紋

js代碼

Page({

  /**
   * 頁面的初始數(shù)據(jù)
   */
  data: {
    isfingerPrint : false,    //可否使用指紋識別  默認(rèn)false
    isfacial: false,          //可否使用人臉識別  默認(rèn)false
  },

  /**
   * 生命周期函數(shù)--監(jiān)聽頁面加載
   */
  onLoad: function (options) {
    var that = this
    //查看支持的生物認(rèn)證   比如ios的指紋識別   安卓部分機(jī)器是不能用指紋識別的
    wx.checkIsSupportSoterAuthentication({
      success(res) {
        for (var i in res.supportMode){
          if (res.supportMode[i] == 'fingerPrint'){
            console.log("支持指紋識別", res.supportMode[i]);
            that.setData({
              isfingerPrint : true
            })
          } else if (res.supportMode[i] == 'facial'){
            console.log("支持人臉識別", res.supportMode[i]);
          }
        }
      }
    })
  },
  //是否可以指紋識別
  checkIsFingerPrint:function(){
    var boole = this.data.isfingerPrint
    var txt = "不可以使用指紋識別"
    if (boole) {
      txt = "可以使用指紋識別"
    }
    show("提示",txt,false);
  },
  //是否可以人臉識別
  checkIsFacial: function () {
    var boole = this.data.isfacial
    var txt = "不可以使用人臉識別"
    if (boole){
      txt = "可以使用人臉識別"
    }
    function SUCC() {
      console.log("用戶點擊確定")
    }

    function FAIL() {
      console.log("用戶點擊取消")
    }

    show("提示", txt, true,SUCC,FAIL);
  },

  //進(jìn)行指紋識別
  FingerPrint: function(){
    wx.startSoterAuthentication({
      requestAuthModes: ['fingerPrint'],
      challenge: '123456',
      authContent: '請用指紋',
      success(res) {
        console.log("識別成功",res)
        show("提示", "識別成功", false);
      },
      fail(res){
        console.log("識別失敗",res)
        show("提示", "識別失敗", 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ào)(非必須)
 * fail 用戶點擊取消的回調(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();
        }
      }
    }
  })
}

tip: 1、如有遇到新問題,可以在下方留言或者加QQ群437729329 進(jìn)行咨詢

相關(guān)案例查看更多