From 6fbdeec3c03af548067d95ebed41086e910f6bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E5=B8=85?= Date: Mon, 5 Sep 2022 17:28:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=93=E5=AE=B6=E4=BA=BA=E8=84=B8=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=90=8E=E5=8F=B0=E6=8E=A5=E5=8F=A3=E8=81=94=E8=B0=83?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/userformal/faceLogin/FrameFaceLogin.tsx | 4 ++-- src/pages/userformal/login/index.tsx | 13 +++++-------- src/pages/userformal/login/service.ts | 11 ++++++++++- src/utils/request.ts | 4 +++- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/pages/userformal/faceLogin/FrameFaceLogin.tsx b/src/pages/userformal/faceLogin/FrameFaceLogin.tsx index 87b047b..fa14438 100644 --- a/src/pages/userformal/faceLogin/FrameFaceLogin.tsx +++ b/src/pages/userformal/faceLogin/FrameFaceLogin.tsx @@ -14,9 +14,9 @@ export default class FrameFaceLogin extends React.Component { componentDidMount() { // 接收Iframe传递的数据 window.addEventListener("message", (e) => { - const { image} = e.data || {}; //传递的数据 + const { image } = e.data || {}; //传递的数据 if (image) { - this.props.faceCompareEvent(image, null); + this.props.faceCompareEvent(image); } }); } diff --git a/src/pages/userformal/login/index.tsx b/src/pages/userformal/login/index.tsx index 1e469cc..5fc5be3 100644 --- a/src/pages/userformal/login/index.tsx +++ b/src/pages/userformal/login/index.tsx @@ -255,19 +255,16 @@ const Index: React.FC<{}> = () => { const rawLength = raw.length; const uInt8Array = new Uint8Array(rawLength); for (let i = 0; i < rawLength; i += 1) { - uInt8Array[i] = raw.charCodeAt(i); + uInt8Array[i] = raw.charCodeAt(i); } return new Blob([uInt8Array], { type: contentType }); }; //RgbToBase64 const RgbToBase64 = async (image:any) =>{ - const _body = JSON.stringify({//post请求参数 - type: 'pixel', - rgb: image - }); - await rgbToBase64({_body}).then(res => res.json()).then(res => { - hanleFaceSubmit(base64ToBlob( 'data:image/jpg;base64,' + res.data), null); + await rgbToBase64({image}).then(res => { + const _blob = base64ToBlob( 'data:image/jpg;base64,' + res.data); + hanleFaceSubmit(_blob, null); }); } @@ -378,7 +375,7 @@ const Index: React.FC<{}> = () => { {/* 加载摄像头 */} - {!whetherIE.current ? ():()} + {!whetherIE.current ? ():()} {/* onClick={() => {hanleFaceSubmit(null, null);}} */} diff --git a/src/pages/userformal/login/service.ts b/src/pages/userformal/login/service.ts index 113af4d..48828ed 100644 --- a/src/pages/userformal/login/service.ts +++ b/src/pages/userformal/login/service.ts @@ -10,9 +10,18 @@ export async function changePass(params: any) { }); } +/** + * rgb转base64 + * @param params rgb字符串 + * @returns + */ export async function rgbToBase64(params: any) { + const _body = JSON.stringify({//post请求参数 + type: 'pixel', + rgb: params.image + }); return request('/api/core-service-ebtp-userinfo/outer/v1/ebtp/face/rgbArray2Base64', { method: 'post', - params + body:_body, }); } \ No newline at end of file diff --git a/src/utils/request.ts b/src/utils/request.ts index 4ec02f6..d463c27 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -76,7 +76,9 @@ request.interceptors.request.use(async (url, options) => { url.startsWith('/api/auth/reloadPartnerToken') || url.startsWith('/api/api/mall-expe') || url == '/api/biz-service-ebtp-extend/v1/userpassword/validatePassword' || - url.startsWith('/api/notification') + url.startsWith('/api/notification') || + url == '/api/core-service-ebtp-userinfo/outer/v1/ebtp/face/faceCompare' || + url == '/api/core-service-ebtp-userinfo/outer/v1/ebtp/face/rgbArray2Base64' ) { headers = { ...options.headers,