Skip to content

Commit

Permalink
fix: 修复获取短信、邮箱验证码缺失行为验证码参数错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Oct 19, 2024
1 parent 455f269 commit 1cb0172
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/apis/common/captcha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ export function getImageCaptcha() {
}

/** @desc 获取短信验证码 */
export function getSmsCaptcha(query: { phone: string }) {
return http.get<boolean>(`${BASE_URL}/sms`, query)
export function getSmsCaptcha(phone: string, captchaReq: T.BehaviorCaptchaReq) {
return http.get<boolean>(`${BASE_URL}/sms?phone=${phone}&captchaVerification=${encodeURIComponent(captchaReq.captchaVerification || '')}`)
}

/** @desc 获取邮箱验证码 */
export function getEmailCaptcha(query: { email: string }) {
return http.get<boolean>(`${BASE_URL}/mail`, query)
export function getEmailCaptcha(email: string, captchaReq: T.BehaviorCaptchaReq) {
return http.get<boolean>(`${BASE_URL}/mail?email=${email}&captchaVerification=${encodeURIComponent(captchaReq.captchaVerification || '')}`)
}

/** @desc 获取行为验证码 */
Expand Down
6 changes: 6 additions & 0 deletions src/apis/common/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export interface BehaviorCaptchaResp {
wordList: string[]
}

export interface BehaviorCaptchaReq {
captchaType?: string
captchaVerification?: string
clientUid?: string
}

export interface CheckBehaviorCaptchaResp {
repCode: string
repMsg: string
Expand Down
12 changes: 4 additions & 8 deletions src/views/setting/components/VerifyModel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { useWindowSize } from '@vueuse/core'
import { Message } from '@arco-design/web-vue'
import NProgress from 'nprogress'
import { getEmailCaptcha, updateUserEmail, updateUserPassword, updateUserPhone } from '@/apis'
import { type BehaviorCaptchaReq, getEmailCaptcha, updateUserEmail, updateUserPassword, updateUserPhone } from '@/apis'
import { encryptByRsa } from '@/utils/encrypt'
import { useUserStore } from '@/stores'
import { type Columns, GiForm, type Options } from '@/components/GiForm'
Expand Down Expand Up @@ -173,19 +173,15 @@ const reset = () => {
}
// 获取验证码
const getCaptcha = async () => {
const getCaptcha = async (captchaReq: BehaviorCaptchaReq) => {
// 发送验证码
try {
captchaLoading.value = true
captchaBtnName.value = '发送中...'
if (verifyType.value === 'phone') {
// await getSmsCaptcha({
// phone: form.phone
// })
// await getSmsCaptcha(form.phone, captchaReq)
} else if (verifyType.value === 'email') {
await getEmailCaptcha({
email: form.email
})
await getEmailCaptcha(form.email, captchaReq)
}
captchaLoading.value = false
captchaDisable.value = true
Expand Down

0 comments on commit 1cb0172

Please sign in to comment.