106 lines
2.2 KiB
TypeScript
106 lines
2.2 KiB
TypeScript
// 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
|
||
})
|
||
}
|
||
}
|