From 4e5681ec25f9c1e4b9e2b5a73319414be79a7393 Mon Sep 17 00:00:00 2001 From: daihh Date: Sat, 12 Nov 2022 17:25:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/interact-fixed/interact-fixed.vue | 38 ++-- components/interact-share/interact-share.vue | 147 ++++++++++++ pages/study/courseStudy.vue | 227 +++++++++++++++++-- 3 files changed, 370 insertions(+), 42 deletions(-) create mode 100644 components/interact-share/interact-share.vue diff --git a/components/interact-fixed/interact-fixed.vue b/components/interact-fixed/interact-fixed.vue index 3281027..84be5c7 100644 --- a/components/interact-fixed/interact-fixed.vue +++ b/components/interact-fixed/interact-fixed.vue @@ -474,25 +474,25 @@ export default { var regPos = /^\d+(\.\d+)?$/; //非负浮点数 if(regPos.test(name)){ apiUser.getByLoginName(name).then(rs=>{ - if(rs.status==200){ - //因为根据工号查询,只会是一个人,所有会有null情况,而json会返回空字符串 - if(rs.result!=''){ - this.shareInfo.users=[rs.result]; - }else{ - uni.showToast({ - title: '查无此用户', - icon: 'none' - }); - // this.$refs.interactToast.show({message:"查无此用户",type:'warning'}); - } - }else{ - uni.showToast({ - title: rs.message, - icon: 'none' - }); - // this.$refs.interactToast.show({message:rs.message,type:'warning'}); - } - }) + if(rs.status==200){ + //因为根据工号查询,只会是一个人,所有会有null情况,而json会返回空字符串 + if(rs.result!=''){ + this.shareInfo.users=[rs.result]; + }else{ + uni.showToast({ + title: '查无此用户', + icon: 'none' + }); + // this.$refs.interactToast.show({message:"查无此用户",type:'warning'}); + } + }else{ + uni.showToast({ + title: rs.message, + icon: 'none' + }); + // this.$refs.interactToast.show({message:rs.message,type:'warning'}); + } + }) }else{ apiUser.findByName(name).then(rs=>{ if(rs.status==200){ diff --git a/components/interact-share/interact-share.vue b/components/interact-share/interact-share.vue new file mode 100644 index 0000000..7363600 --- /dev/null +++ b/components/interact-share/interact-share.vue @@ -0,0 +1,147 @@ + + + + + \ No newline at end of file diff --git a/pages/study/courseStudy.vue b/pages/study/courseStudy.vue index 49c6b27..0eef212 100644 --- a/pages/study/courseStudy.vue +++ b/pages/study/courseStudy.vue @@ -30,7 +30,7 @@ - 讲师:李玉冰(显示事件) + 讲师:李玉冰(显示事业) +关注 @@ -80,18 +80,18 @@ - + 评价 - + - - + + 收藏 - + @@ -102,7 +102,7 @@ - + @@ -147,7 +147,7 @@ - + 课程推荐 @@ -162,12 +162,11 @@ 暂无 - - - + + 给课程打分 @@ -190,6 +189,7 @@ import apiResOwner from '@/api/modules/resowner.js' import apiPraises from "@/api/modules/praises.js"; import apiTrample from "@/api/modules/trample.js"; + import apiFavorites from '@/api/modules/favorites.js' import {getContentType} from "@/utils/tools.js"; import studyUtil from '@/utils/study.js'; import {toScore} from '@/utils/tools.js'; @@ -197,6 +197,7 @@ export default { data(){ return{ + loading:false,//加载中 courseId:'',//当前课程的id studyId: '',//当前学习的id initContentId:'',//初始化的内容id @@ -204,7 +205,14 @@ teachers:[],//课程老师列表 recommendCourses:[],//推荐课程列表 catalogShow:false,//是否显示目录 + catalogNum:1,//一个目录时不显示,两个时显示占满,三个时类似UI一样的显示了 tabIndex:1,//显示的tab内容 + scoreInfo:{dlgShow:false, score:5, has:false},//评分控制项 + isPraise:false,//是否已点赞 + isTrample:false,//是否已踩 + isFavorite:false,//是否已收藏 + isFollow:false,//是否已关注 + isPlaying:false, onplay:false, @@ -236,15 +244,7 @@ speedListShow:false, speedList:["2.0", "1.5", "1.25", "1.0", "0.75", "0.5"], videoSpeed: 1.0, // 当前倍速: - tabIndex:0, - catalogShow:false,//是否显示目录 - scoreInfo:{ - dlgShow:false, - score:5, - has:false, - }, - isPraise:false, - isTrample:false, + interactRuning:false, scrollInfo:{ scrollLeft: 0, @@ -311,8 +311,9 @@ } this.courseId=options.id; this.courseInfo.id=options.id; - this.loadDetail(); - this.loadReCourses(); + this.loadDetail();//加载课程数据 + this.loadReCourses();//加载推荐课程 + this.loadIsData();//加载关注,收藏,评价等信息 }, onShow(){ uni.setNavigationBarTitle({ title:'\u200E' }) @@ -530,6 +531,31 @@ } }) }, + loadIsData(){ + //加载是否关注,是否收藏,是否评价等 + apiFavorites.has(1,this.courseId).then(rs=>{ + if(rs.status==200 && rs.result){ + this.isFavorite=true; + }else{ + this.isFavorite=false; + } + }) + apiCourseGrade.has(this.courseId).then(rs=>{ + if(rs.status==200 && rs.result){ + this.scoreInfo.has=true; + } + }); + apiPraises.has(1,this.courseId).then(rs=>{ + if(rs.status==200 && rs.result){ + this.isPraise=true; + } + }); + apiTrample.has(this.courseId).then(rs=>{ + if(rs.status==200 && rs.result){ + this.isTrample=true; + } + }); + }, changeTab(idx){ this.tabIndex=idx; }, @@ -540,7 +566,162 @@ closeAllCatalog(){ this.catalogShow=false; //定位目录 - } + }, + openScore(){ + //显示评分弹窗 + if(this.scoreInfo.has){ + this.$refs.messager.show({message:'您已评过分',type:'error'}); + return; + } + this.scoreInfo.dlgShow=true; + }, + closeScore(){ + this.scoreInfo.dlgShow=false; + }, + addScore(){ + if(this.scoreInfo.has){ + this.$refs.messager.show({message:'您已评过分',type:'error'}); + this.scoreInfo.dlgShow=false; + return; + } + let postData={ + courseId:this.courseInfo.id, + studyId:this.studyId, + score:this.scoreInfo.score + } + if(this.scoreInfo.score>0){ + apiCourseGrade.grade(postData).then(rs=>{ + if(rs.status==200){ + this.scoreInfo.dlgShow=false; + this.scoreInfo.has=true; + this.$refs.messager.show({message:'评分成功,谢谢您的评分',type:'success'}); + }else{ + this.$refs.messager.show({message:'评分分处理失败,请稍后再试',type:'error'}); + } + }); + } + }, + openShare(){ + //console.log(this.$refs.fiexdbar,'this.$refs.fiexdbar'); + //因为开始是v-if控制的,所以这里获取不到,必须显示时才会获取到,所以需要单独的弄一个分享组件 + this.$refs.fiexdbar.addShare(); + }, + shareSuccess(rs){ + this.$refs.messager.show({message:'分享成功',type:'success'}); + }, + addFavorite(){ + if(this.loading){ + return; + } + this.loading=true; + uni.showLoading({title:'处理中...'}) + //需要判断是否已点赞,已点赞的不再加 + let postData={ + objType:1, + objId:this.courseId, + title:this.courseInfo.name, + } + if(this.isFavorite) {// 已经收藏,再次点击取消收藏 + apiFavorites.remove(1,this.courseId).then(res=>{ + this.loading=false; + if(res.status==200){ + this.isFavorite=false; + this.$refs.messager.show({message:'已取消收藏',type:'success'}); + }else{ + console.log('取消收藏失败:'+res.message); + } + uni.hideLoading(); + }) + } else { + apiFavorites.save(postData).then(res=>{ + this.loading=false; + if(res.status==200 && res.result){ + this.isFavorite=true; + this.$refs.messager.show({message:'已加入收藏',type:'success'}); + //发送消息 + //this.messageSave(this.data.id,this.data.name,this.userInfo.name,this.data.sysCreateBy,this.data.sysCreateAid,'收藏了我发布的'); + }else{ + this.$refs.messager.show({message:'收藏失败',type:'error'}); + console.log('加入收藏失败:'+res.message); + } + uni.hideLoading(); + }) + } + }, + praiseContent(){ + //赞和踩只能是一个 + if(this.isTrample){ + this.$refs.messager.show({message:'已踩不能赞了',type:'error'}); + return; + } + let postData={ + objType:1, + objId:this.courseInfo.id, + title:this.courseInfo.name + } + if(this.interactRuning){ + return; + } + this.interactRuning=true; + if(this.isPraise){ + apiPraises.remove(1,this.courseInfo.id).then(rs=>{ + this.interactRuning=false; + if(rs.status==200){ + this.$refs.messager.show({message:'已取消点赞',type:'success'}); + this.isPraise=false; + this.courseInfo.praises--; + }else{ + this.$refs.messager.show({message:'取消点赞失败,请稍后再试',type:'success'}); + } + }) + }else{ + apiPraises.save(postData).then(rs=>{ + this.interactRuning=false; + if(rs.status==200){ + this.$refs.messager.show({message:'点赞成功',type:'success'}); + this.isPraise=true; + this.courseInfo.praises++; + }else{ + this.$refs.messager.show({message:'点赞失败,请稍后再试',type:'success'}); + } + }) + } + }, + treadContent(){ + //赞和踩只能是一个 + if(this.isPraise){ + this.$refs.messager.show({message:'已赞不能踩了',type:'error'}); + return; + } + if(this.interactRuning){ + return; + } + this.interactRuning=true; + if(this.isTrample){ + //取消 + apiTrample.remove(this.courseInfo.id).then(rs=>{ + this.interactRuning=false; + if(rs.status==200){ + this.$refs.messager.show({message:'已取消踩',type:'success'}); + this.isTrample=false; + this.courseInfo.trampleCount--; + }else{ + this.$refs.messager.show({message:'取消踩失败,请稍后再试',type:'error'}); + } + }) + }else{ + apiTrample.trample(this.courseInfo.id).then(rs=>{ + this.interactRuning=false; + if(rs.status==200){ + this.$refs.messager.show({message:'已踩',type:'success'}); + this.isTrample=true; + this.courseInfo.trampleCount++; + }else{ + this.$refs.messager.show({message:'踩失败,请稍后再试',type:'error'}); + } + }) + } + }, } }