feat: get user detail info
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import Taro from '@tarojs/taro';
|
||||
import httpService from './httpService';
|
||||
import httpService, { ApiResponse } from './httpService';
|
||||
import tokenManager from '../utils/tokenManager';
|
||||
|
||||
// 微信用户信息接口
|
||||
@@ -34,8 +34,26 @@ export interface VerifyCodeResponse {
|
||||
token?: string;
|
||||
user_info?: WechatUserInfo;
|
||||
}
|
||||
|
||||
|
||||
// 用户详细信息
|
||||
export interface UserInfoType {
|
||||
id: number
|
||||
openid: string
|
||||
unionid: string
|
||||
session_key: string
|
||||
nickname: string
|
||||
avatar_url: string
|
||||
gender: string
|
||||
country: string
|
||||
province: string
|
||||
city: string
|
||||
language: string
|
||||
phone: string
|
||||
is_subscribed: string
|
||||
latitude: number
|
||||
longitude: number
|
||||
subscribe_time: string
|
||||
last_login_time: string
|
||||
}
|
||||
|
||||
|
||||
// 微信授权登录
|
||||
@@ -332,8 +350,19 @@ export const refresh_login_status = async (): Promise<boolean> => {
|
||||
}
|
||||
};
|
||||
|
||||
// 获取用户详细信息
|
||||
export const fetchUserProfile = async (): Promise<ApiResponse<UserInfoType>> => {
|
||||
try {
|
||||
const response = await httpService.post('/user/detail');
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
// 更新用户信息
|
||||
export const updateUserProfile = async (payload: Partial<WechatUserInfo> & { latitude?: number; longitude?: number; }) => {
|
||||
export const updateUserProfile = async (payload: Partial<UserInfoType>) => {
|
||||
try {
|
||||
const response = await httpService.post('user/update', payload);
|
||||
return response;
|
||||
|
||||
Reference in New Issue
Block a user