From 3a44a818d8b49e129b75244d5fe0b4361dd8e450 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Fri, 17 May 2024 21:03:00 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/common/captcha.ts | 8 ++-- src/apis/common/type.ts | 10 +---- src/components/Verify/Verify/VerifyPoints.vue | 6 +-- src/components/Verify/Verify/VerifySlide.vue | 6 +-- src/utils/encrypt.ts | 2 +- src/views/login/components/phone/index.vue | 44 ++++++++----------- src/views/setting/components/VerifyModel.vue | 28 ++++++------ 7 files changed, 46 insertions(+), 58 deletions(-) diff --git a/src/apis/common/captcha.ts b/src/apis/common/captcha.ts index 35d300d..6900e11 100644 --- a/src/apis/common/captcha.ts +++ b/src/apis/common/captcha.ts @@ -19,11 +19,11 @@ export function getEmailCaptcha(query: { email: string }) { } /** @desc 获取行为验证码 */ -export function getBehaviorCaptcha(params: any) { - return http.get(`${BASE_URL}/behavior`, {params}); +export function getBehaviorCaptcha(req: any) { + return http.get(`${BASE_URL}/behavior`, req) } /** @desc 校验行为验证码 */ -export function checkBehaviorCaptcha(params: any) { - return http.post(`${BASE_URL}/behavior`, params); +export function checkBehaviorCaptcha(req: any) { + return http.post(`${BASE_URL}/behavior`, req) } diff --git a/src/apis/common/type.ts b/src/apis/common/type.ts index f17c1dc..96614c2 100644 --- a/src/apis/common/type.ts +++ b/src/apis/common/type.ts @@ -20,13 +20,7 @@ export interface DashboardNoticeResp { } /* 行为验证码类型 */ -export interface BehaviorCaptchaReq { - captchaType?: string - captchaVerification?: string - clientUid?: string -} - -export interface BehaviorCaptchaRes { +export interface BehaviorCaptchaResp { originalImageBase64: string point: { x: number @@ -38,7 +32,7 @@ export interface BehaviorCaptchaRes { wordList: string[] } -export interface CheckBehaviorCaptchaRes { +export interface CheckBehaviorCaptchaResp { repCode: string repMsg: string } diff --git a/src/components/Verify/Verify/VerifyPoints.vue b/src/components/Verify/Verify/VerifyPoints.vue index 5dfc079..33ebe05 100644 --- a/src/components/Verify/Verify/VerifyPoints.vue +++ b/src/components/Verify/Verify/VerifyPoints.vue @@ -77,7 +77,7 @@ import { getBehaviorCaptcha } from '@/apis/common/captcha' import { resetSize } from '@/utils/verify' -import { aesEncrypt } from '@/utils/encrypt' +import { encryptByAes } from '@/utils/encrypt' export default { name: 'VerifyPoints', @@ -224,7 +224,7 @@ export default { setTimeout(() => { // 发送后端请求 const captchaVerification = secretKey.value - ? aesEncrypt( + ? encryptByAes( `${backToken.value}---${JSON.stringify(checkPosArr)}`, secretKey.value ) @@ -232,7 +232,7 @@ export default { const data = { captchaType: captchaType.value, pointJson: secretKey.value - ? aesEncrypt(JSON.stringify(checkPosArr), secretKey.value) + ? encryptByAes(JSON.stringify(checkPosArr), secretKey.value) : JSON.stringify(checkPosArr), token: backToken.value } diff --git a/src/components/Verify/Verify/VerifySlide.vue b/src/components/Verify/Verify/VerifySlide.vue index 142e000..0150be7 100644 --- a/src/components/Verify/Verify/VerifySlide.vue +++ b/src/components/Verify/Verify/VerifySlide.vue @@ -108,7 +108,7 @@ import { checkBehaviorCaptcha, getBehaviorCaptcha } from '@/apis/common/captcha' -import { aesEncrypt } from '@/utils/encrypt' +import { encryptByAes } from '@/utils/encrypt' import { resetSize } from '@/utils/verify' export default { @@ -283,7 +283,7 @@ export default { const data = { captchaType: captchaType.value, pointJson: secretKey.value - ? aesEncrypt( + ? encryptByAes( JSON.stringify({ x: moveLeftDistance, y: 5.0 }), secretKey.value ) @@ -310,7 +310,7 @@ export default { / 1000 ).toFixed(2)}s验证成功` const captchaVerification = secretKey.value - ? aesEncrypt( + ? encryptByAes( `${backToken.value}---${JSON.stringify({ x: moveLeftDistance, y: 5.0 diff --git a/src/utils/encrypt.ts b/src/utils/encrypt.ts index e91a959..48b1209 100644 --- a/src/utils/encrypt.ts +++ b/src/utils/encrypt.ts @@ -28,7 +28,7 @@ export function encryptByRsa(txt: string) { const defaultKeyWork = 'XwKsGlMcdPMEhR1B' -export function aesEncrypt(word, keyWord = defaultKeyWork) { +export function encryptByAes(word, keyWord = defaultKeyWork) { const key = CryptoJS.enc.Utf8.parse(keyWord) const arcs = CryptoJS.enc.Utf8.parse(word) const encrypted = CryptoJS.AES.encrypt(arcs, key, { diff --git a/src/views/login/components/phone/index.vue b/src/views/login/components/phone/index.vue index b9a13a2..a74e1d3 100644 --- a/src/views/login/components/phone/index.vue +++ b/src/views/login/components/phone/index.vue @@ -18,7 +18,7 @@ :loading="captchaLoading" :disabled="captchaDisable" size="large" - @click="handleOpenBehaviorCaptcha" + @click="onCaptcha" > {{ captchaBtnName }} @@ -31,12 +31,12 @@ + ref="VerifyRef" + :captcha-type="captchaType" + :mode="captchaMode" + :img-size="{ width: '330px', height: '155px' }" + @success="getCaptcha" + />