50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
// api/modules/common.ts
|
|
import { mainClient } from '@/api/clients/main'
|
|
import type { IApiResponse } from '@/api/types'
|
|
import type { IAgreement } from '@/types/user'
|
|
import { useUserStore } from '@/stores/user'
|
|
|
|
|
|
|
|
export const commonApi = {
|
|
/**
|
|
* 发送邮箱验证码
|
|
* @param email 邮箱地址
|
|
*/
|
|
sendMailCaptcha: async (email: string) => {
|
|
const res = await mainClient.request<IApiResponse>({
|
|
url: 'common/user/getMailCaptcha',
|
|
method: 'GET',
|
|
data: { email }
|
|
})
|
|
return res.data
|
|
},
|
|
/**
|
|
* 获取协议内容
|
|
* @param id 协议 ID (111: 用户协议, 112: 隐私政策)
|
|
*/
|
|
getAgreement: async (id: number) => {
|
|
const res = await mainClient.request<IApiResponse<IAgreement>>({
|
|
url: 'sys/agreement/getAgreement',
|
|
method: 'POST',
|
|
data: { id }
|
|
})
|
|
return res.agreement
|
|
},
|
|
/**
|
|
* 获取消息列表(新闻播报)
|
|
* @param isBook 是否是图书相关 0-否 1-是
|
|
* @param isMedical 是否是医学相关 0-否 1-是
|
|
* @param isSociology 是否是社会学相关 0-否 1-是
|
|
* @returns 消息列表
|
|
*/
|
|
getMessageList(isBook: number, isMedical: number, isSociology: number) {
|
|
const userStore = useUserStore()
|
|
return mainClient.request<IMessageListResponse>({
|
|
url: userStore.token ? 'common/message/listByPage' : '/visitor/listByPage',
|
|
method: 'POST',
|
|
data: { isBook, isMedical, isSociology }
|
|
})
|
|
}
|
|
}
|