diff --git a/src/api/auth.ts b/src/api/auth.ts index 13fff33..eb49856 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -5,6 +5,7 @@ import type { TokenResponse } from '@/types/api' import { joinUrl } from '@/utils/url' export interface OrganizationMemberInfo { + userId?: string memberId?: string organizationId?: string memberName?: string @@ -28,7 +29,7 @@ export const getImageCodeUrl = (imageRandomStr: string) => { randomStr: imageRandomStr, t: String(Date.now()) }) - return `${joinUrl(env.authBase, 'code/image')}?${params.toString()}` + return `${joinUrl(env.apiBase, env.authBase, 'code/image')}?${params.toString()}` } export const sendMobileCode = async (payload: SendMobileCodePayload) => { @@ -72,3 +73,10 @@ export const bindUserInfoAndGetUserMemberInfoByPhone = async (phone: string) => { userPhone: phone } ) as unknown as OrganizationMemberInfo } + +export const getBindStaffInfo = async () => { + if (env.useMock) return mockApi.getBindStaffInfo() + return await http.post( + joinUrl(env.staffBase, 'user/getBindStaffInfo') + ) as unknown as OrganizationMemberInfo +} diff --git a/src/api/mock.ts b/src/api/mock.ts index 6aa8491..d4e662e 100644 --- a/src/api/mock.ts +++ b/src/api/mock.ts @@ -171,6 +171,17 @@ export const mockApi = { } }, + async getBindStaffInfo() { + await wait(180) + return { + userId: 'USER10001', + memberId: 'MEMBER10001', + organizationId: 'ORG10001', + memberName: '当前员工', + memberRoleId: 'ROLE_STAFF' + } + }, + async orderList(query: CommodityOrderSearch) { await wait() const keyword = query.orderId || query.contactPhone || '' diff --git a/src/stores/auth.ts b/src/stores/auth.ts index cfcbe11..b1f0dfe 100644 --- a/src/stores/auth.ts +++ b/src/stores/auth.ts @@ -1,7 +1,7 @@ import { computed, ref } from 'vue' import { defineStore } from 'pinia' import { - bindUserInfoAndGetUserMemberInfoByPhone, + getBindStaffInfo, loginByMobile, type OrganizationMemberInfo } from '@/api/auth' @@ -66,7 +66,7 @@ export const useAuthStore = defineStore('auth', () => { const payload = await loginByMobile(phone, code) persistToken(payload, phone) try { - const member = await bindUserInfoAndGetUserMemberInfoByPhone(phone) + const member = await getBindStaffInfo() if (!member?.organizationId || !member?.memberId) { throw new Error('未绑定组织,请联系管理员') } diff --git a/src/views/login/LoginView.vue b/src/views/login/LoginView.vue index c120c27..3d31dac 100644 --- a/src/views/login/LoginView.vue +++ b/src/views/login/LoginView.vue @@ -1,5 +1,5 @@