user.js 678 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * 用户模块 API
  3. */
  4. import http from '@/utils/http'
  5. /**
  6. * 获取当前用户个人资料
  7. * @returns {Promise<{userId, nickname, avatar, phone, appId}>}
  8. */
  9. export function getProfile() {
  10. return http.get('/app/user/profile')
  11. }
  12. /**
  13. * 修改当前用户个人资料(昵称、头像)
  14. * @param {Object} data - { nickname?, avatar? }
  15. */
  16. export function updateProfile(data) {
  17. return http.put('/app/user/profile', data)
  18. }
  19. /**
  20. * 上传头像图片到 OSS
  21. * @param {string} filePath - 本地图片临时路径
  22. * @returns {Promise<{url: string}>} OSS 公网访问 URL
  23. */
  24. export function uploadAvatar(filePath) {
  25. return http.upload('/file/image', { filePath })
  26. }