diff --git a/api/home/index.ts b/api/home/index.ts index 87b9b56..989faea 100644 --- a/api/home/index.ts +++ b/api/home/index.ts @@ -103,4 +103,11 @@ export const getTDK = () => { */ export const getTDKList = () => { return useFetchRequest.get>('/prod-api/app-api/business/tdk-settings/list-menu', {}) +} + +/** + * 通知列表 + */ +export const getNoticeList = () => { + return useDollarFetchRequest.get>('/prod-api/app-api/system/index-setting/notice-list', {}) } \ No newline at end of file diff --git a/api/upnew/index.ts b/api/upnew/index.ts index d339297..dfc138a 100644 --- a/api/upnew/index.ts +++ b/api/upnew/index.ts @@ -16,7 +16,7 @@ export const create = (params: TcreateReq) => { * @returns */ export const parent = (params: { type: string | number; parentId: number | string }) => { - return useFetchRequest.get>('/prod-api/app-api/business/app/dict/parent', { query: params }) + return useDollarFetchRequest.get>('/prod-api/app-api/business/app/dict/parent', { query: params }) } /** * 获取具有上下级的字典信息 @@ -32,7 +32,7 @@ export const parentV2 = (params: { type: string | number; parentId: number | str * @returns */ export const indexTabs = () => { - return useFetchRequest.get>('/prod-api/app-api/business/project/index/index-tab3') + return useDollarFetchRequest.get>('/prod-api/app-api/business/project/index/index-tab3') } /** * 模糊查询获取标签内容 @@ -73,3 +73,10 @@ export const recommendTop = (params: recommendTopReq) => { export const homeLabel = () => { return useFetchRequest.get>('/prod-api/app-api/business/app/dict/index-tab') } + +/** + * 获取客服微信 + */ +export const getWechat = () => { + return useDollarFetchRequest.get>('/prod-api/app-api/system/index-setting/kefu-wechat') +} diff --git a/api/upnew/types.ts b/api/upnew/types.ts index 9f077b6..8e60383 100644 --- a/api/upnew/types.ts +++ b/api/upnew/types.ts @@ -10,9 +10,9 @@ export interface FileItem { // 定义整个 JSON 对象的类型 export interface TcreateReq { - activeName: string + activeName: string | number id: number | string - type: any[] + type: number isDomestic: number | string province: string // 省份编码 city: string // 城市编码 diff --git a/composables/useDollarFetchRequest.ts b/composables/useDollarFetchRequest.ts index 939b80a..332b289 100644 --- a/composables/useDollarFetchRequest.ts +++ b/composables/useDollarFetchRequest.ts @@ -1,77 +1,56 @@ -import { isArray } from "~/utils/utils"; +import { isArray } from '~/utils/utils' +import useUserStore from '~/stores/user' // import refreshToken from "~/utils/RefreshToken"; -type FetchType = typeof $fetch; -export type FetchOptions = Parameters[1]; +type FetchType = typeof $fetch +export type FetchOptions = Parameters[1] -const useClientRequest = async ( - url: string, - opts?: FetchOptions -) => { - const token = useCookie("token"); - const runtimeConfig = useRuntimeConfig(); +const useClientRequest = async (url: string, opts?: FetchOptions) => { + const token = useCookie('token') + const runtimeConfig = useRuntimeConfig() + const userStore = useUserStore() const defaultOptions: FetchOptions = { baseURL: runtimeConfig.public.apiBase, onRequest({ options }) { - options.headers = options.headers || 'application/json'; - if (token.value) { - options.headers.set("Authorization", `Bearer ${token.value}`); + options.headers = options.headers || 'application/json' + if (token.value || userStore.token) { + options.headers.set('Authorization', `Bearer ${token.value || userStore.token}`) } }, onResponse({ response }) { if (+response.status === 200 && +response._data.code !== 0) { - ElMessage.error(response._data.msg); + ElMessage.error(response._data.msg) } }, onResponseError({ response }) { - ElMessage.error( - isArray(response._data.data.msg) - ? response._data.data.msg[0] - : response._data.data.msg - ); + ElMessage.error(isArray(response._data.data.msg) ? response._data.data.msg[0] : response._data.data.msg) }, - }; - - // 明确转换返回类型 - const response = await $fetch(url, { ...defaultOptions, ...opts }); - return response as unknown as T; -}; - - // GET请求 - export const get = ( - endpoint: string, - config?: Omit - ): Promise => { - return useClientRequest(endpoint, { ...config, method: 'GET' }) - } - // POST请求 - export const post = ( - endpoint: string, - body?: any, - config?: Omit - ): Promise => { - return useClientRequest(endpoint, { ...config, method: 'POST', body }) - } + // 明确转换返回类型 + const response = await $fetch(url, { ...defaultOptions, ...opts }) + return response as unknown as T +} - - // DELETE请求 - export const del = ( - endpoint: string, - config?: Omit - ): Promise => { - return useClientRequest(endpoint, { ...config, method: 'DELETE' }) - } +// GET请求 +export const get = (endpoint: string, config?: Omit): Promise => { + return useClientRequest(endpoint, { ...config, method: 'GET' }) +} - // PUT请求 - export const put = ( - endpoint: string, - body?: any, - config?: Omit - ): Promise => { - console.log({ ...config, method: 'PUT', body }); - - return useClientRequest(endpoint, { ...config, method: 'PUT', body }) - } +// POST请求 +export const post = (endpoint: string, body?: any, config?: Omit): Promise => { + return useClientRequest(endpoint, { ...config, method: 'POST', body }) +} + +// DELETE请求 +export const del = (endpoint: string, config?: Omit): Promise => { + return useClientRequest(endpoint, { ...config, method: 'DELETE' }) +} + +// PUT请求 +export const put = (endpoint: string, body?: any, config?: Omit): Promise => { + console.log({ ...config, method: 'PUT', body }) + + return useClientRequest(endpoint, { ...config, method: 'PUT', body }) +} diff --git a/pages/foreign/index.vue b/pages/foreign/index.vue index 47fc700..ba97ecb 100644 --- a/pages/foreign/index.vue +++ b/pages/foreign/index.vue @@ -35,13 +35,19 @@ import { page } from '~/api/upnew/index' import type { pageRes, pageReq } from '~/api/upnew/types' - const query = reactive({ + const query = reactive< + pageReq & { + isDomestic: number + } + >({ pageNo: 1, pageSize: 10, projectType: '-1', editions: '-1', source: -1, type: 1, + /**是否是国内: 1是 0否 */ + isDomestic: 1, }) // const result = reactive({ // list: [], diff --git a/pages/home/components/MainContent.vue b/pages/home/components/MainContent.vue index b99834e..a8efe0d 100644 --- a/pages/home/components/MainContent.vue +++ b/pages/home/components/MainContent.vue @@ -2,27 +2,19 @@