更新:增加“图书首页”功能

This commit is contained in:
2025-11-10 17:38:23 +08:00
parent 577e782cd8
commit e39f47855b
18 changed files with 1634 additions and 430 deletions

105
api/modules/home.ts Normal file
View File

@@ -0,0 +1,105 @@
// api/modules/home.ts
import { createRequestClient } from '../request'
import { SERVICE_MAP } from '../config'
import type {
IMyBooksResponse,
IRecommendBooksResponse,
ILabelListResponse,
IBookListResponse,
IVipInfoResponse,
ISearchResponse
} from '@/types/book'
const client = createRequestClient({ baseURL: SERVICE_MAP.MAIN })
/**
* 首页相关API
*/
export const homeApi = {
/**
* 获取VIP信息
*/
getVipInfo() {
return client.request<IVipInfoResponse>({
url: 'bookAbroad/home/getVipInfo',
method: 'POST',
data: {}
})
},
/**
* 获取我的书单
* @param current 当前页码
* @param limit 每页数量
*/
getMyBooks(current: number, limit: number) {
return client.request<IMyBooksResponse>({
url: 'bookAbroad/home/getMyBooks',
method: 'POST',
data: { current, limit }
})
},
/**
* 获取推荐图书
*/
getRecommendBooks() {
return client.request<IRecommendBooksResponse>({
url: 'bookAbroad/home/getRecommendBooks',
method: 'POST',
data: {}
})
},
/**
* 获取标签列表
* @param type 0: 分类标签, 1: 活动标签
*/
getBookLabelList(type: number) {
return client.request<ILabelListResponse>({
url: 'bookAbroad/home/getBookAbroadLableList',
method: 'POST',
data: { type }
})
},
/**
* 根据父级ID获取子标签列表
* @param pid 父级标签ID
*/
getSubLabelList(pid: number) {
return client.request<ILabelListResponse>({
url: 'bookAbroad/home/getBookAbroadLableListByPid',
method: 'POST',
data: { pid }
})
},
/**
* 根据标签ID获取图书列表
* @param lableId 标签ID注意原接口参数名为 lableId
*/
getBooksByLabel(lableId: number) {
return client.request<IBookListResponse>({
url: 'bookAbroad/home/getAbroadBookListByLable',
method: 'POST',
data: { lableId }
})
},
/**
* 搜索图书
* @param keyword 搜索关键字
*/
searchBooks(data: {
key: string,
page: number,
limit: number,
}) {
return client.request<ISearchResponse>({
url: 'book/shopproduct/selectList',
method: 'POST',
data
})
}
}