Files
taimed-international-app/api/modules/book_home.ts

106 lines
2.2 KiB
TypeScript
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/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: 'bookAbroad/home/searchBook',
method: 'POST',
data
})
}
}