Files
ShaFaFanXin/前端/api/index.uts
2026-01-27 18:06:04 +08:00

127 lines
2.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* API接口统一管理
*/
import { get, post } from '../utils/request.uts'
/**
* 获取轮播图 (临时从配置获取,后续可从后端获取)
*/
export const getBanners = () => {
// 由于后端暂时没有轮播图API先返回固定数据
return Promise.resolve({
code: 0,
message: 'success',
data: [
{
id: '1',
image: '/static/mock/banner1.svg',
title: '专业沙发翻新服务',
link: '/pages/service/index'
},
{
id: '2',
image: '/static/mock/banner2.svg',
title: '十年品质保证',
link: '/pages/about/index'
},
{
id: '3',
image: '/static/mock/banner3.svg',
title: '免费上门评估',
link: '/pages/booking/index'
}
]
})
}
/**
* 获取案例列表
*/
export const getCaseList = (params ?: UTSJSONObject) => {
// 后端使用page和limit参数需要转换
const queryParams = params ? {
page: params['page'] || 1,
limit: params['pageSize'] || params['limit'] || 10,
serviceType: params['category'], // 后端使用serviceType
status: 'published' // 只获取已发布的案例
} : {}
return get('/cases', queryParams as UTSJSONObject)
}
/**
* 获取案例详情
*/
export const getCaseDetail = (id : string) => {
return get(`/cases/${id}`)
}
/**
* 获取热门案例 (临时使用前4条案例)
*/
export const getHotCases = () => {
return get('/cases', { limit: 4, status: 'published' } as UTSJSONObject)
}
/**
* 获取服务流程 (使用服务列表替代)
*/
export const getServiceProcess = () => {
return get('/services')
}
/**
* 获取有效服务列表
*/
export const getActiveServices = () => {
return get('/services/active')
}
/**
* 获取公司信息
*/
export const getCompanyInfo = () => {
return get('/company/info')
}
/**
* 提交预约
*/
export const submitBooking = (data : UTSJSONObject) => {
return post('/booking', data)
}
/**
* 获取用户信息
*/
export const getUserInfo = () => {
return get('/user/info')
}
/**
* 获取用户收藏列表
*/
export const getFavorites = () => {
return get('/user/favorites')
}
/**
* 添加收藏
*/
export const addFavorite = (caseId : string) => {
return post('/user/favorites', { caseId: caseId } as UTSJSONObject)
}
/**
* 取消收藏
*/
export const removeFavorite = (caseId : string) => {
return post('/user/favorites/remove', { caseId: caseId } as UTSJSONObject)
}
/**
* 获取预约记录
*/
export const getBookingList = () => {
return get('/user/bookings')
}