This commit is contained in:
zhaofang
2022-07-21 19:08:03 +08:00
parent e220e99408
commit 4f89bc863f
5 changed files with 2614 additions and 237 deletions

View File

@@ -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,

1338
pages/index/index(1).vue Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
<u-toast ref="messager"></u-toast>
<!--页面头部-->
<view class="top" style="padding-top: 6px;">
<view class="top-bar">
<view class="top-bar">
<view style="position: relative" @click="toMessage()" >
<view v-if="msgNum>0" style="position: absolute;top:12px;right: 16px;z-index: 999;">
<u-badge :isDot="true" :offset="[30,30]" type="error"></u-badge>
@@ -83,28 +83,21 @@
</view>
<view class="con-au">
<view v-if="c.type==10 || c.type==20" class="item-author" style="display: flex;">
<!-- <author v-if="c.authorInfo" :showInfo="true" :data="c.authorInfo"></author> -->
<text style="font-size: 28upx; color: #666666;">{{c.teachersName}}</text>
<text style="font-size: 28upx; color: #666666;">{{c.teacher}}</text>
</view>
<view v-else style="font-size: 28upx; color: #666666;padding-top: 10upx;">
<!-- <text>发布时间</text><text>{{c.sysCreateTime}}</text> -->
</view>
<!-- <view v-if="c.score==0" class="stu-f">未评分</view> -->
</view>
<view class="statuy-ren">
<view class="">
<text style="color: #FF8E00;">
{{c.studys}}
{{c.studies}}
</text>
人学习
</view>
<view class="statuy-score">
<text >{{converToScore(c.score)}}</text>
</view>
</view>
</view>
@@ -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('查询文章');

1249
pages/resource/search(1).vue Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -85,14 +85,14 @@
<view class="con-au">
<view v-if="c.type==10 || c.type==20" class="item-author" style="display: flex;">
<!-- <author v-if="c.authorInfo" :showInfo="true" :data="c.authorInfo"></author> -->
<text style="font-size: 28upx; color: #666666;">{{c.teachersName}}</text>
<text style="font-size: 28upx; color: #666666;">{{c.teacher}}</text>
</view>
<view v-else style="font-size: 24upx; color: #666666;padding-top: 10upx;">
<!-- <text>发布时间</text><text>{{c.showTime}}</text> -->
</view>
</view>
<view class="statuy-ren">
<text><text class="statuy-num">{{c.studys}}</text>人学习</text>
<text><text class="statuy-num">{{c.studies}}</text>人学习</text>
<view v-if="c.score" class="stu-f">{{converToScore(c.score)}}</view>
</view>
</view>
@@ -526,112 +526,23 @@
},
async loadCourseData(){
uni.showLoading({title:'加载中...'});
this.course.params.keyword=this.keyword;
//查询课程
let $this=this;
let dataList = [];
this.course.params.keyword=this.keyword;
//查询课程
this.noPageList = false;
let $this=this;
this.noPageList && await apiCoursePortal.pageList(this.course.params).then(rs=>{
setTimeout(function(){ uni.hideLoading();},100);
let dataList = [];
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;
}
await apiCoursePortal.courseSearch(this.course.params).then(rs=>{
setTimeout(function(){ uni.hideLoading();},100);
// this.course.loadStatus='noMore';
// }
if(rs.status==200){
let courseIds=[];
this.course.list.push(...rs.result.list);
this.course.count=rs.result.count;
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,//用于记录时间,
}
}).catch(err=>{
setTimeout(function(){ uni.hideLoading();},100);