diff --git a/src/views/portal/course/Index.vue b/src/views/portal/course/Index.vue index db7e3a18..3ef918ee 100644 --- a/src/views/portal/course/Index.vue +++ b/src/views/portal/course/Index.vue @@ -212,6 +212,7 @@ import apiOldCourse from "@/api/boe/course.js"; import apiTeacher from "@/api/modules/teacher.js"; import apiUser from "@/api/system/user.js"; import scene from "@/api/modules/scene.js"; +import apiUserGroup from "@/api/modules/usergroup.js"; import interactBar from "@/components/Portal/interactBar.vue"; import courseImage from "@/components/Course/courseImage.vue"; import { courseType, getType, toScore,formatDate } from "@/utils/tools.js"; @@ -235,6 +236,7 @@ export default { data() { return { formatDate, + audiences:[],//当前用户的受众 couretitle: "", toScore, noPageList: true, //判断接口是否还有数据 @@ -317,12 +319,36 @@ export default { if (this.course.keyword != undefined) { this.totalPages = 4; } - this.search(); - this.searchterm(); + this.loadSysTypes(); this.getScoreList(); this.getHotList(); //查询排行榜,页面打开只查询一次 + let localKey="user_"+this.userInfo.sysId+"_gids"; + if(this.audiences.length==0){ + //let hasIds; + let hasIds=sessionStorage.getItem(localKey); + if(hasIds && hasIds.length>0){ + this.audiences=hasIds.split(","); + this.search(); + }else{ + Promise.all([apiOldCourse.audience(this.userInfo.sysId),apiUserGroup.userGroupIds()]).then(rs=>{ + //console.log(rs,'rs'); + let aids=[]; + if(rs[0].status==200){ + aids.push(rs[0].result); + } + if(rs[1].status==200){ + aids.push(rs[1].result); + } + this.audiences=aids; + sessionStorage.setItem(localKey,this.audiences); + this.search(); + }) + } + } + + this.searchterm(); }, beforeDestroy() { window.removeEventListener("scroll", this.handleScroll); @@ -524,6 +550,10 @@ export default { if (this.course.keyword) { apiSearchterm.save({ keyword: this.course.keyword, type: 1 }); } + if(this.audiences.length>0){ + this.course.audiences=this.audiences.join(","); + } + this.isFind = true; this.course.type = this.category; if (this.types.sysTypes == 0 || this.types.sysTypes == null) { @@ -597,6 +627,7 @@ export default { i !== "orderAsc" && i !== "topOrder" && i !== "device" && + i !== "audiences" && courseData[i] !== null && courseData[i] !== undefined ) {