欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

小程序實現(xiàn)人臉識別的項目實踐

 更新時間:2023年10月11日 10:08:21   作者:前端小灰狼  
人臉識別在現(xiàn)在很多地方都可以用的到,例如支付,解鎖等,本文就來介紹一下小程序實現(xiàn)人臉識別,具有一定的參考價值,感興趣的可以了解一下

調用api   wx.startFacialRecognitionVerify

第一步:

// 修改方法
      expertUpdate() {
wx.startFacialRecognitionVerify({
          name: _this.registerForm.realName, //身份證名稱
          idCardNumber: _this.registerForm.idCard, //身份證號碼
          checkAliveType: 1, //屏幕閃爍(人臉核驗的交互方式,默認0,讀數(shù)字)
          success(res) {
            console.log(res)  //認證結果
         if(res.errCode == 0){
          //識別成功  這個時候可以調后端的接口 (帶著返的res.verifyResult)
          _this.verifyUser(res.verifyResult)
        }else{
        	tipInfo("識別失敗")
        }
          },
          complete(res) {
          console.log(res)
          },
          fail(e) {
            console.log("err", err)//失敗處理方法
        wx.showToast('請保持光線充足,面部正對手機,且無遮擋')
          }
        })
}

第二步:調方法 校驗后端的接口

 // 人臉識別  根據上一個方法把verify_result傳過來  //后端的校驗接口
      verifyUser(verify_result) {
        //看后端實際要求 要傳身份證號碼不
        let obj = {
          uuid: this.infoForm.idCard,
          verify_result: verify_result
        }
      //后端接口=>verifyUser
        verifyUser(obj).then(res => {
          if (res.code == '0') {
            this.$refs.uForm.validate().then(res => {
              let obj = {
                pkid: uni.getStorageSync('expert_info').pkid,
                memberId: uni.getStorageSync('expert_info').memberId,
                avatar: this.fileList1[0].url,
                realName: this.infoForm.realName,
                orgName: this.infoForm.orgName,
                idCard: this.infoForm.idCard,
                province: this.infoForm.province,
                city: this.infoForm.city,
                district: this.infoForm.district,
                phone: this.infoForm.phone,
                professorLevel: this.infoForm.professorLevel,
                adept: this.infoForm.adept,
                intro: this.infoForm.intro,
                smsCode: this.infoForm.smsCode,
                annex: this.fileList2,
              }
             //修改方法
              expertUpdate(obj).then(res => {
                console.log(res, '修改成功了嗎');
                if (res.code == '0') {
                  uni.$u.toast('修改成功', 5000)
                  uni.navigateBack()
                  //修改成功后 是返回上一步  還是跳轉其他頁面 根據實際情況
                } else {
                  uni.$u.toast(res.msg, 5000)
                }
              })
              console.log(res);
            }).catch(error => {
              console.log(error);
              uni.$u.toast('請先按要求填寫', 5000)
            })
          }
        })
      },

注釋:完整方法  這個是實現(xiàn)小程序個人信息完善,加了一個判斷,如果 輸入框沒有值則需要走人臉識別驗證方法  如果有值 只是修改其他項 就不需要驗證  修改完成之后 名字和身份證號碼直接禁用

 // 修改方法
      expertUpdate() {
        if (this.fileList1.length == 0) {
          uni.$u.toast('請上傳頭像')
          return false
        }
        // 判斷 realName 是否為空
        if (!this.infoForm.realName) {
          uni.$u.toast('請?zhí)顚懶彰?);
          return false;
        }
        // 驗證 realName 是否為中文
        const chineseRegex = /^[\u4e00-\u9fa5]+$/;
        if (!chineseRegex.test(this.infoForm.realName)) {
          uni.$u.toast('姓名必須為中文');
          return false;
        }
        // 判斷 idCard 是否為空
        if (!this.infoForm.idCard) {
          uni.$u.toast('請?zhí)顚懮矸葑C號碼');
          return false;
        }
        // 驗證 idCard 是否符合身份證標準
        const idCardRegex = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
        if (!idCardRegex.test(this.infoForm.idCard)) {
          uni.$u.toast('身份證號格式不正確');
          return false;
        }
        if (this.fileList2.length == 0) {
          uni.$u.toast('請上傳附件')
          return false
        }
        if (this.infoForm.intro.length > 200) {
          uni.$u.toast('簡介字數(shù)不能超過200字!')
          return false
        }
        if (!this.flag) {
          let _this = this
          wx.startFacialRecognitionVerify({
            name: _this.infoForm.realName,
            idCardNumber: _this.infoForm.idCard,
            checkAliveType: 1,
            success(res) {
              console.log(res)
              _this.verifyUser(res.verifyResult)
              // console.log(res)
              // uni.navigateBack()
            },
            complete(res) {
              console.log(res)
            },
            fail(e) {
              // console.log(res)
              // console.log(_this.infoForm.realName)
              // console.log(_this.infoForm.idCard)
              console.log(e, 'fail')
            }
          })
        } else {
          this.$refs.uForm.validate().then(res => {
            let obj = {
              pkid: uni.getStorageSync('expert_info').pkid,
              memberId: uni.getStorageSync('expert_info').memberId,
              avatar: this.fileList1[0].url,
              realName: this.infoForm.realName,
              orgName: this.infoForm.orgName,
              idCard: this.infoForm.idCard,
              province: this.infoForm.province,
              city: this.infoForm.city,
              district: this.infoForm.district,
              phone: this.infoForm.phone,
              professorLevel: this.infoForm.professorLevel,
              adept: this.infoForm.adept,
              intro: this.infoForm.intro,
              smsCode: this.infoForm.smsCode,
              annex: this.fileList2,
            }
            expertUpdate(obj).then(res => {
              console.log(res, '修改成功了嗎');
              if (res.code == '0') {
                uni.$u.toast('修改成功', 5000)
                uni.navigateBack()
                // this.getExpertInfo()
              } else {
                uni.$u.toast(res.msg, 5000)
              }
            })
            console.log(res);
          }).catch(error => {
            console.log(error);
            uni.$u.toast('請先按要求填寫', 5000)
          })
        }
      },
      // 人臉識別
      verifyUser(verify_result) {
        let obj = {
          uuid: this.infoForm.idCard,
          verify_result: verify_result
        }
        verifyUser(obj).then(res => {
          if (res.code == '0') {
            this.$refs.uForm.validate().then(res => {
              let obj = {
                pkid: uni.getStorageSync('expert_info').pkid,
                memberId: uni.getStorageSync('expert_info').memberId,
                avatar: this.fileList1[0].url,
                realName: this.infoForm.realName,
                orgName: this.infoForm.orgName,
                idCard: this.infoForm.idCard,
                province: this.infoForm.province,
                city: this.infoForm.city,
                district: this.infoForm.district,
                phone: this.infoForm.phone,
                professorLevel: this.infoForm.professorLevel,
                adept: this.infoForm.adept,
                intro: this.infoForm.intro,
                smsCode: this.infoForm.smsCode,
                annex: this.fileList2,
              }
              expertUpdate(obj).then(res => {
                console.log(res, '修改成功了嗎');
                if (res.code == '0') {
                  uni.$u.toast('修改成功', 5000)
                  uni.navigateBack()
                  // this.getExpertInfo()
                } else {
                  uni.$u.toast(res.msg, 5000)
                }
              })
              console.log(res);
            }).catch(error => {
              console.log(error);
              uni.$u.toast('請先按要求填寫', 5000)
            })
          }
        })
      },
      

到此這篇關于小程序實現(xiàn)人臉識別的項目實踐的文章就介紹到這了,更多相關小程序 人臉識別內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • 基于JS對象創(chuàng)建常用方式及原理分析

    基于JS對象創(chuàng)建常用方式及原理分析

    下面小編就為大家?guī)硪黄贘S對象創(chuàng)建常用方式及原理分析。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-06-06
  • js實現(xiàn)頁面導航層級指示效果

    js實現(xiàn)頁面導航層級指示效果

    這篇文章主要為大家詳細介紹了js實現(xiàn)頁面導航層級指示效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-08-08
  • 學習javascript的閉包,原型,和匿名函數(shù)之旅

    學習javascript的閉包,原型,和匿名函數(shù)之旅

    Javascript中有幾個非常重要的語言特性——對象、原型繼承、閉包。其中閉包 對于那些使用傳統(tǒng)靜態(tài)語言C/C++的程序員來說是一個新的語言特性,本文給大家介紹js的閉包,原型,和匿名函數(shù)之旅,感興趣的朋友一起學習吧
    2015-10-10
  • js實現(xiàn)限定范圍拖拽的示例

    js實現(xiàn)限定范圍拖拽的示例

    這篇文章主要介紹了js實現(xiàn)限定范圍拖拽的示例,幫助大家更好的制作js特效,美化自己的網頁,感興趣的朋友可以了解下
    2020-10-10
  • JavaScript對象的四種創(chuàng)建方法

    JavaScript對象的四種創(chuàng)建方法

    這篇文章主要介紹了JavaScript對象的四種創(chuàng)建方法,首先我們通過確定一個對象的屬性和方法展開主題相關內容,需要的小伙伴可以參考一下
    2022-08-08
  • JavaScript實現(xiàn)淺拷貝與深拷貝的方法分析

    JavaScript實現(xiàn)淺拷貝與深拷貝的方法分析

    這篇文章主要介紹了JavaScript實現(xiàn)淺拷貝與深拷貝的方法,結合實例形式總結分析了JavaScript淺拷貝與深拷貝的定義與使用方法,需要的朋友可以參考下
    2018-07-07
  • 微信小程序中懸浮窗功能的實現(xiàn)代碼

    微信小程序中懸浮窗功能的實現(xiàn)代碼

    懸浮窗就是圖中微信圖標的按鈕,采用fixed定位,可拖動和點擊。本文給大家分享一個比較常見的常見,通過實例代碼給大家介紹微信小程序中懸浮窗功能的實現(xiàn),一起看看吧
    2019-08-08
  • 通過身份證號得到出生日期和性別的js代碼

    通過身份證號得到出生日期和性別的js代碼

    主要是通過判斷指定位數(shù)的數(shù)字,來判斷并加以算法實現(xiàn)男女性別的判斷。
    2009-11-11
  • JS給按鈕添加跳轉功能類似a標簽

    JS給按鈕添加跳轉功能類似a標簽

    這篇文章主要介紹了JS給按鈕添加跳轉功能類似a標簽,需要的朋友可以參考下
    2017-05-05
  • jsonp跨域獲取百度聯(lián)想詞的方法分析

    jsonp跨域獲取百度聯(lián)想詞的方法分析

    這篇文章主要介紹了jsonp跨域獲取百度聯(lián)想詞的方法,結合實例形式分析了jsonp的原理及跨域獲取百度聯(lián)想詞的相關操作技巧,需要的朋友可以參考下
    2019-05-05

最新評論