From b172667f354f7f00fe14809e66cbf12362fbc646 Mon Sep 17 00:00:00 2001 From: zhangwei <1504152376@qq.com> Date: 星期五, 06 九月 2024 17:19:36 +0800 Subject: [PATCH] 人脸打卡 --- src/pages/test/test.vue | 132 ++++++++++++++++++++++--------------------- 1 files changed, 68 insertions(+), 64 deletions(-) diff --git a/src/pages/test/test.vue b/src/pages/test/test.vue index c23f9b0..f4deff6 100644 --- a/src/pages/test/test.vue +++ b/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, '涓婁紶鐓х墖鎺ュ彛锛屽浘鐗囨崲鎴愯繙绔痷rl鍦板潃 鑷鏇挎崲'); + this.faceImg = e.tempImagePath + this.$db.set('faceImg',e.tempImagePath) + uni.navigateBack() //涓婁紶鐓х墖鎺ュ彛锛屽浘鐗囨崲鎴愯繙绔痷rl鍦板潃 鑷鏇挎崲 // 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; -- Gitblit v1.9.1