Merge branch 'main' of https://git.nuttyreading.com/zm/taimed-international-app
This commit is contained in:
9
api/clients/index.ts
Normal file
9
api/clients/index.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { skeletonClient } from './skeleton'
|
||||
import { mainClient } from './main'
|
||||
import { paymentClient } from './payment'
|
||||
|
||||
export {
|
||||
skeletonClient,
|
||||
mainClient,
|
||||
paymentClient
|
||||
}
|
||||
@@ -3,5 +3,5 @@ import { createRequestClient } from '../request';
|
||||
import { SERVICE_MAP } from '../config';
|
||||
|
||||
export const mainClient = createRequestClient({
|
||||
baseURL: SERVICE_MAP.MAIN,
|
||||
baseURL: SERVICE_MAP.MAIN
|
||||
});
|
||||
|
||||
8
api/clients/skeleton.ts
Normal file
8
api/clients/skeleton.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// api/clients/main.ts
|
||||
import { createRequestClient } from '../request';
|
||||
import { SERVICE_MAP } from '../config';
|
||||
|
||||
export const skeletonClient = createRequestClient({
|
||||
baseURL: SERVICE_MAP.MAIN,
|
||||
loading: false
|
||||
})
|
||||
@@ -1,6 +1,5 @@
|
||||
// api/modules/book.ts
|
||||
import { createRequestClient } from '../request'
|
||||
import { SERVICE_MAP } from '../config'
|
||||
import { mainClient, skeletonClient } from '@/api/clients'
|
||||
import type { IApiResponse } from '../types'
|
||||
import type {
|
||||
IBook,
|
||||
@@ -13,8 +12,6 @@ import type {
|
||||
} from '@/types/book'
|
||||
import type { IGoods } from '@/types/order'
|
||||
|
||||
const client = createRequestClient({ baseURL: SERVICE_MAP.MAIN })
|
||||
|
||||
/**
|
||||
* 书籍相关API
|
||||
*/
|
||||
@@ -25,7 +22,7 @@ export const bookApi = {
|
||||
* @param limit 每页数量
|
||||
*/
|
||||
getMyBooks(current: number, limit: number) {
|
||||
return client.request<IApiResponse<{ page: IPageData<IBook> }>>({
|
||||
return mainClient.request<IApiResponse<{ page: IPageData<IBook> }>>({
|
||||
url: 'bookAbroad/home/getMyBooks',
|
||||
method: 'POST',
|
||||
data: { current, limit }
|
||||
@@ -37,7 +34,7 @@ export const bookApi = {
|
||||
* @param bookId 书籍ID
|
||||
*/
|
||||
getBookInfo(bookId: number) {
|
||||
return client.request<IApiResponse<{ bookInfo: IBookDetail }>>({
|
||||
return skeletonClient.request<IApiResponse<{ bookInfo: IBookDetail }>>({
|
||||
url: 'bookAbroad/home/getBookInfo',
|
||||
method: 'POST',
|
||||
data: { bookId }
|
||||
@@ -49,7 +46,7 @@ export const bookApi = {
|
||||
* @param bookId 书籍ID
|
||||
*/
|
||||
getBookReadCount(bookId: number) {
|
||||
return client.request<IApiResponse<{
|
||||
return skeletonClient.request<IApiResponse<{
|
||||
readCount: number
|
||||
listenCount: number
|
||||
buyCount: number
|
||||
@@ -65,7 +62,7 @@ export const bookApi = {
|
||||
* @param bookId 书籍ID
|
||||
*/
|
||||
getRecommendBook(bookId: number) {
|
||||
return client.request<IApiResponse<{ bookList: IBook[] }>>({
|
||||
return skeletonClient.request<IApiResponse<{ bookList: IBook[] }>>({
|
||||
url: 'bookAbroad/home/getRecommendBook',
|
||||
method: 'POST',
|
||||
data: { bookId }
|
||||
@@ -79,7 +76,7 @@ export const bookApi = {
|
||||
* @param limit 每页数量
|
||||
*/
|
||||
getBookComments(bookId: number, current: number, limit: number) {
|
||||
return client.request<IApiResponse<{
|
||||
return mainClient.request<IApiResponse<{
|
||||
commentsTree: IComment[]
|
||||
commentsCount: number
|
||||
}>>({
|
||||
@@ -96,7 +93,7 @@ export const bookApi = {
|
||||
* @param pid 父评论ID,默认为0表示顶级评论
|
||||
*/
|
||||
insertComment(bookId: number, content: string, pid: number = 0) {
|
||||
return client.request<IApiResponse>({
|
||||
return mainClient.request<IApiResponse>({
|
||||
url: 'bookAbroad/insertBookAbroadComment',
|
||||
method: 'POST',
|
||||
data: { bookId, content, pid }
|
||||
@@ -108,7 +105,7 @@ export const bookApi = {
|
||||
* @param commentId 评论ID
|
||||
*/
|
||||
likeComment(commentId: number) {
|
||||
return client.request<IApiResponse>({
|
||||
return mainClient.request<IApiResponse>({
|
||||
url: 'bookAbroad/insertBookAbroadCommentLike',
|
||||
method: 'POST',
|
||||
data: { commentId }
|
||||
@@ -120,7 +117,7 @@ export const bookApi = {
|
||||
* @param commentId 评论ID
|
||||
*/
|
||||
unlikeComment(commentId: number) {
|
||||
return client.request<IApiResponse>({
|
||||
return mainClient.request<IApiResponse>({
|
||||
url: 'bookAbroad/delBookAbroadCommentLike',
|
||||
method: 'POST',
|
||||
data: { commentId }
|
||||
@@ -132,7 +129,7 @@ export const bookApi = {
|
||||
* @param commentId 评论ID
|
||||
*/
|
||||
deleteComment(commentId: number) {
|
||||
return client.request<IApiResponse>({
|
||||
return mainClient.request<IApiResponse>({
|
||||
url: 'bookAbroad/delBookAbroadComment',
|
||||
method: 'POST',
|
||||
data: { commentId }
|
||||
@@ -144,7 +141,7 @@ export const bookApi = {
|
||||
* @param bookId 书籍ID
|
||||
*/
|
||||
getBookChapter(data: { bookId: number; language: string }) {
|
||||
return client.request<IApiResponse<{ chapterList: IChapter[] }>>({
|
||||
return mainClient.request<IApiResponse<{ chapterList: IChapter[] }>>({
|
||||
url: 'bookAbroad/home/getBookChapter',
|
||||
method: 'POST',
|
||||
data
|
||||
@@ -156,7 +153,7 @@ export const bookApi = {
|
||||
* @param chapterId 章节ID
|
||||
*/
|
||||
getChapterContent(chapterId: number) {
|
||||
return client.request<IApiResponse<{ contentPage: IChapterContent[] }>>({
|
||||
return mainClient.request<IApiResponse<{ contentPage: IChapterContent[] }>>({
|
||||
url: 'bookAbroad/home/getBookChapterContent',
|
||||
method: 'POST',
|
||||
data: { chapterId }
|
||||
@@ -168,7 +165,7 @@ export const bookApi = {
|
||||
* @param bookId 书籍ID
|
||||
*/
|
||||
getReadProgress(bookId: number) {
|
||||
return client.request<IApiResponse<{ bookReadRate: IReadProgress | null }>>({
|
||||
return mainClient.request<IApiResponse<{ bookReadRate: IReadProgress | null }>>({
|
||||
url: 'bookAbroad/home/getBookReadRate',
|
||||
method: 'POST',
|
||||
data: { bookId }
|
||||
@@ -182,7 +179,7 @@ export const bookApi = {
|
||||
* @param contentId 内容ID
|
||||
*/
|
||||
saveReadProgress(bookId: number, chapterId: number, contentId: number) {
|
||||
return client.request<IApiResponse>({
|
||||
return mainClient.request<IApiResponse>({
|
||||
url: 'bookAbroad/home/insertBookReadRate',
|
||||
method: 'POST',
|
||||
data: { bookId, chapterId, contentId }
|
||||
@@ -196,7 +193,7 @@ export const bookApi = {
|
||||
* @param contentId 内容ID
|
||||
*/
|
||||
getBookLanguages(bookId: number) {
|
||||
return client.request<IApiResponse>({
|
||||
return mainClient.request<IApiResponse>({
|
||||
url: 'bookAbroad/home/getBookLanguage',
|
||||
method: 'POST',
|
||||
data: { bookId }
|
||||
@@ -208,7 +205,7 @@ export const bookApi = {
|
||||
* @param chapterId 章节ID
|
||||
*/
|
||||
getChapterContentListen(chapterId: number) {
|
||||
return client.request<IApiResponse<{ bookChapterContents: any[] }>>({
|
||||
return mainClient.request<IApiResponse<{ bookChapterContents: any[] }>>({
|
||||
url: 'bookAbroad/home/getBookChapterContentListen',
|
||||
method: 'POST',
|
||||
data: { chapterId }
|
||||
@@ -220,7 +217,7 @@ export const bookApi = {
|
||||
* @param bookId 书籍ID
|
||||
*/
|
||||
getBookGoods(bookId: number) {
|
||||
return client.request<IApiResponse<{ goodsList: IGoods[] }>>({
|
||||
return mainClient.request<IApiResponse<{ goodsList: IGoods[] }>>({
|
||||
url: 'bookAbroad/home/getProductListForBook',
|
||||
method: 'POST',
|
||||
data: { bookId }
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// api/modules/home.ts
|
||||
import { createRequestClient } from '../request'
|
||||
import { SERVICE_MAP } from '../config'
|
||||
import { mainClient, skeletonClient } from '@/api/clients'
|
||||
import type {
|
||||
IMyBooksResponse,
|
||||
IRecommendBooksResponse,
|
||||
@@ -10,17 +9,15 @@ import type {
|
||||
ISearchResponse
|
||||
} from '@/types/book'
|
||||
|
||||
const client = createRequestClient({ baseURL: SERVICE_MAP.MAIN })
|
||||
|
||||
/**
|
||||
* 首页相关API
|
||||
*/
|
||||
export const homeApi = {
|
||||
export const bookHomeApi = {
|
||||
/**
|
||||
* 获取VIP信息
|
||||
*/
|
||||
getVipInfo() {
|
||||
return client.request<IVipInfoResponse>({
|
||||
return mainClient.request<IVipInfoResponse>({
|
||||
url: 'bookAbroad/home/getVipInfo',
|
||||
method: 'POST',
|
||||
data: {}
|
||||
@@ -33,7 +30,7 @@ export const homeApi = {
|
||||
* @param limit 每页数量
|
||||
*/
|
||||
getMyBooks(current: number, limit: number) {
|
||||
return client.request<IMyBooksResponse>({
|
||||
return skeletonClient.request<IMyBooksResponse>({
|
||||
url: 'bookAbroad/home/getMyBooks',
|
||||
method: 'POST',
|
||||
data: { current, limit }
|
||||
@@ -44,7 +41,7 @@ export const homeApi = {
|
||||
* 获取推荐图书
|
||||
*/
|
||||
getRecommendBooks() {
|
||||
return client.request<IRecommendBooksResponse>({
|
||||
return skeletonClient.request<IRecommendBooksResponse>({
|
||||
url: 'bookAbroad/home/getRecommendBooks',
|
||||
method: 'POST',
|
||||
data: {}
|
||||
@@ -56,7 +53,7 @@ export const homeApi = {
|
||||
* @param type 0: 分类标签, 1: 活动标签
|
||||
*/
|
||||
getBookLabelList(type: number) {
|
||||
return client.request<ILabelListResponse>({
|
||||
return skeletonClient.request<ILabelListResponse>({
|
||||
url: 'bookAbroad/home/getBookAbroadLableList',
|
||||
method: 'POST',
|
||||
data: { type }
|
||||
@@ -68,7 +65,7 @@ export const homeApi = {
|
||||
* @param pid 父级标签ID
|
||||
*/
|
||||
getSubLabelList(pid: number) {
|
||||
return client.request<ILabelListResponse>({
|
||||
return skeletonClient.request<ILabelListResponse>({
|
||||
url: 'bookAbroad/home/getBookAbroadLableListByPid',
|
||||
method: 'POST',
|
||||
data: { pid }
|
||||
@@ -80,7 +77,7 @@ export const homeApi = {
|
||||
* @param lableId 标签ID(注意:原接口参数名为 lableId)
|
||||
*/
|
||||
getBooksByLabel(lableId: number) {
|
||||
return client.request<IBookListResponse>({
|
||||
return skeletonClient.request<IBookListResponse>({
|
||||
url: 'bookAbroad/home/getAbroadBookListByLable',
|
||||
method: 'POST',
|
||||
data: { lableId }
|
||||
@@ -96,7 +93,7 @@ export const homeApi = {
|
||||
page: number,
|
||||
limit: number,
|
||||
}) {
|
||||
return client.request<ISearchResponse>({
|
||||
return mainClient.request<ISearchResponse>({
|
||||
url: 'bookAbroad/home/searchBook',
|
||||
method: 'POST',
|
||||
data
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// api/modules/course.ts
|
||||
import { createRequestClient } from '../request'
|
||||
import { SERVICE_MAP } from '../config'
|
||||
import { skeletonClient, mainClient } from '@/api/clients/index'
|
||||
import type { IApiResponse } from '../types'
|
||||
import type {
|
||||
ICourseMedicalTreeResponse,
|
||||
ICourseCategoryResponse,
|
||||
IUserLateCourseListResponse,
|
||||
IMarketCourseListResponse,
|
||||
ICourseDetailResponse,
|
||||
@@ -16,10 +15,6 @@ import type { ISearchRequest, ISearchResponse } from '@/types/search'
|
||||
import type { ICommentListResponse, IAddCommentResponse, IComment } from '@/types/comment'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
|
||||
|
||||
const client = createRequestClient({ baseURL: SERVICE_MAP.MAIN })
|
||||
|
||||
/**
|
||||
* 课程相关API
|
||||
*/
|
||||
@@ -29,7 +24,7 @@ export const courseApi = {
|
||||
* @returns 分类数据
|
||||
*/
|
||||
getCourseMedicalTree() {
|
||||
return client.request<ICourseMedicalTreeResponse>({
|
||||
return mainClient.request<ICourseCategoryResponse>({
|
||||
url: 'medical/home/getCourseMedicalTree',
|
||||
method: 'POST',
|
||||
data: {}
|
||||
@@ -41,7 +36,7 @@ export const courseApi = {
|
||||
* @returns 观看记录列表
|
||||
*/
|
||||
getUserLateCourseList() {
|
||||
return client.request<IUserLateCourseListResponse>({
|
||||
return mainClient.request<IUserLateCourseListResponse>({
|
||||
url: 'medical/home/getUserLateCourseList',
|
||||
method: 'POST',
|
||||
data: {}
|
||||
@@ -61,7 +56,7 @@ export const courseApi = {
|
||||
limit: number
|
||||
}) {
|
||||
const userStore = useUserStore()
|
||||
return client.request<IMarketCourseListResponse>({
|
||||
return mainClient.request<IMarketCourseListResponse>({
|
||||
url: userStore.token ? 'medical/home/getMarketCourseList' : 'visitor/getMarketCourseList',
|
||||
method: 'POST',
|
||||
data
|
||||
@@ -74,7 +69,7 @@ export const courseApi = {
|
||||
* @returns 搜索结果
|
||||
*/
|
||||
searchData(data: ISearchRequest) {
|
||||
return client.request<ISearchResponse>({
|
||||
return mainClient.request<ISearchResponse>({
|
||||
url: 'bookAbroad/home/searchCourse',
|
||||
method: 'POST',
|
||||
data
|
||||
@@ -86,7 +81,7 @@ export const courseApi = {
|
||||
* @param id 课程ID
|
||||
*/
|
||||
getCourseDetail(id: number) {
|
||||
return client.request<ICourseDetailResponse>({
|
||||
return skeletonClient.request<ICourseDetailResponse>({
|
||||
url: 'sociology/course/getCourseDetail',
|
||||
method: 'POST',
|
||||
data: { id }
|
||||
@@ -98,7 +93,7 @@ export const courseApi = {
|
||||
* @param id 目录ID
|
||||
*/
|
||||
getCatalogueChapterList(id: number) {
|
||||
return client.request<IChapterListResponse>({
|
||||
return skeletonClient.request<IChapterListResponse>({
|
||||
url: 'sociology/course/getCourseCatalogueChapterList',
|
||||
method: 'POST',
|
||||
data: { id }
|
||||
@@ -110,7 +105,7 @@ export const courseApi = {
|
||||
* @param id 章节ID
|
||||
*/
|
||||
getChapterDetail(id: number) {
|
||||
return client.request<IChapterDetailResponse>({
|
||||
return skeletonClient.request<IChapterDetailResponse>({
|
||||
url: 'sociology/course/getCourseCatalogueChapterDetail',
|
||||
method: 'POST',
|
||||
data: { id, load: false }
|
||||
@@ -122,7 +117,7 @@ export const courseApi = {
|
||||
* @param catalogueId 目录ID
|
||||
*/
|
||||
startStudyForMF(catalogueId: number) {
|
||||
return client.request<IApiResponse>({
|
||||
return mainClient.request<IApiResponse>({
|
||||
url: 'sociology/course/startStudyForMF',
|
||||
method: 'POST',
|
||||
data: { catalogueId }
|
||||
@@ -134,7 +129,7 @@ export const courseApi = {
|
||||
* @param id 目录ID
|
||||
*/
|
||||
getProductListForCourse(id: number) {
|
||||
return client.request<IProductListResponse>({
|
||||
return mainClient.request<IProductListResponse>({
|
||||
url: 'sociology/product/getProductListForCourse',
|
||||
method: 'POST',
|
||||
data: { id }
|
||||
@@ -146,7 +141,7 @@ export const courseApi = {
|
||||
* @param courseCatalogueId 目录ID
|
||||
*/
|
||||
checkRenewPayment(courseCatalogueId: number) {
|
||||
return client.request<IApiResponse<{ canRelearn: boolean }>>({
|
||||
return skeletonClient.request<IApiResponse<{ canRelearn: boolean }>>({
|
||||
url: 'common/courseRelearn/courseCatalogueCanRelearn',
|
||||
method: 'POST',
|
||||
data: { courseCatalogueId }
|
||||
@@ -158,7 +153,7 @@ export const courseApi = {
|
||||
* @param catalogueId 目录ID
|
||||
*/
|
||||
getRenewProductList(catalogueId: number) {
|
||||
return client.request<IProductListResponse>({
|
||||
return mainClient.request<IProductListResponse>({
|
||||
url: 'common/courseRelearn/relearnShopProductList',
|
||||
method: 'POST',
|
||||
data: { catalogueId }
|
||||
@@ -173,7 +168,7 @@ export const courseApi = {
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
getCourseComments(courseId: number, page: number, limit: number, userId: number) {
|
||||
return client.request<ICommentListResponse>({
|
||||
return mainClient.request<ICommentListResponse>({
|
||||
url: 'common/courseGuestbook/getCourseGuestbookList',
|
||||
method: 'POST',
|
||||
data: { courseId, page, limit, userId, chapterId: '' }
|
||||
@@ -194,7 +189,7 @@ export const courseApi = {
|
||||
content: string
|
||||
images: string
|
||||
}) {
|
||||
return client.request<IAddCommentResponse>({
|
||||
return mainClient.request<IAddCommentResponse>({
|
||||
url: 'common/courseGuestbook/addCourseGuestbook',
|
||||
method: 'POST',
|
||||
data
|
||||
@@ -207,7 +202,7 @@ export const courseApi = {
|
||||
* @param guestbookId 留言ID
|
||||
*/
|
||||
likeComment(userId: number, guestbookId: number) {
|
||||
return client.request<IApiResponse>({
|
||||
return mainClient.request<IApiResponse>({
|
||||
url: 'common/courseGuestbook/addCourseGuestbookSupport',
|
||||
method: 'POST',
|
||||
data: { userId, guestbookId }
|
||||
@@ -220,7 +215,7 @@ export const courseApi = {
|
||||
* @param guestbookId 留言ID
|
||||
*/
|
||||
unlikeComment(userId: number, guestbookId: number) {
|
||||
return client.request<IApiResponse>({
|
||||
return mainClient.request<IApiResponse>({
|
||||
url: 'common/courseGuestbook/cancelCourseGuestbookSupport',
|
||||
method: 'POST',
|
||||
data: { userId, guestbookId }
|
||||
@@ -232,7 +227,7 @@ export const courseApi = {
|
||||
* @param courseId 课程ID
|
||||
*/
|
||||
checkCourseVip(courseId: number) {
|
||||
return client.request<IApiResponse<{ userVip: IVipInfo | null }>>({
|
||||
return skeletonClient.request<IApiResponse<{ userVip: IVipInfo | null }>>({
|
||||
url: 'common/userVip/ownCourseCatalogueByVip',
|
||||
method: 'POST',
|
||||
data: { courseId }
|
||||
@@ -244,7 +239,7 @@ export const courseApi = {
|
||||
* @param courseId 课程ID
|
||||
*/
|
||||
getCourseVipModule(courseId: number) {
|
||||
return client.request<IApiResponse<{ list: string[] }>>({
|
||||
return skeletonClient.request<IApiResponse<{ list: string[] }>>({
|
||||
url: 'common/userVip/getCourseVipModule',
|
||||
method: 'POST',
|
||||
data: { courseId }
|
||||
|
||||
@@ -3,8 +3,7 @@ import { createRequestClient } from '../request'
|
||||
import { SERVICE_MAP } from '../config'
|
||||
import type { IApiResponse } from '../types'
|
||||
import type { IVideoCheckResponse } from '@/types/video'
|
||||
|
||||
const client = createRequestClient({ baseURL: SERVICE_MAP.MAIN })
|
||||
import { skeletonClient } from '@/api/clients'
|
||||
|
||||
/**
|
||||
* 视频相关API
|
||||
@@ -18,7 +17,7 @@ export const videoApi = {
|
||||
checkVideo(data: {
|
||||
id: number
|
||||
}) {
|
||||
return client.request<IVideoCheckResponse>({
|
||||
return skeletonClient.request<IVideoCheckResponse>({
|
||||
url: 'sociology/course/checkVideo',
|
||||
method: 'POST',
|
||||
data
|
||||
@@ -34,7 +33,7 @@ export const videoApi = {
|
||||
videoId: number
|
||||
position: number
|
||||
}) {
|
||||
return client.request<IApiResponse>({
|
||||
return skeletonClient.request<IApiResponse>({
|
||||
url: 'sociology/course/saveCoursePosition',
|
||||
method: 'POST',
|
||||
data
|
||||
@@ -51,7 +50,7 @@ export const videoApi = {
|
||||
videoId: number
|
||||
sort: number
|
||||
}) {
|
||||
return client.request<IApiResponse>({
|
||||
return skeletonClient.request<IApiResponse>({
|
||||
url: 'medical/course/addErrorCourse',
|
||||
method: 'POST',
|
||||
data
|
||||
|
||||
1
api/types.d.ts
vendored
1
api/types.d.ts
vendored
@@ -15,6 +15,7 @@ export interface IApiResponse<T = any> {
|
||||
*/
|
||||
export interface IRequestOptions extends UniApp.RequestOptions {
|
||||
// 允许扩展额外字段(例如 FILE 上传专用等)
|
||||
headers?: Record<string, string>;
|
||||
maxSize?: number;
|
||||
files?: Array<{ name: string; uri: string; fileType?: string }>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user