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

@@ -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);