// 领养专区相关API接口 // 注意:所有接口的鉴权配置已在 http/config/config.js 中统一管理 /** * 获取待领养宠物列表 * @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: false, ...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: false, ...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: false, ...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 }) }