diff --git a/api/modules/coursePortal.js b/api/modules/coursePortal.js index 56a0e3f..0c0bcfe 100644 --- a/api/modules/coursePortal.js +++ b/api/modules/coursePortal.js @@ -72,8 +72,12 @@ const scorelist=function(num){ const getTeacherByCourseIDs = function(ids){ return ajax.postJson('/xboe/m/course/portal/query-teacher', ids); } +const courseSearch=function(query){ + return ajax.post('/xboe/m/course/fulltext/search',query); +} export default { + courseSearch, list, pageList, detail, diff --git a/pages/index/index(1).vue b/pages/index/index(1).vue new file mode 100644 index 0000000..d39b186 --- /dev/null +++ b/pages/index/index(1).vue @@ -0,0 +1,1338 @@ + + + + diff --git a/pages/index/index.vue b/pages/index/index.vue index 0bd5cd0..1e1382e 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -3,7 +3,7 @@ - + @@ -83,28 +83,21 @@ - - {{c.teachersName}} + {{c.teacher}} - - - - - {{c.studys}} + {{c.studies}} 人学习 - {{converToScore(c.score)}}分 - @@ -480,42 +473,15 @@ scenes:'', type:'' } - let oldPageIndex = 0; - if(this.dataFilter.courseParams.type == undefined && this.dataFilter.courseParams.cateName == undefined) { - oldPageIndex = curData.pageIndex-3; - } - else { - oldPageIndex = curData.pageIndex; - } - let oldParams={type:'',page:oldPageIndex,size:10,cateName:this.dataFilter.courseParams.cateName,sort:''};//老数据的查询条件 - let courseType=this.dataFilter.courseParams.type; + query.type=this.dataFilter.courseParams.type; if(this.tabIndex==0){ query.orderField='id'; - oldParams.sort = 'new'; }else{ query.orderField='studys'; - oldParams.sort = 'hot'; } - if(courseType){ - query.type=courseType; - if(courseType==10){ - oldParams.type='weike'; - }else if(courseType==20){ - oldParams.type='online-course'; - }else if(courseType==30){ - //query.type=courseType; - oldParams.type='face-course'; - }else if(courseType==40){ - //query.type=courseType; - oldParams.type='project'; - }else{ - //oldParams.type=courseType; - } - + if(this.dataFilter.courseParams.scenes){ + query.scenes=this.dataFilter.courseParams.scenes; } - // if(this.dataFilter.courseParams.scenes){ - // query.scenes=this.dataFilter.courseParams.scenes; - // } if(this.dataFilter.courseParams.sysType1){ query.sysType1=this.dataFilter.courseParams.sysType1; } @@ -525,111 +491,20 @@ if(this.dataFilter.courseParams.sysType3){ query.sysType3=this.dataFilter.courseParams.sysType3; } - if(curData.pageIndex > this.totalPages) { - this.noDataList = true; - oldParams.page=curData.pageIndex-this.totalPages; - }else{ - if(this.totalPages<3){ - this.noDataList = false; - } - } - // if(oldParams.page < 1) { - // this.noDataList = false; - // } else { - // this.noDataList = true; - // } + //从新课程库中取10条,从老库中取10条 keyword:this.course.keyword - if(courseType == 30 || courseType == 40) { - this.noPageList = false; - } uni.showLoading({title:'加载中...'}); - if(courseType!=10){ - this.noDataList && await apiBoeCourse.courseList(oldParams).then(res=>{ - setTimeout(function(){ uni.hideLoading() },100); - if(res.status==200 && res.result.dataList.length > 0){ - let list = this.filterConversion(res.result.dataList); - list.forEach(item=>{ - // curData.list.push(item); - data.push(item); - }); - // this.courseList=curData.list; - } else { - this.noDataList = false; - } - }) - } - this.noPageList && await apiCoursePortal.pageList(query).then(res=>{ - setTimeout(function(){ uni.hideLoading() },100); - if(res.status==200 && res.result.list.length>0){ - this.totalPages = res.result.totalPages; - let courseIds=[]; - res.result.list.forEach(item=>{ - item.authorInfo={avatar:'',name:'',code:'',sex:null}; - item.teachersName = ''; - item.teachersId = ''; - // curData.list.push(item); - // data.push(item); - courseIds.push(item.id); - if(item.isTop) { - isTopList.push(item); - } else { - data.push(item); - } - }); - this.loadCouserTeacher(res.result.list,courseIds); - }else{ - this.noPageList = false; - } - }) - if(this.tabIndex==0) {//最新 - // curData.list.sort(this.pcompare("publishTime",false)) - data.sort(this.pcompare("publishTime",false)) - } - if(this.tabIndex==1) {//最热 - // curData.list.sort(this.pcompare("studys",false)) - data.sort(this.pcompare("studys",false)) - } - // curData.list.sort(this.pcompare("sysCreateTime",false)); - curData.list.push(...isTopList,...data); - this.courseList=curData.list; - if(this.noPageList || this.noDataList) { + await apiCoursePortal.courseSearch(query).then(res=>{ + setTimeout(function(){ uni.hideLoading() },100); + if(res.status==200 && res.result.list.length>0){ + curData.list.push(...res.result.list); this.loadStatus='more'; - } else if(!this.noPageList && !this.noDataList) { + }else{ this.loadStatus='noMore'; } + }) + this.courseList=curData.list; }, - pcompare(prop,rev) { - if(rev === undefined) { - rev = 1; - }else { - rev = rev?1:-1; - } - return function(obj1,obj2) { - let val1 = obj1[prop],val2 = obj2[prop]; - return val1 < val2 ? rev*(-1):rev*1; - } - }, - filterConversion(data) { - let list = []; - data.forEach((item,index)=>{ - list.push({ - coverImg: item.cover[0].url, - name: item.title, - type: item.type, - id: item.id, - studys:Number(item.enrollSuccess),//学习人数 - score: item.score, - avatar: '', - code: '', - sex:null, - sysCreateTime:item.releaseDate,//用于记录时间, - sysCreateBy:'', - }) - }) - return list; - }, - - //拿到文章数据列表方法 findArticleData(){ //console.log('查询文章'); diff --git a/pages/resource/search(1).vue b/pages/resource/search(1).vue new file mode 100644 index 0000000..decc77c --- /dev/null +++ b/pages/resource/search(1).vue @@ -0,0 +1,1249 @@ + + + + + diff --git a/pages/resource/search.vue b/pages/resource/search.vue index 8afc2e0..9bbf3a1 100644 --- a/pages/resource/search.vue +++ b/pages/resource/search.vue @@ -85,14 +85,14 @@ - {{c.teachersName}} + {{c.teacher}} - {{c.studys}}人学习 + {{c.studies}}人学习 {{converToScore(c.score)}}分 @@ -526,112 +526,23 @@ //查询课程 let $this=this; let dataList = []; - if(this.course.params.type == 30 || this.course.params.type == 40) { - this.noPageList = false; - } - this.noPageList && await apiCoursePortal.pageList(this.course.params).then(rs=>{ + await apiCoursePortal.courseSearch(this.course.params).then(rs=>{ setTimeout(function(){ uni.hideLoading();},100); - if(rs.status==200){ - - //let userIds=[]; let courseIds=[]; - rs.result.list.forEach(item=>{ - item.name = this.$keywordActiveShow(item.name,this.course.params.keyword); - item.authorInfo={avatar:'',code:'',name:'',sex: null - } - $this.course.list.push(item); - dataList.push(item); - item.teachersName = ''; - item.teachersId = ''; - //userIds.push(item.sysCreateAid) - courseIds.push(item.id); - }) - - if(rs.result.list.length == 0) { - this.noPageList = false; - } - - // if(this.course.params.pageIndex>=rs.result.totalPages){ - // this.course.loadStatus='noMore'; - // } - // this.course.list.push(...dataList); + this.course.list.push(...rs.result.list); this.course.count=rs.result.count; - this.loadCouserTeacher(rs.result.list,courseIds); - //this.loadUserInfos(rs.result.list,userIds); + if(rs.result.list.length == 0) { + this.course.loadStatus='noMore'; + } else { + this.course.loadStatus='more' + } }else{ this.$refs.messager.show({message:rs.message,type:'error'}); } }).catch(err=>{ setTimeout(function(){ uni.hideLoading();},100); }) - //从新课程库中取10条,从老库中取10条 keyword:this.course.keyword - let oldParams={type:'',page:$this.course.params.pageIndex,size:10,keyword:$this.course.params.keyword,cateName:$this.course.params.cateName,sort:''} - if($this.course.params.type==20){ - oldParams.type='online-course'; - }else if($this.course.params.type==30){ - oldParams.type='face-course'; - }else if($this.course.params.type==40){ - oldParams.type='project'; - } - if($this.course.params.orderField == 'id') {//最新 - oldParams.sort = 'new'; - } - if($this.course.params.orderField == 'studys') {//最热 - oldParams.sort = 'hot'; - } - uni.showLoading({title:'加载中...'}); - this.noDataList && await apiBoeCourse.courseList(oldParams).then(res=>{ - setTimeout(function(){ uni.hideLoading() },100); - if(res.status==200){ - if(res.result.dataList.length == 0) { - this.noDataList = false; - } - let list = this.filterConversion(res.result.dataList); - this.course.list.push(...list); - } - }) - if($this.course.params.orderField == 'id') {//最新 - this.course.list.sort(this.pcompare("publishTime",false)) - } - if($this.course.params.orderField == 'studys') {//最热 - this.course.list.sort(this.pcompare("studys",false)) - } - - if(this.noPageList || this.noDataList) { - this.course.loadStatus='more' - } else if(!this.noPageList && !this.noDataList) { - this.course.loadStatus='noMore'; - } - }, - pcompare(prop,rev) { - if(rev === undefined) { - rev = 1; - }else { - rev = rev?1:-1; - } - return function(obj1,obj2) { - let val1 = obj1[prop],val2 = obj2[prop]; - return val1 < val2 ? rev*(-1):rev*1; - } - }, - filterConversion(data) { - let list = []; - data.forEach((item,index)=>{ - list.push({ - coverImg: item.cover[0].url, - name: item.title, - type: item.type, - id: item.id, - studys: Number(item.enrollSuccess),//学习人数 - score: item.score, - avatar: '', - ucode: '', - showTime:item.releaseDate,//用于记录时间, - sysCreateBy:'', - }) - }) - return list; }, loadArticleData(){ uni.showLoading({title:'加载中...'});