亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

小程序?qū)崿F(xiàn)人臉識(shí)別的項(xiàng)目實(shí)踐

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

調(diào)用api   wx.startFacialRecognitionVerify

第一步:

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

第二步:調(diào)方法 校驗(yàn)后端的接口

 // 人臉識(shí)別  根據(jù)上一個(gè)方法把verify_result傳過(guò)來(lái)  //后端的校驗(yàn)接口
      verifyUser(verify_result) {
        //看后端實(shí)際要求 要傳身份證號(hào)碼不
        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()
                  //修改成功后 是返回上一步  還是跳轉(zhuǎn)其他頁(yè)面 根據(jù)實(shí)際情況
                } else {
                  uni.$u.toast(res.msg, 5000)
                }
              })
              console.log(res);
            }).catch(error => {
              console.log(error);
              uni.$u.toast('請(qǐng)先按要求填寫', 5000)
            })
          }
        })
      },

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

 // 修改方法
      expertUpdate() {
        if (this.fileList1.length == 0) {
          uni.$u.toast('請(qǐng)上傳頭像')
          return false
        }
        // 判斷 realName 是否為空
        if (!this.infoForm.realName) {
          uni.$u.toast('請(qǐng)?zhí)顚懶彰?);
          return false;
        }
        // 驗(yàn)證 realName 是否為中文
        const chineseRegex = /^[\u4e00-\u9fa5]+$/;
        if (!chineseRegex.test(this.infoForm.realName)) {
          uni.$u.toast('姓名必須為中文');
          return false;
        }
        // 判斷 idCard 是否為空
        if (!this.infoForm.idCard) {
          uni.$u.toast('請(qǐng)?zhí)顚懮矸葑C號(hào)碼');
          return false;
        }
        // 驗(yàn)證 idCard 是否符合身份證標(biāo)準(zhǔn)
        const idCardRegex = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
        if (!idCardRegex.test(this.infoForm.idCard)) {
          uni.$u.toast('身份證號(hào)格式不正確');
          return false;
        }
        if (this.fileList2.length == 0) {
          uni.$u.toast('請(qǐng)上傳附件')
          return false
        }
        if (this.infoForm.intro.length > 200) {
          uni.$u.toast('簡(jiǎn)介字?jǐn)?shù)不能超過(guò)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('請(qǐng)先按要求填寫', 5000)
          })
        }
      },
      // 人臉識(shí)別
      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('請(qǐng)先按要求填寫', 5000)
            })
          }
        })
      },
      

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

相關(guān)文章

最新評(píng)論