// 评价相关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: false, ...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: false, ...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 }) }