This commit is contained in:
2025-08-15 16:52:03 +08:00
parent de2d6e6b70
commit 2986b212a0
11 changed files with 1787 additions and 0 deletions
+212
View File
@@ -0,0 +1,212 @@
// 领养专区相关API接口
/**
* 获取待领养宠物列表
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getAdoptionPets = (params = {}, config = {}) => {
return uni.$u.http.get('/adoption/pets', {
params,
custom: {
auth: false,
loading: true,
...config.custom
},
...config
})
}
/**
* 搜索宠物
* @param {Object} searchParams 搜索参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const searchPets = (searchParams, config = {}) => {
return uni.$u.http.get('/adoption/pets/search', {
params: searchParams,
custom: {
auth: false,
loading: true,
...config.custom
},
...config
})
}
/**
* 筛选宠物
* @param {Object} filterParams 筛选参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const filterPets = (filterParams, config = {}) => {
return uni.$u.http.post('/adoption/pets/filter', filterParams, {
custom: {
auth: false,
loading: true,
...config.custom
},
...config
})
}
/**
* 获取宠物详情
* @param {String|Number} petId 宠物ID
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getAdoptionPetDetail = (petId, config = {}) => {
return uni.$u.http.get(`/adoption/pets/${petId}`, {
custom: {
auth: false,
loading: true,
...config.custom
},
...config
})
}
/**
* 申请领养
* @param {Object} adoptionData 领养申请数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const applyAdoption = (adoptionData, config = {}) => {
return uni.$u.http.post('/adoption/apply', adoptionData, {
custom: {
auth: true,
loading: true,
loadingText: '正在提交申请...',
...config.custom
},
...config
})
}
/**
* 获取我的领养申请
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getMyAdoptionApplications = (params = {}, config = {}) => {
return uni.$u.http.get('/adoption/my-applications', {
params,
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
/**
* 取消领养申请
* @param {String|Number} applicationId 申请ID
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const cancelAdoptionApplication = (applicationId, config = {}) => {
return uni.$u.http.delete(`/adoption/applications/${applicationId}`, {}, {
custom: {
auth: true,
loading: true,
loadingText: '正在取消申请...',
...config.custom
},
...config
})
}
/**
* 获取领养机构列表
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getAdoptionOrganizations = (params = {}, config = {}) => {
return uni.$u.http.get('/adoption/organizations', {
params,
custom: {
auth: false,
loading: true,
...config.custom
},
...config
})
}
/**
* 获取领养机构详情
* @param {String|Number} orgId 机构ID
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getOrganizationDetail = (orgId, config = {}) => {
return uni.$u.http.get(`/adoption/organizations/${orgId}`, {
custom: {
auth: false,
loading: true,
...config.custom
},
...config
})
}
/**
* 收藏宠物
* @param {String|Number} petId 宠物ID
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const favoritePet = (petId, config = {}) => {
return uni.$u.http.post(`/adoption/pets/${petId}/favorite`, {}, {
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
/**
* 取消收藏宠物
* @param {String|Number} petId 宠物ID
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const unfavoritePet = (petId, config = {}) => {
return uni.$u.http.delete(`/adoption/pets/${petId}/favorite`, {}, {
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
/**
* 获取收藏的宠物列表
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getFavoritePets = (params = {}, config = {}) => {
return uni.$u.http.get('/adoption/favorites', {
params,
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
+112
View File
@@ -0,0 +1,112 @@
// AI助手相关API接口
// 注意:所有接口的鉴权配置已在 http/config/config.js 中统一管理
/**
* 发送消息给AI助手
* @param {Object} messageData 消息数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const sendMessage = (messageData, config = {}) => {
return uni.$u.http.post('/ai/chat', messageData, {
custom: {
auth: true,
loading: true,
loadingText: 'AI正在思考中...',
...config.custom
},
...config
})
}
/**
* 获取AI知识库
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getKnowledgeBase = (params = {}, config = {}) => {
return uni.$u.http.get('/ai/knowledge', {
params,
custom: {
auth: false,
loading: true,
...config.custom
},
...config
})
}
/**
* 获取聊天历史
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getChatHistory = (params = {}, config = {}) => {
return uni.$u.http.get('/ai/chat/history', {
params,
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
/**
* 清除聊天历史
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const clearChatHistory = (config = {}) => {
return uni.$u.http.delete('/ai/chat/history', {}, {
custom: {
auth: true,
loading: true,
loadingText: '正在清除历史记录...',
...config.custom
},
...config
})
}
/**
* 获取AI建议
* @param {Object} petData 宠物数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getAISuggestion = (petData, config = {}) => {
return uni.$u.http.post('/ai/suggestion', petData, {
custom: {
auth: true,
loading: true,
loadingText: '正在分析宠物状况...',
...config.custom
},
...config
})
}
/**
* 语音转文字
* @param {Object} audioData 音频数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const speechToText = (audioData, config = {}) => {
return uni.$u.http.upload('/ai/speech-to-text', {
filePath: audioData.filePath,
name: 'audio',
formData: audioData.formData || {},
custom: {
auth: true,
loading: true,
loadingText: '正在识别语音...',
...config.custom
},
...config
})
}
+234
View File
@@ -0,0 +1,234 @@
// 通用API接口
/**
* 上传图片
* @param {Object} imageData 图片数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const uploadImage = (imageData, config = {}) => {
return uni.$u.http.upload('/upload/image', {
filePath: imageData.filePath,
name: imageData.name || 'file',
formData: imageData.formData || {},
custom: {
auth: true,
loading: true,
loadingText: '正在上传图片...',
...config.custom
},
...config
})
}
/**
* 上传多张图片
* @param {Array} imageList 图片列表
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const uploadImages = (imageList, config = {}) => {
const uploadPromises = imageList.map(imageData => {
return uploadImage(imageData, {
...config,
custom: {
loading: false, // 批量上传时不显示单个loading
...config.custom
}
})
})
return Promise.all(uploadPromises)
}
/**
* 上传文件
* @param {Object} fileData 文件数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const uploadFile = (fileData, config = {}) => {
return uni.$u.http.upload('/upload/file', {
filePath: fileData.filePath,
name: fileData.name || 'file',
formData: fileData.formData || {},
custom: {
auth: true,
loading: true,
loadingText: '正在上传文件...',
...config.custom
},
...config
})
}
/**
* 下载文件
* @param {String} url 文件URL
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const downloadFile = (url, config = {}) => {
return uni.$u.http.download(url, {
custom: {
auth: false,
loading: true,
loadingText: '正在下载文件...',
...config.custom
},
...config
})
}
/**
* 获取七牛云上传token
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getQiniuToken = (config = {}) => {
return uni.$u.http.get('/upload/qiniu-token', {
custom: {
auth: true,
loading: false,
...config.custom
},
...config
})
}
/**
* 获取阿里云OSS上传签名
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getOSSSignature = (config = {}) => {
return uni.$u.http.get('/upload/oss-signature', {
custom: {
auth: true,
loading: false,
...config.custom
},
...config
})
}
/**
* 获取系统配置
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getSystemConfig = (config = {}) => {
return uni.$u.http.get('/system/config', {
custom: {
auth: false,
loading: false,
...config.custom
},
...config
})
}
/**
* 获取版本信息
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getVersionInfo = (config = {}) => {
return uni.$u.http.get('/system/version', {
custom: {
auth: false,
loading: false,
...config.custom
},
...config
})
}
/**
* 检查更新
* @param {Object} versionData 版本数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const checkUpdate = (versionData, config = {}) => {
return uni.$u.http.post('/system/check-update', versionData, {
custom: {
auth: false,
loading: true,
...config.custom
},
...config
})
}
/**
* 发送短信验证码
* @param {Object} smsData 短信数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const sendSmsCode = (smsData, config = {}) => {
return uni.$u.http.post('/sms/send', smsData, {
custom: {
auth: false,
loading: true,
loadingText: '正在发送验证码...',
...config.custom
},
...config
})
}
/**
* 验证短信验证码
* @param {Object} verifyData 验证数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const verifySmsCode = (verifyData, config = {}) => {
return uni.$u.http.post('/sms/verify', verifyData, {
custom: {
auth: false,
loading: true,
loadingText: '正在验证...',
...config.custom
},
...config
})
}
/**
* 获取地区数据
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getRegionData = (params = {}, config = {}) => {
return uni.$u.http.get('/common/regions', {
params,
custom: {
auth: false,
loading: false,
...config.custom
},
...config
})
}
/**
* 意见反馈
* @param {Object} feedbackData 反馈数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const submitFeedback = (feedbackData, config = {}) => {
return uni.$u.http.post('/feedback', feedbackData, {
custom: {
auth: true,
loading: true,
loadingText: '正在提交反馈...',
...config.custom
},
...config
})
}
+204
View File
@@ -0,0 +1,204 @@
// 宠物管理相关API接口
// 注意:所有接口的鉴权配置已在 http/config/config.js 中统一管理
/**
* 获取宠物列表
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getPetsList = (params = {}, config = {}) => {
return uni.$u.http.get('/pets', {
params,
custom: {
loading: true,
...config.custom
},
...config
})
}
/**
* 获取宠物详情
* @param {String|Number} petId 宠物ID
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getPetDetail = (petId, config = {}) => {
return uni.$u.http.get(`/pets/${petId}`, {
custom: {
loading: true,
...config.custom
},
...config
})
}
/**
* 添加宠物
* @param {Object} petData 宠物数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const addPet = (petData, config = {}) => {
return uni.$u.http.post('/pets', petData, {
custom: {
loading: true,
loadingText: '正在添加宠物...',
...config.custom
},
...config
})
}
/**
* 更新宠物信息
* @param {String|Number} petId 宠物ID
* @param {Object} petData 宠物数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const updatePet = (petId, petData, config = {}) => {
return uni.$u.http.put(`/pets/${petId}`, petData, {
custom: {
auth: true,
loading: true,
loadingText: '正在更新宠物信息...',
...config.custom
},
...config
})
}
/**
* 删除宠物
* @param {String|Number} petId 宠物ID
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const deletePet = (petId, config = {}) => {
return uni.$u.http.delete(`/pets/${petId}`, {}, {
custom: {
auth: true,
loading: true,
loadingText: '正在删除宠物...',
...config.custom
},
...config
})
}
/**
* 获取宠物记录列表
* @param {String|Number} petId 宠物ID
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getPetRecords = (petId, params = {}, config = {}) => {
return uni.$u.http.get(`/pets/${petId}/records`, {
params,
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
/**
* 添加宠物记录
* @param {String|Number} petId 宠物ID
* @param {Object} recordData 记录数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const addPetRecord = (petId, recordData, config = {}) => {
return uni.$u.http.post(`/pets/${petId}/records`, recordData, {
custom: {
auth: true,
loading: true,
loadingText: '正在添加记录...',
...config.custom
},
...config
})
}
/**
* 更新宠物记录
* @param {String|Number} petId 宠物ID
* @param {String|Number} recordId 记录ID
* @param {Object} recordData 记录数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const updatePetRecord = (petId, recordId, recordData, config = {}) => {
return uni.$u.http.put(`/pets/${petId}/records/${recordId}`, recordData, {
custom: {
auth: true,
loading: true,
loadingText: '正在更新记录...',
...config.custom
},
...config
})
}
/**
* 删除宠物记录
* @param {String|Number} petId 宠物ID
* @param {String|Number} recordId 记录ID
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const deletePetRecord = (petId, recordId, config = {}) => {
return uni.$u.http.delete(`/pets/${petId}/records/${recordId}`, {}, {
custom: {
auth: true,
loading: true,
loadingText: '正在删除记录...',
...config.custom
},
...config
})
}
/**
* 获取宠物健康数据
* @param {String|Number} petId 宠物ID
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getPetHealthData = (petId, params = {}, config = {}) => {
return uni.$u.http.get(`/pets/${petId}/health`, {
params,
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
/**
* 获取宠物时间线
* @param {String|Number} petId 宠物ID
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getPetTimeline = (petId, params = {}, config = {}) => {
return uni.$u.http.get(`/pets/${petId}/timeline`, {
params,
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
+227
View File
@@ -0,0 +1,227 @@
// 个人中心相关API接口
/**
* 获取用户信息
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getUserInfo = (config = {}) => {
return uni.$u.http.get('/user/info', {
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
/**
* 更新用户信息
* @param {Object} userInfo 用户信息
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const updateUserInfo = (userInfo, config = {}) => {
return uni.$u.http.put('/user/info', userInfo, {
custom: {
auth: true,
loading: true,
loadingText: '正在更新用户信息...',
...config.custom
},
...config
})
}
/**
* 获取用户宠物列表
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getUserPets = (params = {}, config = {}) => {
return uni.$u.http.get('/user/pets', {
params,
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
/**
* 用户登录
* @param {Object} loginData 登录数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const userLogin = (loginData, config = {}) => {
return uni.$u.http.post('/auth/login', loginData, {
custom: {
auth: false,
loading: true,
loadingText: '正在登录...',
...config.custom
},
...config
})
}
/**
* 微信登录
* @param {Object} wxData 微信登录数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const wxLogin = (wxData, config = {}) => {
return uni.$u.http.post('/auth/wx-login', wxData, {
custom: {
auth: false,
loading: true,
loadingText: '正在登录...',
...config.custom
},
...config
})
}
/**
* 用户注册
* @param {Object} registerData 注册数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const userRegister = (registerData, config = {}) => {
return uni.$u.http.post('/auth/register', registerData, {
custom: {
auth: false,
loading: true,
loadingText: '正在注册...',
...config.custom
},
...config
})
}
/**
* 用户登出
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const userLogout = (config = {}) => {
return uni.$u.http.post('/auth/logout', {}, {
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
/**
* 刷新token
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const refreshToken = (config = {}) => {
const refreshToken = uni.getStorageSync('refreshToken')
return uni.$u.http.post('/auth/refresh', { refreshToken }, {
custom: {
auth: false,
loading: false,
toast: false,
...config.custom
},
...config
})
}
/**
* 修改密码
* @param {Object} passwordData 密码数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const changePassword = (passwordData, config = {}) => {
return uni.$u.http.put('/user/password', passwordData, {
custom: {
auth: true,
loading: true,
loadingText: '正在修改密码...',
...config.custom
},
...config
})
}
/**
* 获取用户统计数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getUserStats = (config = {}) => {
return uni.$u.http.get('/user/stats', {
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
/**
* 获取用户设置
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getUserSettings = (config = {}) => {
return uni.$u.http.get('/user/settings', {
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
/**
* 更新用户设置
* @param {Object} settings 设置数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const updateUserSettings = (settings, config = {}) => {
return uni.$u.http.put('/user/settings', settings, {
custom: {
auth: true,
loading: true,
loadingText: '正在保存设置...',
...config.custom
},
...config
})
}
/**
* 绑定手机号
* @param {Object} phoneData 手机号数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const bindPhone = (phoneData, config = {}) => {
return uni.$u.http.post('/user/bind-phone', phoneData, {
custom: {
auth: true,
loading: true,
loadingText: '正在绑定手机号...',
...config.custom
},
...config
})
}
+202
View File
@@ -0,0 +1,202 @@
// 评价相关API接口
/**
* 获取评价列表
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getReviews = (params = {}, config = {}) => {
return uni.$u.http.get('/reviews', {
params,
custom: {
auth: false,
loading: true,
...config.custom
},
...config
})
}
/**
* 获取特定对象的评价列表
* @param {String} targetType 目标类型 (pet, organization, service)
* @param {String|Number} targetId 目标ID
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getTargetReviews = (targetType, targetId, params = {}, config = {}) => {
return uni.$u.http.get(`/reviews/${targetType}/${targetId}`, {
params,
custom: {
auth: false,
loading: true,
...config.custom
},
...config
})
}
/**
* 添加评价
* @param {Object} reviewData 评价数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const addReview = (reviewData, config = {}) => {
return uni.$u.http.post('/reviews', reviewData, {
custom: {
auth: true,
loading: true,
loadingText: '正在提交评价...',
...config.custom
},
...config
})
}
/**
* 更新评价
* @param {String|Number} reviewId 评价ID
* @param {Object} reviewData 评价数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const updateReview = (reviewId, reviewData, config = {}) => {
return uni.$u.http.put(`/reviews/${reviewId}`, reviewData, {
custom: {
auth: true,
loading: true,
loadingText: '正在更新评价...',
...config.custom
},
...config
})
}
/**
* 删除评价
* @param {String|Number} reviewId 评价ID
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const deleteReview = (reviewId, config = {}) => {
return uni.$u.http.delete(`/reviews/${reviewId}`, {}, {
custom: {
auth: true,
loading: true,
loadingText: '正在删除评价...',
...config.custom
},
...config
})
}
/**
* 获取我的评价列表
* @param {Object} params 查询参数
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getMyReviews = (params = {}, config = {}) => {
return uni.$u.http.get('/reviews/my', {
params,
custom: {
auth: true,
loading: true,
...config.custom
},
...config
})
}
/**
* 点赞评价
* @param {String|Number} reviewId 评价ID
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const likeReview = (reviewId, config = {}) => {
return uni.$u.http.post(`/reviews/${reviewId}/like`, {}, {
custom: {
auth: true,
loading: false,
...config.custom
},
...config
})
}
/**
* 取消点赞评价
* @param {String|Number} reviewId 评价ID
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const unlikeReview = (reviewId, config = {}) => {
return uni.$u.http.delete(`/reviews/${reviewId}/like`, {}, {
custom: {
auth: true,
loading: false,
...config.custom
},
...config
})
}
/**
* 举报评价
* @param {String|Number} reviewId 评价ID
* @param {Object} reportData 举报数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const reportReview = (reviewId, reportData, config = {}) => {
return uni.$u.http.post(`/reviews/${reviewId}/report`, reportData, {
custom: {
auth: true,
loading: true,
loadingText: '正在提交举报...',
...config.custom
},
...config
})
}
/**
* 回复评价
* @param {String|Number} reviewId 评价ID
* @param {Object} replyData 回复数据
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const replyReview = (reviewId, replyData, config = {}) => {
return uni.$u.http.post(`/reviews/${reviewId}/reply`, replyData, {
custom: {
auth: true,
loading: true,
loadingText: '正在回复评价...',
...config.custom
},
...config
})
}
/**
* 获取评价统计
* @param {String} targetType 目标类型
* @param {String|Number} targetId 目标ID
* @param {Object} config 自定义配置
* @returns {Promise}
*/
export const getReviewStats = (targetType, targetId, config = {}) => {
return uni.$u.http.get(`/reviews/${targetType}/${targetId}/stats`, {
custom: {
auth: false,
loading: true,
...config.custom
},
...config
})
}