diff --git a/src/apis/catalogResource.js b/src/apis/catalogResource.js index 295e111..a11eab9 100644 --- a/src/apis/catalogResource.js +++ b/src/apis/catalogResource.js @@ -1,7 +1,7 @@ -import httpInstance from '@/utils/http' +import request from '@/utils/http' export const getResourceCatalogList = (params = {}) => { - return httpInstance({ + return request({ url: '/portal/resource/catalog/pageList', params }) @@ -9,27 +9,27 @@ export const getResourceCatalogList = (params = {}) => { export const getResourceList = (params = {}) => { - return httpInstance({ + return request({ url: '/portal/resource/list', params }) } export const getTreeList = (params = {}) => { - return httpInstance({ + return request({ url: '/portal/resource/catalog/tree', params }) } export const getResourceInfo = (id) => { - return httpInstance({ + return request({ url: `/portal/resource/${id}`, }) } export function resourcePreview(id) { - return httpInstance({ + return request({ url: `/portal/resource/preview/${id}`, method: 'post', // responseType: 'blob' @@ -37,7 +37,7 @@ export function resourcePreview(id) { } export function resourcePreviewTxt(id) { - return httpInstance({ + return request({ url: `/portal/resource/preview/${id}`, method: 'post', responseType: 'blob', diff --git a/src/apis/category.js b/src/apis/category.js deleted file mode 100644 index b5bf637..0000000 --- a/src/apis/category.js +++ /dev/null @@ -1,44 +0,0 @@ -import request from '@/utils/http' - - -export function getCategoryAPI (id) { - return request({ - url: '/category', - params: { - id - } - }) -} - -/** - * @description: 获取二级分类列表数据 - * @param {*} id 分类id - * @return {*} - */ - -export const getCategoryFilterAPI = (id) => { - return request({ - url: '/category/sub/filter', - params: { - id - } - }) -} - -/** - * @description: 获取导航数据 - * @data { - categoryId: 1005000 , - page: 1, - pageSize: 20, - sortField: 'publishTime' | 'orderNum' | 'evaluateNum' - } - * @return {*} - */ -export const getSubCategoryAPI = (data) => { - return request({ - url: '/category/goods/temporary', - method: 'POST', - data - }) -} \ No newline at end of file diff --git a/src/apis/home.js b/src/apis/home.js index b2d792c..e6ee082 100644 --- a/src/apis/home.js +++ b/src/apis/home.js @@ -1,9 +1,8 @@ -import httpInstance from '@/utils/http' - +import request from '@/utils/http' // 查询门户Banner列表 export function getBannerAPI(params = {}) { - return httpInstance({ + return request({ url: '/portal/banner/list', params }) @@ -13,14 +12,14 @@ export function getBannerAPI(params = {}) { * 查询学校动态列表 */ export const getTrendAPI = (params = {}) => { - return httpInstance({ + return request({ url: '/portal/trend/list', params }) } export const getTrendInfoAPI = (trendId) => { - return httpInstance({ + return request({ url: `/portal/trend/${trendId}` }) } @@ -29,7 +28,7 @@ export const getTrendInfoAPI = (trendId) => { *查询学校名师列表 */ export const getShowAPI = (params = {}) => { - return httpInstance({ + return request({ url: '/portal/show/list', params }) @@ -39,28 +38,33 @@ export const getShowAPI = (params = {}) => { *查询目录-同步教材 */ export const getTextbookAPI = () => { - return httpInstance({ + return request({ url: '/portal/textbook/catalog/tree' }) } // 查询目录-专题资源 export const getResourceAPI = (params = {}) => { - return httpInstance({ + return request({ url: '/portal/resource/catalog/pageList', params }) } - export const getAuthAPI = () => { - return httpInstance({ + return request({ url: '/auth/tenant/list' }) } export const getShowInfoAPI = (showId) => { - return httpInstance({ + return request({ url: `/portal/show/${showId}` }) +} + +export const getUploadNum = (showId) => { + return request({ + url: `/statistic/upload/num` + }) } \ No newline at end of file diff --git a/src/apis/layout.js b/src/apis/layout.js deleted file mode 100644 index a42195d..0000000 --- a/src/apis/layout.js +++ /dev/null @@ -1,8 +0,0 @@ - -import httpInstance from "@/utils/http" - -export function getCategoryAPI () { - return httpInstance({ - url: '/home/category/head' - }) -} \ No newline at end of file diff --git a/src/apis/testAPI.js b/src/apis/testAPI.js index 3a60c09..94735ea 100644 --- a/src/apis/testAPI.js +++ b/src/apis/testAPI.js @@ -1,8 +1,8 @@ -import httpInstance from "@/utils/http" +import request from "@/utils/http" export function getCategory () { - return httpInstance({ + return request({ url: 'home/category/head' }) } \ No newline at end of file diff --git a/src/apis/textbook.js b/src/apis/textbook.js index efaebcd..1d827c0 100644 --- a/src/apis/textbook.js +++ b/src/apis/textbook.js @@ -1,36 +1,36 @@ -import httpInstance from '@/utils/http' +import request from '@/utils/http' /** *查询目录-同步教材 */ export const getTextbookAPI = () => { - return httpInstance({ + return request({ url: '/portal/textbook/catalog/list' }) } export const getTextbookTreeAPI = (params = {}) => { - return httpInstance({ + return request({ url: '/portal/textbook/catalog/tree', params }) } export const getTextbookList = (params = {}) => { - return httpInstance({ + return request({ url: '/portal/textbook/list', params }) } export const getTextbookInfoAPI = (id) => { - return httpInstance({ + return request({ url: `/portal/textbook/${id}` }) } export function textbookPreview(id) { - return httpInstance({ + return request({ url: `/portal/textbook/preview/${id}`, method: 'post', // responseType: 'blob' @@ -38,7 +38,7 @@ export function textbookPreview(id) { } export function textbookPreviewTxt(id) { - return httpInstance({ + return request({ url: `/portal/textbook/preview/${id}`, method: 'post', responseType: 'blob', diff --git a/src/apis/user.js b/src/apis/user.js index 89cf512..09eab51 100644 --- a/src/apis/user.js +++ b/src/apis/user.js @@ -1,23 +1,19 @@ // 封装所有和用户相关的接口函数 import request from '@/utils/http' -export const loginAPI = ({ account, password }) => { +export const loginAPI = (loginBody) => { return request({ - url: '/login', + url: '/auth/passwordLogin', method: 'POST', - data: { - account, - password - } + headers: { + isToken: false, + isEncrypt: false + }, + data: loginBody }) } - - -export const getLikeListAPI = ({ limit = 4 }) => { +export const userInfoAPI = () => { return request({ - url: '/goods/relevant', - params: { - limit - } + url: '/system/user/getInfo' }) } \ No newline at end of file diff --git a/src/assets/images/doc.png b/src/assets/images/doc.png new file mode 100644 index 0000000..4d7e8bf Binary files /dev/null and b/src/assets/images/doc.png differ diff --git a/src/assets/images/home-video.png b/src/assets/images/home-video.png new file mode 100644 index 0000000..139bb02 Binary files /dev/null and b/src/assets/images/home-video.png differ diff --git a/src/assets/images/other.png b/src/assets/images/other.png new file mode 100644 index 0000000..8786b0b Binary files /dev/null and b/src/assets/images/other.png differ diff --git a/src/assets/images/picture.png b/src/assets/images/picture.png new file mode 100644 index 0000000..b9a2b5a Binary files /dev/null and b/src/assets/images/picture.png differ diff --git a/src/components/MyFooter/index.vue b/src/components/MyFooter/index.vue new file mode 100644 index 0000000..14a5afc --- /dev/null +++ b/src/components/MyFooter/index.vue @@ -0,0 +1,85 @@ + + + \ No newline at end of file diff --git a/src/components/MyHeader/index.vue b/src/components/MyHeader/index.vue new file mode 100644 index 0000000..399b967 --- /dev/null +++ b/src/components/MyHeader/index.vue @@ -0,0 +1,159 @@ + + + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index 83cc477..cc81b27 100644 --- a/src/main.js +++ b/src/main.js @@ -4,6 +4,10 @@ import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' import App from './App.vue' import router from './router' +//引入Elmessage和Elloading的css样式文件 +import 'element-plus/theme-chalk/el-loading.css' +import 'element-plus/theme-chalk/el-message.css' + // 引入初始化样式文件 import '@/styles/common.scss' diff --git a/src/router/index.js b/src/router/index.js index 2f4f00f..08977bd 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -5,7 +5,7 @@ import { createRouter, createWebHashHistory } from 'vue-router' import Layout from '@/views/Layout/index.vue' import Home from '@/views/Home/index.vue' -import { useTenantStore } from '@/stores/tenantStore' +import { useUserStore } from '@/stores/userStore' const router = createRouter({ history: createWebHashHistory(import.meta.env.BASE_URL), @@ -15,6 +15,22 @@ const router = createRouter({ path: '/login', component: () => import('@/views/Login/index.vue') }, + { + path: '/myUpload', + component: () => import('@/views/MyUpload/index.vue') + }, + { + path: '/myLike', + component: () => import('@/views/MyLike/index.vue') + }, + { + path: '/myCollect', + component: () => import('@/views/MyCollect/index.vue') + }, + { + path: '/myRecord', + component: () => import('@/views/MyRecord/index.vue') + }, { path: '/', component: Layout, @@ -75,9 +91,13 @@ const router = createRouter({ }) router.beforeEach((to, from) => { - useTenantStore().getTenantInfo() + const store = useUserStore() + const whiteList = ['/login'] + + if (!store.token && !whiteList.includes(to.path)) { + return '/login' + } - return true }) export default router diff --git a/src/stores/tenantStore.js b/src/stores/tenantStore.js index 1b2d5a9..4578c47 100644 --- a/src/stores/tenantStore.js +++ b/src/stores/tenantStore.js @@ -5,7 +5,7 @@ import { getAuthAPI } from '@/apis/home' export const useTenantStore = defineStore('tenant', () => { const tenantInfo = ref({}) - const getTenantInfo = async () => { + const setTenantInfo = async () => { const res = await getAuthAPI() if (res.data.voList.length > 0) { tenantInfo.value = res.data.voList[0] @@ -18,7 +18,7 @@ export const useTenantStore = defineStore('tenant', () => { return { tenantInfo, - getTenantInfo, + setTenantInfo, clearTenantInfo } }, { diff --git a/src/stores/userStore.js b/src/stores/userStore.js index 498dc1a..e0bccdf 100644 --- a/src/stores/userStore.js +++ b/src/stores/userStore.js @@ -1,40 +1,43 @@ // 管理用户数据相关 - import { defineStore } from 'pinia' import { ref } from 'vue' -import { loginAPI } from '@/apis/user' -import { useCartStore } from './cartStore' -import { mergeCartAPI } from '@/apis/cart' +import { loginAPI, userInfoAPI } from '@/apis/user' + export const useUserStore = defineStore('user', () => { - const cartStore = useCartStore() - // 1. 定义管理用户数据的state + const token = ref('') const userInfo = ref({}) - // 2. 定义获取接口数据的action函数 - const getUserInfo = async ({ account, password }) => { - const res = await loginAPI({ account, password }) - userInfo.value = res.result - // 合并购物车的操作 - await mergeCartAPI(cartStore.cartList.map(item => { - return { - skuId: item.skuId, - selected: item.selected, - count: item.count - } - })) - cartStore.updateNewList() + + const setToken = async (loginData) => { + const res = await loginAPI(loginData) + token.value = res.data.access_token + } + + const cleartoken = () => { + token.value = '' + } + + const setUserInfo = async () => { + const res = await userInfoAPI() + userInfo.value = res.data } - // 退出时清除用户信息 const clearUserInfo = () => { userInfo.value = {} - // 执行清除购物车的action - cartStore.clearCart() } - // 3. 以对象的格式把state和action return + + const logout = () => { + token.value = '' + userInfo.value = {} + } + return { + token, userInfo, - getUserInfo, - clearUserInfo + setToken, + cleartoken, + setUserInfo, + clearUserInfo, + logout } }, { persist: true, diff --git a/src/utils/http.js b/src/utils/http.js index 79e3bfb..0ff32ec 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -3,19 +3,22 @@ import axios from 'axios' import { ElMessage } from 'element-plus' import { useUserStore } from '@/stores/userStore' import { useTenantStore } from '@/stores/tenantStore' +import router from '@/router' -const httpInstance = axios.create({ +const request = axios.create({ baseURL: '/api-school', timeout: 50000 }) // 拦截器 // axios请求拦截器 -httpInstance.interceptors.request.use(config => { +request.interceptors.request.use(config => { + config.headers.clientId = 'e5cd7e4891bf95d1d19206ce24a7b32e' + // 1. 从pinia获取token数据 const userStore = useUserStore() // 2. 按照后端的要求拼接token数据 - const token = userStore.userInfo.token + const token = userStore.token if (token) { config.headers.Authorization = `Bearer ${token}` } @@ -30,14 +33,35 @@ httpInstance.interceptors.request.use(config => { }, e => Promise.reject(e)) // axios响应式拦截器 -httpInstance.interceptors.response.use(res => res.data, e => { - // 统一错误提示 - ElMessage({ - type: 'warning', - message: e.response.data.message - }) +request.interceptors.response.use(res => { + if (res.data.code === 401) { + // 清除用户信息 + const userStore = useUserStore() + userStore.logout() + router.push('/login') + } + // 业务逻辑失败 + if (res.data.code !== 200) { + ElMessage.error(res.data.msg) + return Promise.reject(res.data) + } + // 业务逻辑成功 + return res.data +}, e => { + if (e.response.status === 401) { + // 清除用户信息 + const userStore = useUserStore() + userStore.logout() + router.push('/login') + } else { + // 统一错误提示 + ElMessage({ + type: 'warning', + message: e.response.data.msg + }) + } return Promise.reject(e) }) -export default httpInstance +export default request diff --git a/src/views/Home/index.vue b/src/views/Home/index.vue index 28f7bec..39cb5d3 100644 --- a/src/views/Home/index.vue +++ b/src/views/Home/index.vue @@ -1,65 +1,66 @@ - \ No newline at end of file diff --git a/src/views/Layout/index.vue b/src/views/Layout/index.vue index 60b317a..a3e6121 100644 --- a/src/views/Layout/index.vue +++ b/src/views/Layout/index.vue @@ -1,16 +1,6 @@ \ No newline at end of file diff --git a/src/views/MyLike/index.vue b/src/views/MyLike/index.vue new file mode 100644 index 0000000..a773a61 --- /dev/null +++ b/src/views/MyLike/index.vue @@ -0,0 +1,119 @@ + + + + + \ No newline at end of file diff --git a/src/views/MyRecord/index.vue b/src/views/MyRecord/index.vue new file mode 100644 index 0000000..4efb93a --- /dev/null +++ b/src/views/MyRecord/index.vue @@ -0,0 +1,161 @@ + + + + + \ No newline at end of file diff --git a/src/views/MyUpload/index.vue b/src/views/MyUpload/index.vue new file mode 100644 index 0000000..4efb93a --- /dev/null +++ b/src/views/MyUpload/index.vue @@ -0,0 +1,161 @@ + + + + + \ No newline at end of file diff --git a/src/views/TextBook/index.vue b/src/views/TextBook/index.vue index afc92fd..3dd920e 100644 --- a/src/views/TextBook/index.vue +++ b/src/views/TextBook/index.vue @@ -7,67 +7,70 @@ - - - - - - - + + + + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - @@ -139,8 +142,6 @@ import { View, Search } from '@element-plus/icons-vue' import { getTextbookAPI, getTextbookTreeAPI, getTextbookList } from '@/apis/textbook' import JzSort from '@/components/JzSort/index.vue' -const imgSuffix = ['.jpg', '.png', '.jpeg', '.gif', '.bmp'] - const router = useRouter() const queryParams = ref({ catalogId: undefined, @@ -155,6 +156,8 @@ const queryParams = ref({ const tableData = ref([]) const total = ref(0) +const activeNames = ref(['1']) + const radio2 = ref() const radio3 = ref() const radio4 = ref() @@ -301,7 +304,7 @@ onMounted(() => { } } - .card-filter { + .el-collapse { margin-top: 20px; }