个人主页接口对接

This commit is contained in:
zhaofang
2022-09-20 19:53:09 +08:00
parent 44253f06f0
commit b99f54189d
19 changed files with 533 additions and 886 deletions

View File

@@ -6,44 +6,56 @@
<i style="color: #333333" class="el-icon-search"></i>
</div>
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane name="first">
<el-tab-pane name="">
<span slot="label"><svg-icon icon-class="home-dynamic" style="font-size: 30px;"></svg-icon> <span class="tabs-info">动态</span></span>
动态
</el-tab-pane>
<el-tab-pane name="second">
<el-tab-pane name="1">
<span slot="label"><svg-icon icon-class="home-course" style="font-size: 30px;"></svg-icon><span class="tabs-info">课程</span></span>
<course-list></course-list>
<course-list :list="cousrePageList"></course-list>
</el-tab-pane>
<el-tab-pane name="case">
<el-tab-pane name="3">
<span slot="label"><svg-icon icon-class="home-case" style="font-size: 30px;"></svg-icon><span class="tabs-info">案例</span></span>
<case-list></case-list>
<case-list :list="casePageList"></case-list>
</el-tab-pane>
<el-tab-pane name="note">
<el-tab-pane name="6">
<span slot="label"><svg-icon icon-class="home-note" style="font-size: 30px;"></svg-icon><span class="tabs-info">笔记</span></span>
<note-list></note-list>
<note-list :list="notePageList"></note-list>
</el-tab-pane>
<el-tab-pane name="qa">
<el-tab-pane name="4">
<span slot="label"><svg-icon icon-class="home-qa" style="font-size: 30px;"></svg-icon><span class="tabs-info">提问</span></span>
<put-list></put-list>
<put-list :list="qaPageList"></put-list>
</el-tab-pane>
<el-tab-pane name="answer">
<el-tab-pane name="5">
<span slot="label"><svg-icon icon-class="home-answer" style="font-size: 30px;"></svg-icon><span class="tabs-info">回答</span></span>
<answer-list></answer-list>
<answer-list :list="answerPageList"></answer-list>
</el-tab-pane>
<el-tab-pane name="article">
<el-tab-pane name="2">
<span slot="label"><svg-icon icon-class="home-article" style="font-size: 30px;"></svg-icon><span class="tabs-info">文章</span></span>
<article-list></article-list>
<article-list :list="articlePageList"></article-list>
</el-tab-pane>
<el-tab-pane name="fourth">
<el-tab-pane name="7">
<span slot="label"><svg-icon icon-class="home-follow" style="font-size: 30px;"></svg-icon><span class="tabs-info">关注</span></span>
<follow-list></follow-list>
</el-tab-pane>
<el-tab-pane name="book">
<el-tab-pane name="8">
<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="width:200px"></div>
<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>
</template>
@@ -58,20 +70,270 @@
import ArticleList from "@/components/HomePage/articleList.vue"
import FollowList from "@/components/HomePage/followList.vue"
import BookList from "@/components/HomePage/bookList.vue"
import apiStat from '@/api/phase2/stat.js';
import apiCourse from '@/api/modules/course.js'
import apiArticle from '@/api/modules/article.js'
import apiCases from '@/api/modules/cases.js'
import apiQa from '@/api/modules/qa.js'
import apiNote from '@/api/phase2/note.js'
import { mapGetters } from 'vuex';
import apiUser from "@/api/system/user.js";
import {cutFullName} from "@/utils/tools.js";
export default{
components:{top,UcHeader,CaseList,CourseList,NoteList,PutList,AnswerList,ArticleList,FollowList,BookList},
computed: {
...mapGetters(['userInfo']),
},
data(){
return{
page:{
pageIndex:1,
pageSize:10,
count:0
},
input:'',
activeName:'first',
activeName:'',
pageId:'',
pageList:[],
casePageList:[],
notePageList:[],
articlePageList:[],
qaPageList:[],
answerPageList:[],
cousrePageList:[],
}
},
methods:{
handleClick() {
}
}
mounted() {
this.pageId = this.$route.query.id;
this.getList();
},
methods:{
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,//内容类型
aid:this.pageId, //指定用户的动态,
hidden:true,//是否隐藏,不指定,查询全部
}
apiStat.userDynamicList(data).then(res=>{
if(res.status == 200) {
this.page.count = res.result.count;
let ids = res.result.list.map(item=>item.contentId);
const noReapetIds = [...new Set(ids)];
res.result.list.forEach(item=>{
item.info = {};
item.authorInfo = {
aid: "",
name: "",
orgInfo: "",
avatar: "",
sex: null
}
item.isAll = false;
})
if(this.activeName == 1){
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);
}
}
})
},
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;
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) {
apiCourse.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);
}
})
},
handleClick() {
this.getList();
}
},
watch:{
},
}
</script>