Files
learning-system-portal/src/views/portal/follow/index.vue
zhaofang 2f4488f71b 提交
2022-10-31 22:02:08 +08:00

618 lines
26 KiB
Vue

<template>
<div class="follow-page">
<div class="follow-banner">
<portal-header current="follow" textColor="#fff" :hideSearch="true" @emitInput="emitInput"></portal-header>
</div>
<div>
<div class="home-page-left">
<!--
<div class="book-input">
<span>分享书籍</span>
<el-input style="width:130px" v-model="input" placeholder="请输入内容"></el-input>
<i style="color: #333333" class="el-icon-search"></i>
</div>
-->
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane name="" label="全部">
<template v-for="item in allPageList">
<course-list v-if="item.contentType == 1" :list="[item]" :isDynamic="true" :personal="true" :isFollow="true" @hideIndex="dynamicHide"></course-list>
<case-list v-if="item.contentType == 3" :list="[item]" :isDynamic="true" :personal="true" :isFollow="true" @hideIndex="dynamicHide"></case-list>
<note-list v-if="item.contentType == 6" :list="[item]" :isDynamic="true" :personal="true" :isFollow="true" @hideIndex="dynamicHide"></note-list>
<put-list v-if="item.contentType == 4" :list="[item]" :isDynamic="true" :personal="true" :isFollow="true" @hideIndex="dynamicHide"></put-list>
<answer-list v-if="item.contentType == 5" :list="[item]" :isDynamic="true" :personal="true" :isFollow="true" @hideIndex="dynamicHide"></answer-list>
<article-list v-if="item.contentType == 2" :list="[item]" :isDynamic="true" :personal="true" :isFollow="true" @hideIndex="dynamicHide"></article-list>
</template>
<div v-if="allPageList.length==0 && loading==1" class="home-no-list">
<img class="img" :src="`${webBaseUrl}/images/homeWu/no-course.png`" alt="" srcset="">
<p class="text">暂时没有动态</p>
</div>
</el-tab-pane>
<el-tab-pane name="1" label="课程">
<course-list :list="cousrePageList" :isDynamic="true" :personal="true" :isFollow="true" @hideIndex="dynamicHide"></course-list>
</el-tab-pane>
<el-tab-pane name="6" label="笔记">
<note-list :list="notePageList" :isDynamic="true" :personal="true" :isFollow="true" @hideIndex="dynamicHide"></note-list>
</el-tab-pane>
<el-tab-pane name="3" label="案例">
<case-list :list="casePageList" :isDynamic="true" :personal="true" :isFollow="true" @hideIndex="dynamicHide"></case-list>
</el-tab-pane>
<el-tab-pane name="2" label="文章">
<article-list :list="articlePageList" :isDynamic="true" :personal="true" :isFollow="true" @hideIndex="dynamicHide"></article-list>
</el-tab-pane>
<el-tab-pane name="4" label="提问">
<put-list :list="qaPageList" :isDynamic="true" :personal="true" :isFollow="true" @hideIndex="dynamicHide"></put-list>
</el-tab-pane>
<el-tab-pane name="5" label="回答">
<answer-list :list="answerPageList" :isDynamic="true" :personal="true" :isFollow="true" @hideIndex="dynamicHide"></answer-list>
</el-tab-pane>
<!-- <el-tab-pane name="7" label="关注">
<follow-list></follow-list>
</el-tab-pane> -->
<!--
<el-tab-pane name="book" label="书籍">
<span slot="label"><svg-icon icon-class="home-book" style="font-size: 30px;"></svg-icon><span class="tabs-info">书籍</span></span>
<book-list></book-list>
</el-tab-pane>
-->
</el-tabs>
<div style="text-align: center; margin-top:57px;" v-show="page.count > 0">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.pageIndex"
:page-sizes="[10, 20, 30, 40]"
:page-size="page.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="page.count">
</el-pagination>
</div>
<div style="height:200px"></div>
</div>
</div>
</div>
</template>
<script>
import portalHeader from "@/components/PortalHeader.vue";
import UcHeader from '@/components/HomePage/homePage.vue'
import CaseList from '@/components/HomePage/caseList.vue'
import CourseList from '@/components/HomePage/courseList.vue'
import NoteList from "@/components/HomePage/noteList.vue"
import PutList from "@/components/HomePage/putTo.vue"
import AnswerList from "@/components/HomePage/answerList.vue"
import ArticleList from "@/components/HomePage/articleList.vue"
import FollowList from "@/components/HomePage/followList.vue"
import BookList from "@/components/HomePage/bookList.vue"
import apiFollow from "@/api/phase2/userfollow.js"
import apiStat from "@/api/phase2/stat.js"
import apiArticle from '@/api/modules/article.js'
import apiCases from '@/api/modules/cases.js'
import apiCourseStudy from '@/api/modules/courseStudy.js'
import apiQa from '@/api/modules/qa.js'
import apiCourse from '@/api/modules/course.js'
import apiNote from '@/api/phase2/note.js'
import apiUser from "@/api/system/user.js";
import {cutFullName} from "@/utils/tools.js";
import { mapGetters,mapActions } from 'vuex';
export default{
components:{portalHeader,UcHeader,CaseList,CourseList,NoteList,PutList,AnswerList,ArticleList,FollowList,BookList},
data(){
return{
input:'',
loading:0,//加载中
activeName:'first',
page:{
pageIndex:1,
pageSize:10,
count:0
},
input:'',
activeName:'',
pageId:'',
// pageList:[],
casePageList:[],
notePageList:[],
articlePageList:[],
qaPageList:[],
answerPageList:[],
cousrePageList:[],
allPageList:[],
personal:true,
orgData:[],
Profess:[],
followIds:[],
}
},
computed: {
...mapGetters(['userInfo','majorTypeMap','orgDomainMap']),
},
created() {
apiFollow.list().then(res=>{
if(res.status == 200) {
this.followIds = res.result;
this.followIds.push(this.userInfo.aid);
this.getList()
}
})
this.loadMajorType();
this.loadOrgDomain();
},
methods:{
emitInput(){
},
...mapActions({
loadMajorType:'majorType/loadMajorTypes',
loadOrgDomain:'orgDomain/loadOrgDomains'
}),
dynamicHide(id){
apiStat.dynamicHide(id).then(res=>{
if(res.status == 200){
this.$message.success('动态隐藏成功')
this.getList();
} else {
this.$message.error(res.message);
}
})
},
handleSizeChange(val) {
this.page.pageSize = val;
this.page.pageIndex = 1;
this.getList();
},
handleCurrentChange(val) {
this.page.pageIndex = val;
this.getList();
},
getList() {
let data = {
pageIndex:this.page.pageIndex,
pageSize:this.page.pageSize,
contentType:this.activeName == 0? '':this.activeName,//内容类型
aids:this.followIds // 数组
}
apiStat.userDynamicfollows(data).then(res=>{
this.loading=1;
if(res.status == 200) {
this.page.count = res.result.count;
if(res.result.count==0){
return;
}
let ids = res.result.list.map(item=>item.contentId);
let aids = [];
const noReapetIds = [...new Set(ids)];
res.result.list.forEach(item=>{
aids.push(item.aid);
item.info = {};
item.authorInfo = {
aid: "",
name: "",
orgInfo: "",
avatar: "",
sex: null
}
item.isAll = false;
})
if(this.activeName == 0) {// 动态处理
this.getAllList(res.result.list)
}
if(this.activeName == 1){
const noReapetAids = [...new Set(aids)];
this.cousrePageList = res.result.list;
this.getCourse(noReapetIds,res.result.list);
}
if(this.activeName == 2) {
this.articlePageList = res.result.list;
this.getArticle(noReapetIds,res.result.list);
}
if(this.activeName == 3) {
this.casePageList = res.result.list;
this.getCase(noReapetIds,res.result.list);
}
if(this.activeName == 6) { // 笔记
this.getNote(noReapetIds,res.result.list);
this.notePageList = res.result.list;
}
if(this.activeName == 4) { // 提问
this.qaPageList = res.result.list;
this.getQa(noReapetIds,res.result.list);
}
if(this.activeName == 5) { // 回答
this.answerPageList = res.result.list;
this.getAnswer(ids,res.result.list);
}
}
})
},
getAllList(list) {
this.allPageList = [];
let casePageList=[];
let notePageList=[];
let articlePageList=[];
let qaPageList=[];
let answerPageList=[];
let cousrePageList=[];
list.forEach(item=>{
if(item.contentType == 1) {
cousrePageList.push(item);
}
if(item.contentType == 2) {
articlePageList.push(item);
}
if(item.contentType == 3) {
casePageList.push(item);
}
if(item.contentType == 4) {
qaPageList.push(item);
}
if(item.contentType == 5) {
answerPageList.push(item);
}
if(item.contentType == 6) {
notePageList.push(item);
}
})
let caseIds = casePageList.map(item=>item.contentId);
const noReapetCaseIds = [...new Set(caseIds)];
let articleIds = articlePageList.map(item=>item.contentId);
const noReapetArticleIds = [...new Set(articleIds)];
let cousreIds = cousrePageList.map(item=>item.contentId);
const noReapetCousreIds = [...new Set(cousreIds)];
let qaIds = qaPageList.map(item=>item.contentId);
const noReapetQaIds = [...new Set(qaIds)];
let anwerIds = answerPageList.map(item=>item.contentId);
const noReapetAnwerIds = [...new Set(anwerIds)];
let noteIds = notePageList.map(item=>item.contentId);
const noReapetNoteIds = [...new Set(noteIds)];
if(noReapetCaseIds.length > 0) {
this.getCase(noReapetCaseIds,casePageList);
}
if(noReapetArticleIds.length > 0) {
this.getArticle(noReapetArticleIds,articlePageList);
}
if(noReapetCousreIds.length > 0) {
this.getCourse(noReapetCousreIds,cousrePageList);
}
if(noReapetQaIds.length > 0) {
this.getQa(noReapetQaIds,qaPageList);
}
if(noReapetAnwerIds.length > 0) {
this.getAnswer(noReapetAnwerIds,answerPageList);
}
if(noReapetNoteIds.length > 0) {
this.getNote(noReapetNoteIds,notePageList);
}
this.allPageList.push(...casePageList,...articlePageList,...cousrePageList,...qaPageList,...answerPageList,...notePageList);
this.allPageList.sort(this.pcompare("eventTime", false));
},
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;
};
},
getAnswer(ids,list){
if(ids.length == 0){
return
}
apiQa.answerIds(ids).then(res=>{
if(res.status == 200) {
list.forEach((item, index) => {
res.result.some(con => {
if (con.id == item.contentId) {
item.info = con;
return true;
} else {
return false;
}
});
});
}
})
},
getQa(ids,list){
apiQa.ids(ids).then(res=>{
if(res.status == 200) {
list.forEach((item, index) => {
res.result.some(con => {
if (con.id == item.contentId) {
item.info = con;
return true;
} else {
return false;
}
});
});
}
})
},
getNote(ids,list) {
apiNote.ids(ids).then(res=>{
if(res.status == 200) {
list.forEach((item, index) => {
res.result.some(con => {
if (con.id == item.contentId) {
item.info = con;
return true;
} else {
return false;
}
});
});
}
})
},
getCase(ids,list){
apiCases.ids(ids).then(res=>{
if(res.status == 200) {
list.forEach((item, index) => {
res.result.some(con => {
if (con.id == item.contentId) {
item.info = con;
if(typeof item.info.majorType == 'string') {
item.info.majorType = item.info.majorType.split(',');
}
return true;
} else {
return false;
}
});
});
this.getCaseUserData(list);
}
})
},
getCaseUserData(list) {
// let ids = caseList.map((item, index) => {
// return item.info.authorId;
// });
// const noReapetIds = [...new Set(ids)];
let data = list.filter((item, index) => {
return item.info && item.info.authorId != null;
});
let ids = data.map((item, index) => {
return item.info.authorId;
});
const noReapetIds = [...new Set(ids)];
apiUser.getByIds(noReapetIds).then(res => {
if (res.status == 200) {
list.forEach((item, index) => {
res.result.some(author => {
if (author.aid == item.info.authorId) {
item.authorInfo = author;
author.orgInfo=cutFullName(author.orgInfo,1);
return true;
} else {
return false;
}
});
});
} else {
this.$message.error(res.message);
}
});
},
getArticle(ids,list){
apiArticle.ids(ids).then(res=>{
if(res.status == 200) {
list.forEach((item, index) => {
res.result.some(con => {
if (con.id == item.contentId) {
item.info = con;
return true;
} else {
return false;
}
});
});
this.getArticleUserData(list);
}
})
},
getArticleUserData(list) {
let data = list.filter((item, index) => {
return item.info && item.info.sysCreateAid != null;
});
let ids = data.map((item, index) => {
return item.info.sysCreateAid;
});
const noReapetIds = [...new Set(ids)];
apiUser.getByIds(noReapetIds).then(res => {
if (res.status == 200) {
list.forEach((item, index) => {
res.result.some(author => {
if (author.aid == item.info.sysCreateAid) {
item.authorInfo = author;
author.orgInfo=cutFullName(author.orgInfo,1);
return true;
} else {
return false;
}
});
});
} else {
this.$message.error(res.message);
}
});
},
getCourse(ids,list) {
let params = {
ids:ids,
aids:this.followIds
}
apiCourseStudy.followIds(params).then(res=>{
if(res.status == 200) {
list.forEach((item, index) => {
res.result.some(con => {
if (item.contentId == con.courseId && item.aid == con.aid) {
item.info = con;
return true;
} else {
return false;
}
});
});
// this.getArticleUserData(list);
}
})
},
handleClick() {
this.page.count = 0;
this.getList();
}
}
}
</script>
<style lang="scss" scoped>
.follow-banner{
background-color: #0078FC;
}
.follow-page{
background: #FFFFFF;
// height: 100%;
::v-deep .el-tabs__active-bar{
height: 4px;
border-radius: 3px;
background: #387DF7;
margin-top: 15px;
}
::v-deep .el-tabs__item{
padding: 0 30px;
height: 55px;
font-size: 18px;
font-weight: 400;
color: #333333;
}
::v-deep .el-tabs__item.is-active{
font-size: 18px;
font-weight: 600;
color: #333333;
}
::v-deep .el-tabs__nav-wrap::after{
height: 1px;
background-color: 979797;
}
.home-page-left{
border-radius: 4px;
padding-top: 29px;
margin: 0px 20% 0 19%;
position: relative;
.book-input{
position: absolute;
right: 0px;
width: 250px;
height: 40px;
border: 1px solid rgba(153,153,153,0.5);
border-radius: 19px;
span{
display: inline-block;
font-size: 14px;
color: #999999;
padding: 0 10px 0 16px;
border-right: 1px solid rgba($color: #999999, $alpha: 0.48);
}
::v-deep .el-input__inner{
border: none !important;
}
::v-deep .el-icon-search{
color: #333333 !important;
}
}
// display: flex;
.svg-icon{
vertical-align: middle;
}
.tabs-info{
font-size: 16px;
color: #333333;
margin-left: 4px;
}
}
.home-page-right{
padding: 40px 52px 18px 52px;
box-sizing: border-box;
background: #fff;
border-radius: 4px;
margin-left: 25px;
.total-per{
display: flex;
// justify-content: space-between;
padding-bottom: 28px;
border-bottom: 1px solid rgba($color: #999999, $alpha: 0.21);
.per-li{
width: 90px;
text-align: center;
margin: 0 25px;
.per-info{
display: block;
font-size: 28px;
font-weight: 600;
color: #333333;
}
.per-text{
font-size: 14px;
color: #666666;
}
}
}
.ach-title{
font-size: 18px;
font-weight: 600;
color: #333333;
}
.ach-ul{
display: flex;
flex-wrap: wrap;
border-bottom: 1px solid rgba($color: #999999, $alpha: 0.21);
padding-bottom: 4px;
.ach-box{
flex: 33%;
width: 57px;
text-align: center;
margin-bottom: 18px;
img{
width: 52px;
height: 58px;
margin-bottom: 4px;
}
p{
font-size: 14px;
color: #333333;
line-height: 20px;
}
}
}
.ava-info{
display: flex;
padding: 10px 0 30px 0;
img{
width: 48px;
height: 48px;
}
.ava-text{
padding: 2px 0;
margin-left: 18px;
font-size: 14px;
display: flex;
flex-direction: column;
justify-content: space-between;
}
}
}
// }
}
</style>