网友真实露脸自拍10p,成人国产精品秘?久久久按摩,国产精品久久久久久无码不卡,成人免费区一区二区三区

小程序模板網(wǎng)

微信小程序之生物識別

發(fā)布時間:2018-01-06 11:23 所屬欄目:小程序開發(fā)教程

今天閑來沒事,了解下生物識別。生物識別有三個接口1、wx.checkIsSupportSoterAuthentication 用來獲取本機支持的生物識別方式(人臉、指紋、聲紋)2、wx.startSoterAuthentication 進行生物認證3、wx.checkIsSoterE ...

 
 
 

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

生物識別有三個接口


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

2、wx.startSoterAuthentication 進行生物認證

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

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

wxml代碼

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

js代碼

Page({

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

  /**
   * 生命周期函數(shù)--監(jiān)聽頁面加載
   */
  onLoad: function (options) {
    var that = this
    //查看支持的生物認證   比如ios的指紋識別   安卓部分機器是不能用指紋識別的
    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);
  },

  //進行指紋識別
  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();
        }
      }
    }
  })
}


易優(yōu)小程序(企業(yè)版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/18383.html 復(fù)制鏈接 如需定制請聯(lián)系易優(yōu)客服咨詢:800182392 點擊咨詢
QQ在線咨詢
AI智能客服 ×