| | |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | 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; |
| | |
| | | .readFile({ //读取本地文件内容 |
| | | filePath: tempFilePath, // 文件路径 |
| | | encoding: 'base64', // 返回格式 |
| | | success: ({data}) => { |
| | | success: ({ |
| | | data |
| | | }) => { |
| | | return resolve('data:image/png;base64,' + data); |
| | | }, |
| | | fail(res) { |
| | |
| | | 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({ |
| | |
| | | } |
| | | |
| | | .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; |