import { $api } from '@/composables/fetch'
import type { UserInfo } from '@/stores/use-user-store'

export interface LoginParams {
    loginName: string
    password: string
}
export interface TokenInfo {
    data: string
}

export interface RegisterParams extends LoginParams {
    email: string
    phone: string
}

export interface ResetPasswordParams {
    email: string
    code: string
    newPassword: string
}

export const userApi = {
    // 登录
    login: (params: LoginParams) => {
        return $api.post<string>('/custom/login', params)
    },
    // 获取用户信息
    getUserInfo: () => {
        return $api.post<UserInfo>('/custom/info')
    },
    // 获取用户信息
    getUserSingle: () => {
        return $api.post<UserInfo>('/ucard/api/merchant/user/single')
    },
    //退出登录
    logout: () => {
        return $api.post('/custom/logout', {})
    },
    //忘记密码
    updatePassword: (params: { email: string }) => {
        return $api.post('/custom/update/password/send/email', params)
    },
    //用户余额
    walletBalance: (params= {}) => {
        return $api.post('/custom/get/balance', params)
    },
    //修改密码
    updateEmailPassword: (params= {}) => {
        return $api.post('/custom/update/email/password', params)
    }
}
