diff --git a/src/apis/catalogResource.js b/src/apis/catalogResource.js new file mode 100644 index 0000000..05daccf --- /dev/null +++ b/src/apis/catalogResource.js @@ -0,0 +1,16 @@ +import httpInstance from '@/utils/http' + +export const getResourceCatalogList = (params = {}) => { + return httpInstance({ + url: '/portal/resource/catalog/pageList', + params + }) +} + + +export const getResourceList = (params = {}) => { + return httpInstance({ + url: '/portal/resource/list', + params + }) +} \ No newline at end of file diff --git a/src/apis/home.js b/src/apis/home.js index 0f2884d..aa69e15 100644 --- a/src/apis/home.js +++ b/src/apis/home.js @@ -1,48 +1,47 @@ import httpInstance from '@/utils/http' -// 获取banner - -export function getBannerAPI (params = {}) { - // 默认为1 商品为2 - const { distributionSite = '1' } = params +// 查询门户Banner列表 +export function getBannerAPI(params = {}) { return httpInstance({ - url: '/home/banner', - params: { - distributionSite - } + url: '/portal/banner/list', + params }) } /** - * @description: 获取新鲜好物 - * @param {*} - * @return {*} + * 查询学校动态列表 */ -export const findNewAPI = () => { +export const getTrendAPI = (params = {}) => { return httpInstance({ - url: '/home/new' + url: '/portal/trend/list', + params }) } /** - * @description: 获取人气推荐 - * @param {*} - * @return {*} + *查询学校名师列表 */ -export const getHotAPI = () => { +export const getShowAPI = (params = {}) => { return httpInstance({ - url: '/home/hot' + url: '/portal/show/list', + params }) } /** - * @description: 获取所有商品模块 - * @param {*} - * @return {*} + *查询目录-同步教材 */ -export const getGoodsAPI = () => { +export const getTextbookAPI = () => { return httpInstance({ - url: '/home/goods' + url: '/portal/textbook/catalog/tree' }) -} \ No newline at end of file +} + +// 查询目录-专题资源 +export const getResourceAPI = (params = {}) => { + return httpInstance({ + url: '/portal/resource/catalog/pageList', + params + }) +} diff --git a/src/apis/textbook.js b/src/apis/textbook.js new file mode 100644 index 0000000..5bd86dd --- /dev/null +++ b/src/apis/textbook.js @@ -0,0 +1,24 @@ +import httpInstance from '@/utils/http' + +/** + *查询目录-同步教材 + */ +export const getTextbookAPI = () => { + return httpInstance({ + url: '/portal/textbook/catalog/list' + }) +} + +export const getTextbookTreeAPI = (params = {}) => { + return httpInstance({ + url: '/portal/textbook/catalog/tree', + params + }) +} + +export const getTextbookList = (params = {}) => { + return httpInstance({ + url: '/portal/textbook/list', + params + }) +} \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index 759db19..68e2382 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -45,7 +45,7 @@ const router = createRouter({ component: () => import('@/views/CatalogResource/index.vue') }, { - path: 'subSubject', + path: 'subSubject/:id', component: () => import('@/views/SubCatalogResource/index.vue') }, { diff --git a/src/utils/http.js b/src/utils/http.js index d6f0a5d..d22a776 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -3,8 +3,8 @@ import axios from 'axios' import { ElMessage } from 'element-plus' import { useUserStore } from '@/stores/userStore' const httpInstance = axios.create({ - baseURL: 'http://pcapi-xiaotuxian-front-devtest.itheima.net', - timeout: 5000 + baseURL: '/api', + timeout: 50000 }) // 拦截器 diff --git a/src/utils/utils.js b/src/utils/utils.js new file mode 100644 index 0000000..1fadb67 --- /dev/null +++ b/src/utils/utils.js @@ -0,0 +1,44 @@ +// 日期格式化 +export function parseTime(time, pattern) { + if (arguments.length === 0 || !time) { + return null; + } + const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'; + let date; + if (typeof time === 'object') { + date = time; + } else { + if (typeof time === 'string' && /^[0-9]+$/.test(time)) { + time = parseInt(time); + } else if (typeof time === 'string') { + time = time + .replace(new RegExp(/-/gm), '/') + .replace('T', ' ') + .replace(new RegExp(/\.[\d]{3}/gm), ''); + } + if (typeof time === 'number' && time.toString().length === 10) { + time = time * 1000; + } + date = new Date(time); + } + const formatObj = { + y: date.getFullYear(), + m: date.getMonth() + 1, + d: date.getDate(), + h: date.getHours(), + i: date.getMinutes(), + s: date.getSeconds(), + a: date.getDay() + }; + return format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { + let value = formatObj[key]; + // Note: getDay() returns 0 on Sunday + if (key === 'a') { + return ['日', '一', '二', '三', '四', '五', '六'][value]; + } + if (result.length > 0 && value < 10) { + value = '0' + value; + } + return value || 0; + }); +} \ No newline at end of file diff --git a/src/views/CatalogResource/index.vue b/src/views/CatalogResource/index.vue index d13964d..3399c55 100644 --- a/src/views/CatalogResource/index.vue +++ b/src/views/CatalogResource/index.vue @@ -9,9 +9,6 @@