import { post } from '../utils/request'; import { API_PATHS } from '../utils/config'; /** * 用户相关接口 */ /** * 登录结果接口 */ export interface LoginResult { token: string; userInfo: UserInfo; } /** * 用户信息接口 */ export interface UserInfo { id: number; nickname: string; phone: string; avatar: string; } /** * 微信小程序手机号快速登录 * 使用button open-type="getPhoneNumber"获取手机号 * @param params { code, phoneCode } * code: 微信登录凭证(用于获取openid) * phoneCode: 手机号获取凭证(用于获取手机号) */ export const loginByMiniappPhone = (params: { code: string; phoneCode: string }): Promise => { return post(API_PATHS.loginMiniappPhone, params); }; /** * 获取用户信息 */ export const getUserInfo = (): Promise => { return post(API_PATHS.getUserInfo); }; /** * 退出登录 */ export const logout = (): Promise => { return post(API_PATHS.logout); };