-
zhangwei
2025-03-05 16213c0f85aa3ac8317797bf4a05fd12940e16d3
src/pages/test/test.vue
@@ -40,36 +40,36 @@
       * 生命周期函数--监听页面加载
       */
      onLoad() {
         this.getAuthSetting() //获取权限
         // this.getAuthSetting() //获取权限
         this.initFaceVerify()
      },
      methods: {
         getAuthSetting() {
            wx.getSetting({
               success: (res) => {
                  if (!res.authSetting['scope.camera']) {
                     wx.showModal({
                        title: '请允许获取摄像头权限',
                        showCancel: false,
                        complete: (modalRes) => {
                           if (modalRes.confirm) {
                              wx.openSetting({
                                 success: (settingRes) => {
                                    if (!settingRes.authSetting[
                                          'scope.camera']) {
                                       this.getAuthSetting()
                                    } else {
                                       wx.navigateBack()
                                    }
                                 }
                              })
                           }
                        }
                     })
                  }
               }
            })
         },
         // getAuthSetting() {
         //    wx.getSetting({
         //       success: (res) => {
         //          if (!res.authSetting['scope.camera']) {
         //             wx.showModal({
         //                title: '请允许获取摄像头权限',
         //                showCancel: false,
         //                complete: (modalRes) => {
         //                   if (modalRes.confirm) {
         //                      wx.openSetting({
         //                         success: (settingRes) => {
         //                            if (!settingRes.authSetting[
         //                                  'scope.camera']) {
         //                               this.getAuthSetting()
         //                            } else {
         //                               wx.navigateBack()
         //                            }
         //                         }
         //                      })
         //                   }
         //                }
         //             })
         //          }
         //       }
         //    })
         // },
         initFaceVerify() {
            console.log('我是initFaceVerify----------------------');
            videoCtx = null;
@@ -130,26 +130,28 @@
            VKSession.destroy();
         },
         async getImageBase64_readFile(tempFilePath) {
           const base64 = await new Promise(resolve => {
             //获取全局唯一的文件管理器
             wx.getFileSystemManager()
               .readFile({ //读取本地文件内容
                 filePath: tempFilePath, // 文件路径
                 encoding: 'base64', // 返回格式
                 success: ({data}) => {
                   return resolve('data:image/png;base64,' + data);
                 },
                 fail(res) {
                   console.log('fail', res)
                 }
               });
           });
           wx.hideLoading()
           console.log('base64', base64)
           // this.setData({
           //   saveImg: base64
           // })
            const base64 = await new Promise(resolve => {
               //获取全局唯一的文件管理器
               wx.getFileSystemManager()
                  .readFile({ //读取本地文件内容
                     filePath: tempFilePath, // 文件路径
                     encoding: 'base64', // 返回格式
                     success: ({
                        data
                     }) => {
                        return resolve('data:image/png;base64,' + data);
                     },
                     fail(res) {
                        console.log('fail', res)
                     }
                  });
            });
            wx.hideLoading()
            console.log('base64', base64)
            // this.setData({
            //   saveImg: base64
            // })
         },
         picture() {
            this.startVerify = true
@@ -158,18 +160,22 @@
            videoCtx.takePhoto({
               quality: 'normal',
               success: (e) => {
                  this.getImageBase64_readFile(e.tempImagePath).then(res=>{
                     let obj = {
                        imgBase64:res,//数据base64
                        cordId:'',//身份证号码
                        name:'',//姓名
                        gender:2//性别
                     }
                     this.$api.IaiAddPersoBase64(obj).then(res=>{
                        console.log(res,'----------------');
                     })
                  })
                  // this.getImageBase64_readFile(e.tempImagePath).then(res=>{
                  //    let obj = {
                  //       imgBase64:res,//数据base64
                  //       cordId:'',//身份证号码
                  //       name:'',//姓名
                  //       gender:2//性别
                  //    }
                  //    this.$api.IaiAddPersoBase64(obj).then(res=>{
                  //       console.log(res,'----------------');
                  //    })
                  // })
                  this.verifyText = '面容识别成功'
                  console.log(e.tempImagePath, '上传照片接口,图片换成远端url地址 自行替换');
                  this.faceImg = e.tempImagePath
                  this.$db.set('faceImg',e.tempImagePath)
                  uni.navigateBack()
                  //上传照片接口,图片换成远端url地址 自行替换
                  // uploadImage(e.tempImagePath).then((res) => {
                  //    this.setData({
@@ -314,16 +320,14 @@
   }
   .camera {
      width: 600rpx;
      height: 600rpx;
      border-radius: 50% 50%;
      width: 100vw;
      height: 800rpx;
      margin: 0 auto;
   }
   .faceImg {
      width: 600rpx;
      height: 600rpx;
      border-radius: 50% 50%;
      width: 100vw;
      height: 800rpx;
      margin: 0 auto;
      position: absolute;
      z-index: 999;