Commit 1d65176d by yanju

Merge branch 'yoona' into 'master'

完成他人主页的展示

See merge request !28
parents 88b46689 f7539dec
......@@ -16,7 +16,7 @@
:height-v="96"
:flex-v="['row','flex-start','flex-start']"
:font-style="[28,36,400,'#999','left']"
:extend-style="{overflowX: 'scroll'}"
:extend-style="{overflowX: 'scroll', marginRight: showRight ? 0 : commonReturnFlexedLength(40)}"
>
<yun-div
:no-flex-shrink="true"
......
......@@ -3,11 +3,43 @@
<yun-div :margin-v="[0,0,20]">
<user-card-big></user-card-big>
</yun-div>
<Nav :show-right="false" :nav-list="navList" :path="path"></Nav>
<project-card></project-card>
<project-card></project-card>
<project-card></project-card>
<project-card></project-card>
<Nav :show-right="false" :nav-list="navList"></Nav>
<yun-div v-if="rightList.length > 0">
<yun-div v-if="selected==='blog'|| selected ==='project'">
<project-card
v-for="(val,index) in rightList"
:info="val"
:key="val.contentId"
></project-card>
</yun-div>
<yun-div v-else-if="selected==='answer'|| selected ==='myReply'">
<answer-card
v-for="(val,index) in rightList"
:info="val"
:key="val.questionId"
></answer-card>
</yun-div>
<yun-div v-else-if="selected==='dynamic'">
<dynamic-card
v-for="(val,index) in rightList"
:key="val.postId"
:info="val"
></dynamic-card>
</yun-div>
<yun-div v-else-if="selected==='topic'">
<topic-card></topic-card>
</yun-div>
<yun-div v-if="selected==='following' || selected === 'fans'">
<user-card-x
v-for="(val,index) in rightList"
:info="val"
:key="val.userId"
></user-card-x>
</yun-div>
<scroll-loading ref="pagination" :pages="pages" v-on:changePage="changePage"></scroll-loading>
</yun-div>
<empty-card v-else></empty-card>
</yun-div>
</template>
......@@ -16,49 +48,261 @@ import UserCardBig from "../../../components/moblie/userCardBig";
import commonMixin from "../../../components/moblie/commonMixin";
import Nav from "../../../components/moblie/nav";
import ProjectCard from "../../../components/moblie/projectCard";
import ScrollLoading from "../../../components/moblie/scrollLoading";
import EmptyCard from "../../../components/moblie/emptyCard";
import AnswerCard from '../../../components/moblie/answerCard'
import DynamicCard from '../../../components/moblie/dynamicCard'
import config from "../../../action/config";
import TopicCard from "../../../components/moblie/topicCard";
import UserCardX from "../../../components/moblie/userCardX";
export default {
mixins: [commonMixin],
components: {ProjectCard, Nav, UserCardBig},
components: {UserCardX, TopicCard, EmptyCard, ProjectCard, Nav, UserCardBig, ScrollLoading, AnswerCard, DynamicCard},
async asyncData({$axios, params}) {
//获取他人的资料
let infoResponse = await $axios.$get(config.api.get.User.otherInfo + params.id + '/baseinfo');
return { ...infoResponse.data }
},
data() {
return {
// 获取用户id
id: 12,
number: 32
id: 0,
rightList: [],
pages: 1,
selected: ''
}
},
computed: {
navList: function () {
return [
{
label: `项目·${this.number}`,
id: 'project'
label: `项目 · ${this.statistics.projectNum}`,
path: `/u/${this.id}/project`
},
{
label: `博客 · ${this.statistics.blogNum}`,
path: `/u/${this.id}/blog`
},
{
label: `提问 · ${this.statistics.questionNum}`,
path: `/u/${this.id}/answer`
},
{
label: `博客·${this.number}`,
id: 'blog'
label: `回答 · ${this.statistics.questionReplyNum}`,
path: `/u/${this.id}/myReply`
},
{
label: `提问·${this.number}`,
id: 'answer'
label: `动态`,
path: `/u/${this.id}/dynamic`
},
{
label: `回答·${this.number}`,
id: 'myAnswer'
label: `话题`,
path: `/u/${this.id}/topic`
},
{
label: `动态·${this.number}`,
id: 'dynamic'
label: `关注 · ${this.statistics.followedNum}`,
path: `/u/${this.id}/following`
},
{
label: `话题·${this.number}`,
id: 'topic'
label: `粉丝 · ${this.statistics.fansNum}`,
path: `/u/${this.id}/fans`
},
]
},
path: function () {
return `/u/${this.id}`
}
}
},
watch: {
$route(val){
this.selected = this.$route.params.select;
this.restartPagination();
},
},
created() {
this.selected = this.$route.params.select;
this.id = this.$route.params.id
this.changePage(1)
},
methods: {
restartPagination(){
if(process.browser){
this.rightList = [];
this.pages = 1 ;
this.$refs.pagination.setCurrentPage(1)
}
},
handleResponse(currentPage,response){
if(currentPage===1){
this.rightList=response.data.dataList;
this.pages = response.data.totalPage;
}else{
response.data.dataList.map((val,index)=>{
this.rightList.push(val)
});
this.pages = response.data.totalPage;
}
},
//获取动态list
dataGetDynamic(currentPage){
let userId = this.$route.params.id;
this.$axios.$get(config.api.get.Post.otherList+userId+'/posts', {
params: {
page: currentPage,
size: 10
}
}).then((response) => {
console.log(response);
this.handleResponse(currentPage,response)
})
},
//获取创建的问题list
dataGetMyCreateAnswer(currentPage){
if (this.statistics.questionNum === 0) return;
let userId = this.$route.params.id;
this.$axios.$get(config.api.get.Question.otherCreated+userId+'/questions',{
params:{
page:currentPage,
size:10
}
}).then((response)=>{
console.log(response);
this.handleResponse(currentPage,response)
})
},
//获取回答的问题list
dataGetNoticeAnswer(currentPage){
if (this.statistics.questionReplyNum === 0) return;
let userId = this.$route.params.id;
this.$axios.$get(config.api.get.Question.otherParticipated+userId+'/question/participated',{
params:{
page:currentPage,
size:10
}
}).then((response)=>{
console.log(response);
this.handleResponse(currentPage,response)
})
},
//获取我的项目list
dataGetProject(currentPage){
if (this.statistics.projectNum === 0) return;
let userId = this.$route.params.id;
this.$axios.$get(config.api.get.Project.otherList+userId+'/projects', {
params: {
page: currentPage,
size: 10
}
}).then((response) => {
console.log(response);
this.handleResponse(currentPage,response)
})
},
//获取我的博客list
dataGetBlog(currentPage){
if (this.statistics.blogNum === 0) return;
let userId = this.$route.params.id;
this.$axios.$get(config.api.get.Blog.otherList+userId+'/blogs', {
params: {
page: currentPage,
size: 10
}
}).then((response) => {
console.log(response);
this.handleResponse(currentPage,response)
})
},
dataGetMyAnswer(currentPage){
this.$axios.$get(config.api.get.Question.myCreated,{
params:{
page:currentPage,
size:10
}
}).then((response)=>{
console.log(response);
this.handleResponse(currentPage,response)
})
},
//获取他人的粉丝
dataGetFans(currentPage){
let userId = this.$route.params.id;
this.$axios.$get(config.api.get.User.otherFans+userId+'/fans',{
params:{
page:currentPage,
size:10
}
}).then((response)=>{
if(response.code===0){
console.log(response);
this.handleResponse(currentPage,response)
}
})
},
//获取他人的关注
dataGetFollowing(currentPage){
let userId = this.$route.params.id;
this.$axios.$get(config.api.get.User.otherFollowing+userId+'/follower',{
params:{
page:currentPage,
size:10
}
}).then((response)=>{
if(response.code===0){
console.log(response);
this.handleResponse(currentPage,response)
}
})
},
changePage(currentPage){
//返回页数 请求新的数据
if(this.selected==='project'){
this.dataGetProject(currentPage)
}
if(this.selected==='blog'){
this.dataGetBlog(currentPage)
}
if(this.selected==='myReply') {
this.dataGetNoticeAnswer(currentPage)
}
if(this.selected==='answer'){
this.dataGetMyCreateAnswer(currentPage)
}
if(this.selected==='dynamic'){
this.dataGetDynamic(currentPage)
}
if(this.selected==='fans'){
this.dataGetFans(currentPage)
}
if(this.selected==='following'){
this.dataGetFollowing(currentPage)
}
}
},
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment