import { get, post, put, patch, del } from '../client' import { idempotencyKey } from '../idempotency' /** 本人全局状态(GET /me/status) */ export const userService = { getStatus() { return get('/me/status') }, } /** 本人资料 / 择偶条件 / 照片 / 隐私 / 审核 / 关系状态(对齐 miniapp/services/profileService.js) */ export const profileService = { getProfile() { return get('/me/profile') }, updateProfile(payload: Record) { return put('/me/profile', payload, { idempotencyKey: idempotencyKey('profile-put', payload?.userId || 'me') }) }, updateBasicProfile(payload: Record) { return patch('/me/profile/basic', payload, { idempotencyKey: idempotencyKey('profile-basic', 'me') }) }, getCompletion() { return get('/me/profile/completion') }, getPreferences() { return get('/me/preferences') }, updatePreferences(payload: Record) { return put('/me/preferences', payload, { idempotencyKey: idempotencyKey('preferences-put') }) }, getPhotos() { return get('/me/photos') }, deletePhoto(photoId: string) { return del(`/me/photos/${encodeURIComponent(photoId)}`) }, setMainPhoto(photoId: string) { return put(`/me/photos/${encodeURIComponent(photoId)}/main`, {}, { idempotencyKey: idempotencyKey('photo-main', photoId) }) }, requestUploadToken(payload: { fileName: string; contentType?: string }) { return post('/me/photos/upload-token', payload, { idempotencyKey: payload.fileName }) }, confirmPhoto(payload: { fileKey: string; photoType: string }) { return post('/me/photos/confirm', payload, { idempotencyKey: idempotencyKey('photo-confirm', payload.fileKey) }) }, getPrivacySettings() { return get('/me/privacy-settings') }, updatePrivacySettings(payload: Record) { return put('/me/privacy-settings', payload, { idempotencyKey: idempotencyKey('privacy-put') }) }, getReviewStatus() { return get('/me/profile/review-status') }, submitReview() { return post('/me/profile/submit-review', {}, { idempotencyKey: idempotencyKey('review-submit') }) }, getRelationshipStatus() { return get('/me/relationship-status') }, pauseSearching() { return patch('/me/relationship-status', { status: 'paused' }, { idempotencyKey: idempotencyKey('rel-pause') }) }, resumeSearching() { return patch('/me/relationship-status', { status: 'searching' }, { idempotencyKey: idempotencyKey('rel-resume') }) }, markGettingToKnow() { return patch('/me/relationship-status', { status: 'getting_to_know' }, { idempotencyKey: idempotencyKey('rel-gtk') }) }, } /** 实名认证 */ export const verificationService = { submit(payload: { realName: string; idCardNumber: string; faceImageUrl?: string }) { const tail = (payload.idCardNumber || '').slice(-4).toUpperCase() return post('/verification/submit', payload, { idempotencyKey: idempotencyKey('verification-submit', tail) }) }, getStatus() { return get('/verification/status') }, } /** 本地资格核验 */ export const localEligibilityService = { getStatus() { return get('/local-eligibility') }, declare(payload: Record) { return post('/local-eligibility/declaration', payload) }, uploadEvidence(payload: Record) { return post('/local-eligibility/evidences', payload) }, submit() { return post('/local-eligibility/submit', {}, { idempotencyKey: idempotencyKey('local-eligibility-submit') }) }, } /** 通知(用户端不提供聊天,仅通知) */ export const notificationService = { getNotifications(params: Record = {}) { return get('/notifications', params) }, markNotificationRead(id: string) { return put(`/notifications/${encodeURIComponent(id)}/read`) }, markAllNotificationsRead() { return put('/notifications/read-all') }, getNotificationsUnreadCount() { // 后端实际路由为 GET /notifications/unread(返回 {count}) return get('/notifications/unread') }, } /** 公益服务记录(我的服务时间线) */ export const serviceHistoryService = { getMyServiceHistory() { return get('/me/service-history') }, }