验证码修改

This commit is contained in:
2025-12-16 18:26:52 +08:00
parent 62e6365d46
commit f7b0dcd120
10 changed files with 70 additions and 46 deletions

View File

@@ -61,20 +61,22 @@ export const authApi = {
/**
* 发送手机验证码
* @param phone 手机号
* @returns Promise<ResultDomain<{sessionId: string, message: string}>>
* @param scene 业务场景login-登录, register-注册, reset-找回密码, bind-绑定手机等)
* @returns Promise<ResultDomain<{sessionId: string, expireTime: string, message: string}>>
*/
async sendSmsCode(phone: string): Promise<ResultDomain<{sessionId: string, message: string}>> {
const response = await api.post<{sessionId: string, message: string}>('/auth/send-sms-code', { phone });
async sendSmsCode(phone: string, scene: string = 'default'): Promise<ResultDomain<{sessionId: string, expireTime: string, message: string}>> {
const response = await api.post<{sessionId: string, expireTime: string, message: string}>('/auth/send-sms-code', { phone, scene });
return response.data;
},
/**
* 发送邮箱验证码
* @param email 邮箱
* @returns Promise<ResultDomain<{sessionId: string, message: string}>>
* @param scene 业务场景login-登录, register-注册, reset-找回密码, bind-绑定邮箱等)
* @returns Promise<ResultDomain<{sessionId: string, expireTime: string, message: string}>>
*/
async sendEmailCode(email: string): Promise<ResultDomain<{sessionId: string, message: string}>> {
const response = await api.post<{sessionId: string, message: string}>('/auth/send-email-code', { email });
async sendEmailCode(email: string, scene: string = 'default'): Promise<ResultDomain<{sessionId: string, expireTime: string, message: string}>> {
const response = await api.post<{sessionId: string, expireTime: string, message: string}>('/auth/send-email-code', { email, scene });
return response.data;
}
};

View File

@@ -320,7 +320,7 @@ const handleSendSmsCode = async () => {
}
try {
const result = await authApi.sendSmsCode(forgotForm.phone);
const result = await authApi.sendSmsCode(forgotForm.phone, 'reset');
if (result.code === 200 && result.data) {
// 保存sessionId
forgotForm.smsSessionId = result.data.sessionId;
@@ -354,7 +354,7 @@ const handleSendEmailCode = async () => {
}
try {
const result = await authApi.sendEmailCode(forgotForm.email);
const result = await authApi.sendEmailCode(forgotForm.email, 'reset');
if (result.code === 200 && result.data) {
// 保存sessionId
forgotForm.emailSessionId = result.data.sessionId;

View File

@@ -319,7 +319,7 @@ const handleSendSmsCode = async () => {
}
try {
const result = await authApi.sendSmsCode(forgotForm.phone);
const result = await authApi.sendSmsCode(forgotForm.phone, 'reset');
if (result.code === 200 && result.data) {
// 保存sessionId
forgotForm.smsSessionId = result.data.sessionId;
@@ -353,7 +353,7 @@ const handleSendEmailCode = async () => {
}
try {
const result = await authApi.sendEmailCode(forgotForm.email);
const result = await authApi.sendEmailCode(forgotForm.email, 'reset');
if (result.code === 200 && result.data) {
// 保存sessionId
forgotForm.emailSessionId = result.data.sessionId;

View File

@@ -358,7 +358,7 @@ const handleSendSmsCode = async () => {
}
try {
const result = await authApi.sendSmsCode(loginForm.phone);
const result = await authApi.sendSmsCode(loginForm.phone, 'login');
if (result.code === 200 && result.data) {
// 保存sessionId
loginForm.captchaId = result.data.sessionId;
@@ -396,7 +396,7 @@ const handleSendEmailCode = async () => {
}
try {
const result = await authApi.sendEmailCode(loginForm.email);
const result = await authApi.sendEmailCode(loginForm.email, 'login');
if (result.code === 200 && result.data) {
// 保存sessionId
loginForm.captchaId = result.data.sessionId;

View File

@@ -358,7 +358,7 @@ const handleSendSmsCode = async () => {
}
try {
const result = await authApi.sendSmsCode(loginForm.phone);
const result = await authApi.sendSmsCode(loginForm.phone, 'login');
if (result.code === 200 && result.data) {
// 保存sessionId
loginForm.captchaId = result.data.sessionId;
@@ -396,7 +396,7 @@ const handleSendEmailCode = async () => {
}
try {
const result = await authApi.sendEmailCode(loginForm.email);
const result = await authApi.sendEmailCode(loginForm.email, 'login');
if (result.code === 200 && result.data) {
// 保存sessionId
loginForm.captchaId = result.data.sessionId;

View File

@@ -387,7 +387,7 @@ const handleSendSmsCode = async () => {
}
try {
const result = await authApi.sendSmsCode(registerForm.phone!);
const result = await authApi.sendSmsCode(registerForm.phone!, 'register');
if (result.code === 200 && result.data) {
// 保存sessionId
registerForm.smsSessionId = result.data.sessionId;
@@ -421,7 +421,7 @@ const handleSendEmailCode = async () => {
}
try {
const result = await authApi.sendEmailCode(registerForm.email!);
const result = await authApi.sendEmailCode(registerForm.email!, 'register');
if (result.code === 200 && result.data) {
// 保存sessionId
registerForm.emailSessionId = result.data.sessionId;

View File

@@ -398,7 +398,7 @@ const handleSendSmsCode = async () => {
}
try {
const result = await authApi.sendSmsCode(registerForm.phone!);
const result = await authApi.sendSmsCode(registerForm.phone!, 'register');
if (result.code === 200 && result.data) {
// 保存sessionId
registerForm.smsSessionId = result.data.sessionId;
@@ -432,7 +432,7 @@ const handleSendEmailCode = async () => {
}
try {
const result = await authApi.sendEmailCode(registerForm.email!);
const result = await authApi.sendEmailCode(registerForm.email!, 'register');
if (result.code === 200 && result.data) {
// 保存sessionId
registerForm.emailSessionId = result.data.sessionId;