diff --git a/src/api/customer/index.ts b/src/api/customer/index.ts index 43b44e9..6cd2dd8 100644 --- a/src/api/customer/index.ts +++ b/src/api/customer/index.ts @@ -3,8 +3,10 @@ */ import { axiosInstance } from '@/api/rbac' import { assertBusinessOk, omsUrl, parseListPayload, unwrapData } from '@/api/oms/common' +import { CUSTOMER_STATUS } from '@/utils/customerStatus' -export type CustomerStatus = 0 | 1 | 2 +/** 与后端 CustomerStatus 对齐:0=None,1=Disabled,2=Normal,3=Frozen */ +export type CustomerStatus = 0 | 1 | 2 | 3 export type CustomerGroup = 0 | 1 | 2 | 3 | 4 | 5 @@ -154,7 +156,7 @@ export const CustomerService = { balance: data.accountBalance ?? data.balance ?? 0, totalQuota: data.totalQuota ?? 0, usedQuota: data.usedQuota ?? 0, - status: data.status ?? 1, + status: data.status ?? CUSTOMER_STATUS.normal, remark: data.remark, salesman: data.salesman ?? data.salesPerson, customerService: data.customerService, @@ -186,7 +188,8 @@ export const CustomerService = { balance: data.accountBalance ?? data.balance, totalQuota: data.totalQuota, usedQuota: data.usedQuota, - status: data.status ?? 1, + // 后端:1=Disabled,2=Normal;勿默认 1,否则公开注册账号无法登录 + status: data.status ?? CUSTOMER_STATUS.normal, role: data.role, remark: data.remark, salesman: data.salesman ?? data.salesPerson, diff --git a/src/store/modules/rbac-user.ts b/src/store/modules/rbac-user.ts index 352a528..605196c 100644 --- a/src/store/modules/rbac-user.ts +++ b/src/store/modules/rbac-user.ts @@ -318,7 +318,11 @@ export const useRbacUserStore = defineStore('rbacUser', () => { enableKeepAlive() await hydrateUserAfterLogin(result) return true - } catch { + } catch (error: unknown) { + // 交给登录页展示业务文案(如「客户已禁用」),勿一律当成账号密码错误 + const anyErr = error as { body?: { message?: string }; message?: string } + const msg = String(anyErr?.body?.message || anyErr?.message || '').trim() + if (msg) throw new Error(msg) return false } } diff --git a/src/views/login/components/pwd-login/index.vue b/src/views/login/components/pwd-login/index.vue index 3d5bdf1..f554177 100644 --- a/src/views/login/components/pwd-login/index.vue +++ b/src/views/login/components/pwd-login/index.vue @@ -350,11 +350,19 @@ async function handleSubmit() { loading.value = true; errorBox.value = ''; - const success = await rbacUserStore.login( - loginForm.account, - loginForm.password, - props.loginType, - ); + let success = false; + try { + success = await rbacUserStore.login( + loginForm.account, + loginForm.password, + props.loginType, + ); + } catch (loginErr: unknown) { + const msg = loginErr instanceof Error ? loginErr.message.trim() : ''; + errorBox.value = msg || t('login.form.login.failed'); + loginCharacters.value?.onLoginFailed(); + return; + } if (success && rbacUserStore.userInfo) { const userInfoData = rbacUserStore.userInfo;