feat: 登录接口错误信息码调整
This commit is contained in:
@ -60,8 +60,8 @@ export class Request {
|
|||||||
|
|
||||||
this.instance.interceptors.response.use(
|
this.instance.interceptors.response.use(
|
||||||
(res: AxiosResponse) => {
|
(res: AxiosResponse) => {
|
||||||
const { data } = res;
|
const { data, status } = res;
|
||||||
switch (data.code) {
|
switch (status) {
|
||||||
case HttpStatusCode.Success:
|
case HttpStatusCode.Success:
|
||||||
return data;
|
return data;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -303,6 +303,12 @@ const handleSubmit = async () => {
|
|||||||
const _fn = isCaptchaLogin.value ? fetchAuthorizationsCaptcha : postLoginPassword;
|
const _fn = isCaptchaLogin.value ? fetchAuthorizationsCaptcha : postLoginPassword;
|
||||||
const { code, data, message: errorInfo } = await _fn(loginForm);
|
const { code, data, message: errorInfo } = await _fn(loginForm);
|
||||||
|
|
||||||
|
console.log(code, errorInfo);
|
||||||
|
if (code === 10001) {
|
||||||
|
errMsg.value = errorInfo;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
// 处理登录成功逻辑
|
// 处理登录成功逻辑
|
||||||
message.success('登录成功');
|
message.success('登录成功');
|
||||||
@ -318,10 +324,6 @@ const handleSubmit = async () => {
|
|||||||
|
|
||||||
getProfileInfo();
|
getProfileInfo();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
if (error?.status === 400) {
|
|
||||||
errMsg.value = error.data?.message;
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
submitting.value = false;
|
submitting.value = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Input>
|
</Input>
|
||||||
|
<p class="color-#F64B31 text-12px font-400 lh-20px font-family-regular" v-if="errMsg">
|
||||||
|
{{ errMsg }}
|
||||||
|
</p>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
||||||
<FormItem class="mt-52px">
|
<FormItem class="mt-52px">
|
||||||
@ -130,6 +133,7 @@ const mobileNumber = ref('');
|
|||||||
const selectAccountModalRef = ref(null);
|
const selectAccountModalRef = ref(null);
|
||||||
const accounts = ref([]);
|
const accounts = ref([]);
|
||||||
const isLegalMobile = ref(false);
|
const isLegalMobile = ref(false);
|
||||||
|
const errMsg = ref('');
|
||||||
|
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
mobile: '',
|
mobile: '',
|
||||||
@ -315,6 +319,11 @@ const handleSubmit = async () => {
|
|||||||
const _fn = isResetPassword.value ? postForgetPassword : postRegister;
|
const _fn = isResetPassword.value ? postForgetPassword : postRegister;
|
||||||
const { code, data, message: errorInfo } = await _fn(formData.value);
|
const { code, data, message: errorInfo } = await _fn(formData.value);
|
||||||
|
|
||||||
|
if (code === 10001) {
|
||||||
|
errMsg.value = errorInfo;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
message.success(isResetPassword.value ? '重置成功' : '注册成功');
|
message.success(isResetPassword.value ? '重置成功' : '注册成功');
|
||||||
// 注册成功后跳转登录页
|
// 注册成功后跳转登录页
|
||||||
@ -337,10 +346,6 @@ const handleSubmit = async () => {
|
|||||||
|
|
||||||
getProfileInfo();
|
getProfileInfo();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
if (error?.status === 400) {
|
|
||||||
errMsg.value = error.data?.message;
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
submitting.value = false;
|
submitting.value = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user