diff --git a/public/images/qualityBg.png b/public/images/qualityBg.png new file mode 100644 index 00000000..650258d4 Binary files /dev/null and b/public/images/qualityBg.png differ diff --git a/src/api/httpAjax.js b/src/api/httpAjax.js new file mode 100644 index 00000000..4f16e263 --- /dev/null +++ b/src/api/httpAjax.js @@ -0,0 +1,208 @@ +import axios from 'axios' +import qs from 'qs' +import {Notification, MessageBox, Message} from 'element-ui' +import store from '@/store' +import {getToken} from '@/utils/token' +import errorCode from '@/utils/errorCode' + +/** + *request请求 axios.request(config) + *requestJson请求 axios.request(config) + *get请求 axios.get(url[, config]) + *post请求 axios.post(url[, data[, config]]) + *postJson请求 axios.post(url[, data[, config]]) + *put请求 axios.put(url[, data[, config]]) + *putJson请求 axios.put(url[, data[, config]]) + *patch请求 axios.patch(url[, data[, config]]) + *patchJson请求 axios.patch(url[, data[, config]]) + *delete请求 axios.delete(url[, config]) + */ + + +// const ReLoginUrl=process.env.VUE_APP_LOGIN_URL; +const TokenName = 'token'; +/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/ +//只是用于发送json对象数据时使用post,put,patch +/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/ +//只是用于发送json对象数据时使用post,put,patch +//用于普通的发送请求 +const formRequest = axios.create({ + //headers:{'Content-Type':'application/x-www-form-urlencoded'}, + // axios中请求配置有baseURL选项,表示请求URL公共部分 + // baseURL: process.env.VUE_APP_CESOURCE_BASE_API, + //超时 + timeout: 10000, +}) +//发送json对象的拦截器 +formRequest.interceptors.request.use(config => { + //是否需要设置 token + const isToken = (config.headers || {}).isToken === false + let curToken = getToken(); + //curToken='eyJ0eXBlIjoidG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC91LmJvZS5jb20iLCJpYXQiOjE2NzIzMTE2MTIsImV4cCI6MTY3MjMxODgxMiwiR2l2ZW5OYW1lIjoiYm9ldSIsInVzZXJJZCI6IjZCMDQ5RkFGLUMzMTQtN0NDRi0wRDI4LTBEMjNGNEM0MjUzMSIsInVJZCI6Ijk2NTM0MjAyNzQ5NzYwNzE2OCIsInBlcm1pc3Npb24iOiIifQ==.a4f41376e994c5fcd3ab537ce17572ef4c633863f87785cf7b6ffa353e2ed51c'; + if (curToken && !isToken) { + config.headers[TokenName] = curToken // 让每个请求携带自定义token 请根据实际情况自行修改 + } + return config +}, error => { + console.log(error) + Promise.reject(error) +}); +formRequest.interceptors.response.use(res => { + //console.log(res); + const code = res.data.status || 200; + if (code === 200) { + return res.data + } else { + if (code === 401) { + // store.dispatch('LogOut').then(() => { + // location.href = this.webBaseUrl + ReLoginUrl; + // }) + console.error('', res.data); + return Promise.reject(new Error('接口返回未登录')) + } else if (code === 403) { + var msg = '当前操作没有权限'; + Message({message: msg, type: 'error'}); + return Promise.reject(new Error(msg)) + } else { + //Message({message: res.data.message, type: 'error'}); + //console.log('err' + res.data.error); + return res.data + } + } + }, + error => { + console.log('err', error) + let {message} = error; + if (message == "Network Error") { + message = "网络异常,请稍后重试"; + } else if (message.includes("timeout")) { + message = "网络异常或接口错误,请求超时"; + } else if (message.includes("Request failed with status code")) { + message = "系统接口" + message.substr(message.length - 3) + "异常"; + } + Message({ + message: message, + type: 'error', + duration: 5 * 1000 + }) + return Promise.reject(error) + } +) + +/** + * request请求,可以自定义参数 + */ +const request = formRequest.request; + +/** + * get请求 ,只有url + */ +const get = function (baseURL, url) { + return request({ + baseURL, + url: url, + method: 'get', + headers: {'Content-Type': 'application/json'} + }) +} + +/** + * post请求 + * @param {Object} url + * @param {Object} postData + */ +const post = function (baseURL, url, postData) { + // if (postData) { + // postData = qs.stringify(postData); + // } + return request({ + baseURL, + url: url, + method: 'post', + data: postData, + headers: {'Content-Type': 'application/json'} + }) +} +//post请求 +const postForm = function (baseURL, url, data) { + return request({ + baseURL, + url, + data, + method: 'post', + headers: {'Content-Type': 'application/x-www-form-urlencoded'} + }); +} +// const postJson=jsonRequest.post; + +const postJson = function (baseURL, url, postData) { + return request({ + baseURL, + url: url, + method: 'post', + data: postData, + headers: {'Content-Type': 'application/json;charset=utf-8'}, + }) +} + +// 导出文件请求定义 +const postJsonToFile = function (baseURL, url, postData) { + return request({ + baseURL, + url: url, + method: 'post', + data: postData, + headers: {'Content-Type': 'application/json;charset=utf-8'}, + responseType: 'blob' + }) +} + +const getJsonToFile = function (baseURL, url, postData) { + return request({ + baseURL, + url: url, + method: 'get', + data: postData, + headers: {'Content-Type': 'application/json;charset=utf-8'}, + responseType: 'blob' + }) +} + +/** + * put请求 + */ +const put = function (baseURL, url, data) { + if (data) { + data = qs.stringify(data); + } + return request({ + baseURL, + url: url, + method: 'put', + data: data, + headers: {'Content-Type': 'application/x-www-form-urlencoded'} + }) +} + +const putJson = function (baseURL, url, data) { + return request({ + baseURL, + url: url, + method: 'put', + data: data, + headers: {'Content-Type': 'application/json;charset=utf-8'}, + }) +} + + +export default { + tokenName: TokenName, + request, + get, + post, + postJson, + postJsonToFile, + put, + putJson, + getJsonToFile +} diff --git a/src/api/phase2/index.js b/src/api/phase2/index.js index 4bc77a58..132ee1d8 100644 --- a/src/api/phase2/index.js +++ b/src/api/phase2/index.js @@ -1,5 +1,7 @@ import ajax from '@/utils/xajax.js' import http from '../unionAjax' +import httpAjax from '../httpAjax' + const baseURL = process.env.VUE_APP_MANAGER_API_PATH; @@ -47,6 +49,18 @@ const articlelist=function (type){ const courselist=function (data){ return ajax.post('/xboe/portal/index/courselist',data); } +// 精品课信息列表 +const qualitylist=function (data){ + return httpAjax.post(baseURL,'/quality/home/qualityItem',data); +} +// 精品课分页查询 +export const qualityPageList=function (data){ + return httpAjax.post(baseURL,'/quality/home/qualityPages',data); +} +// 课程精品课标记时间年份列表 +export const qualityCourseTimeMark=function (){ + return httpAjax.post(baseURL,'/quality/manage/qualityYearList',{}); +} /** * 首页新课程推荐列表 */ @@ -61,5 +75,7 @@ export default { articlelist, courselist, newCases, - getRecommendList + getRecommendList, + qualitylist, + qualityPageList } diff --git a/src/assets/images/course/courseBackground.png b/src/assets/images/course/courseBackground.png new file mode 100644 index 00000000..87766003 Binary files /dev/null and b/src/assets/images/course/courseBackground.png differ diff --git a/src/assets/images/course/courseTag.png b/src/assets/images/course/courseTag.png new file mode 100644 index 00000000..b67ebe9f Binary files /dev/null and b/src/assets/images/course/courseTag.png differ diff --git a/src/assets/images/course/courseTitle.png b/src/assets/images/course/courseTitle.png new file mode 100644 index 00000000..b69cd5f6 Binary files /dev/null and b/src/assets/images/course/courseTitle.png differ diff --git a/src/components/Portal/interactBar.vue b/src/components/Portal/interactBar.vue index a1faad95..c712795e 100644 --- a/src/components/Portal/interactBar.vue +++ b/src/components/Portal/interactBar.vue @@ -44,7 +44,7 @@
- {{ data.favorites? data.favorites:0}} + {{ data.favorites? data.favorites:data.hasCollect?number(data.hasCollect):1}}
@@ -114,6 +114,8 @@ export default { shares:0, praises:0, views:0, + courseId:'', + courseName:'' } } }, @@ -234,7 +236,7 @@ export default { created(){ }, mounted() { - if(this.data && this.data.id && !this.readonly){ + if(this.data && (this.data.id||this.data.courseId) && !this.readonly){ this.checkHas(); } @@ -308,7 +310,7 @@ export default { } let msgPageParams=this.pageParams; if(!msgPageParams){ - msgPageParams=this.data.id; + msgPageParams=this.data.id ?this.data.id: this.data.courseId; } let message={ content, @@ -331,9 +333,9 @@ export default { }) }, checkHas(){ - if(this.type>0 && !this.readonly && this.data.id){ + if(this.type>0 && !this.readonly && (this.data.id||this.data.courseId)){ if(this.favorites){ - apiFavorites.has(this.type,this.data.id).then(rs=>{ + apiFavorites.has(this.type,(this.data.id || this.data.courseId)).then(rs=>{ if(rs.status==200 && rs.result){ this.isFavorite=true; }else{ @@ -506,9 +508,11 @@ export default { return; } //需要判断是否已点赞,已点赞的不再加 + console.log(this.data,'---------------'); + let postData={ objType:this.type, - objId:this.data.id, + objId:this.data.id ?this.data.id: this.data.courseId, title:'', } if(this.loading) { @@ -516,7 +520,7 @@ export default { } this.loading=true; if(this.type==1){ - postData.title=this.data.name; + postData.title=this.data.name?this.data.name:this.data.courseName; }else if(this.type==60){ postData.title=this.data.content; } else if(this.type==5){ @@ -525,7 +529,7 @@ export default { postData.title=this.data.title; } if(this.isFavorite) {// 已经收藏,再次点击取消收藏 - apiFavorites.remove(this.type,this.data.id).then(res=>{ + apiFavorites.remove(this.type,this.data.id ?this.data.id: this.data.courseId).then(res=>{ this.loading=false; if(res.status==200){ this.isFavorite=false; @@ -554,7 +558,7 @@ export default { this.$store.dispatch("unicomFavorites",true) } //if(this.type===2||this.type===4){ - this.messageSave(this.data.id,this.data.title,this.userInfo.name,this.data.sysCreateBy,this.data.sysCreateAid,'收藏了我发布的'); + this.messageSave(this.data.id ?this.data.id: this.data.courseId,this.data.title,this.userInfo.name,this.data.sysCreateBy,this.data.sysCreateAid,'收藏了我发布的'); //} this.$message({message:'已加入收藏',type:'success'}); //this.$emit('addFavorite',res.result);//添加收藏,如果是true代表添加成功,false代表已存在 diff --git a/src/components/PortalHeader.vue b/src/components/PortalHeader.vue index 2f880839..628c84b8 100644 --- a/src/components/PortalHeader.vue +++ b/src/components/PortalHeader.vue @@ -13,9 +13,9 @@
- 课程 + 课程
-
+
案例 @@ -214,6 +214,12 @@ export default { //this.loadPopupConfig(); }, methods: { + handleChangeCourse() { + const paths = ["/course","/qualityCourse"] + // 如果是 课程 和 精品课程, 那么就不再重定向 + const needReload = paths.findIndex(e=> e === this.$route.path) === -1 + if (needReload) this.$router.push({path: paths[0]}) + }, setCurIdentity(iden){ this.$store.dispatch('SetCurIdentity',iden); diff --git a/src/router/index.js b/src/router/index.js index d532a637..f2d9548a 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -2,7 +2,6 @@ import Vue from 'vue' import VueRouter from 'vue-router' /* Layout */ import Layout from '@/layout/index' -import LayoutPortal from '@/layout/portal' import Grateful from '@/views/grateful' Vue.use(VueRouter) @@ -362,7 +361,15 @@ export const constantRoutes = [{ path: '/500', component: (resolve) => require(['@/views/error/500'], resolve), hidden: true + }, + { + path: '/qualityCourse', + hidden: true, + component: (resolve) => require(['@/views/portal/course/qualityCourse'], resolve), + name: 'qualityCourse', + meta: {title: '精品课课程', keepAlive: true, icon: 'dashboard', noCache: true, affix: false}, } + ] const router = new VueRouter({ diff --git a/src/views/Index.vue b/src/views/Index.vue index 255c1dc9..60864947 100644 --- a/src/views/Index.vue +++ b/src/views/Index.vue @@ -153,9 +153,85 @@
+
+ + + + +
+
+ + + + + + + 查看更多>> + +
+ + + + + + +
推荐课程 @@ -1137,6 +1213,9 @@ export default { orderType: 2, list: [], }, + qusisityList: { + list: [], + }, // 推荐课程 recommendedList:{ list: [], @@ -1164,6 +1243,7 @@ export default { }, mounted() { this.getCourseData(1); + this.getEsqusiteList(); this.getRecommendList(); this.getPositive() this.getCaseData(); @@ -1227,6 +1307,10 @@ export default { courseComputedTwoList(){ return this.courseList.list.slice(3) }, + // 精品课展示 + exquisiteList() { + return this.qusisityList.list.slice(0,3) + }, }, methods: { getPositive() { @@ -1421,21 +1505,27 @@ export default { //二期调整,直接改成一个地址 //return this.webBaseUrl + '/course/detail?id=' + item.id; let $this = this; + let cId = ""; + if (item.id) { + cId = item.id; + } else { + cId = item.courseId; + } if (item.type == 10) { //return this.webBaseUrl + "/course/studyindex?id=" + item.id; //console.log("直接进入学习页面"); - this.$router.push("/course/studyindex?id=" + item.id); + this.$router.push("/course/studyindex?id=" + cId); } else if (item.type == 20) { - apiCourseStudy.hasSignup(item.id).then((rs) => { + apiCourseStudy.hasSignup(cId).then((rs) => { if (rs.status == 200) { - //return $this.webBaseUrl + "/course/studyindex?id=" + item.id; - this.$router.push("/course/studyindex?id=" + item.id); + //return $this.webBaseUrl + "/course/studyindex?id=" + cId; + this.$router.push("/course/studyindex?id=" + cId); } else { - //return $this.webBaseUrl + "/course/detail?id=" + item.id; - this.$router.push("/course/detail?id=" + item.id); + //return $this.webBaseUrl + "/course/detail?id=" + cId; + this.$router.push("/course/detail?id=" + cId); } }); - //return $this.webBaseUrl + "/course/detail?id=" + item.id; + //return $this.webBaseUrl + "/course/detail?id=" + cId; } }, orderTypeFilter(val) { @@ -1472,6 +1562,29 @@ export default { } }) }, + //精品课展示 + getEsqusiteList(){ + let course = { + aid: this.userInfo.aid, + } + apiIndex.qualitylist(course).then((res) => { + let courseIds = []; + res.data.result.forEach((item) => { + item.authorInfo = { + aid: "", + name: "", + orgInfo: "", + avatar: "", + code: "", + sex: null, + }; + courseIds.push(item.courseId); + }); + this.loadCouserTeacher(res.data.result, courseIds); + console.log(res.data.result,'--------------------------'); + this.qusisityList.list = res.data.result; + }) + }, getCourseData(pageIndex) { this.isNext = false; let { orderType, num } = this.courseList; @@ -1671,7 +1784,7 @@ export default { let userIds = []; list.forEach((item, index) => { cres.result.some((courseTeahcer) => { - if (courseTeahcer.courseId == item.id) { + if (courseTeahcer.courseId == (item.id||item.courseId)) { if (courseTeahcer.teacherIds) { userIds.push(courseTeahcer.teacherIds[0]); item.authorInfo.aid = courseTeahcer.teacherIds[0]; @@ -2661,6 +2774,7 @@ export default { // padding-bottom: 10px; display: flex; justify-content: space-between; + margin-bottom: 20px; .course-author-left { font-size: 14px; @@ -3009,4 +3123,17 @@ export default { } } } +.courseBg{ + // width: 332px; + // height: 323px; + // background: url("../assets/images/course/courseBackground.png") no-repeat; + // background-size: 100% 100%; /* 或 use 'contain' */ + // background-position: center; + // border: none; + border-radius: 12px; + background: linear-gradient(135deg, #e6f7ff, #f0f8ff, #ffffff); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); + border: 1px solid #d9edf7; + //overflow: hidden; +} diff --git a/src/views/portal/course/qualityCourse.vue b/src/views/portal/course/qualityCourse.vue new file mode 100644 index 00000000..cc4cce45 --- /dev/null +++ b/src/views/portal/course/qualityCourse.vue @@ -0,0 +1,2254 @@ + + + +