import { api, adminApi } from '@/api/client' import type { LegalAgreement, LoginResponse, LoginShopSelectionResponse } from '@/types/common' export interface PasswordLoginRequest { account: string password: string shopId?: string | number agreementAccepted: boolean agreementVersions: Record clientType: string } export interface PhoneLoginRequest { phone: string verificationCode: string shopId?: string | number agreementAccepted: boolean agreementVersions: Record clientType: string } export interface RegisterRequest { account: string password: string nickname: string shopName: string phone: string verificationCode: string agreementAccepted: boolean agreementVersions: Record clientType: string } export const authApi = { passwordLogin(data: PasswordLoginRequest): Promise { return adminApi.post('/auth/login', data) }, getPasswordLoginShops(account: string): Promise { return adminApi.get(`/auth/login-shops/${encodeURIComponent(account)}`) }, sendRegisterCode(phone: string): Promise { return api.post('/user/send-verification-code', { phone, sceneCode: 'PLANNING_MANAGER_REGISTER' }) }, sendLoginCode(phone: string): Promise { return api.post('/user/send-verification-code', { phone, sceneCode: 'USER_LOGIN_SMS_CODE' }) }, phoneLogin(data: PhoneLoginRequest): Promise { return api.post('/user/phone-login', data) }, getPhoneLoginShops(phone: string): Promise { return api.get(`/user/check/login-shops/phone/${encodeURIComponent(phone)}`) }, getCurrentAgreements(): Promise { return api.get('/legal-agreement/current') }, register(data: RegisterRequest): Promise { return adminApi.post('/auth/register', data) }, switchShop(shopId: string | number): Promise { return adminApi.post('/auth/switch-shop', { shopId }) }, logout(): Promise { return adminApi.post('/auth/logout') } }