提交个人主页内容的修改

This commit is contained in:
daihh
2022-10-14 20:43:39 +08:00
parent cbb082ba33
commit 85d74637f3
4 changed files with 128 additions and 110 deletions

View File

@@ -17,7 +17,7 @@
</div>
<!-- <img style="width:60px;height:60" :src="item.authorInfo.avatar"/> -->
</div>
<div class="follow-center">
<div class="follow-center">
<p class="follow-home-title" style="font-size: 20px;margin-bottom: 12px;">{{item.authorInfo.name}}
<!-- <img style="width:22px;height:22;vertical-align:middle" src="/images/homeWu/man.png" /> -->
</p>
@@ -29,8 +29,9 @@
<el-button class="btn" icon="el-icon-plus" v-if="active == 2">已关注</el-button>
</div>
</div>
<!--分页没有加-->
</div>
<div v-if="followList.length == 0">
<div v-if="showEmpty">
<img class="img" style="width:186px;height:160px" src="/images/homeWu/no-follow.png" alt="" srcset="">
<p class="text">还没有关注的人</p>
</div>
@@ -47,7 +48,7 @@
</div>
<!-- <img style="width:60px;height:60" :src="item.authorInfo.avatar"/> -->
</div>
<div class="follow-center">
<div class="follow-center">
<p class="follow-home-title" style="font-size: 20px;margin-bottom: 12px;">{{maPage.userFollow.authorInfo.name}}
<!-- <img style="width:22px;height:22;vertical-align:middle" src="/images/homeWu/man.png" /> -->
</p>
@@ -58,8 +59,9 @@
<el-button type="primary" class="btn" v-else icon="el-icon-plus">关注他</el-button>
</div>
</div>
<!--分页没有加-->
</div>
</div>
</template>
<script>
@@ -76,9 +78,17 @@ import apiUser from "@/api/system/user.js";
author
},
computed:{
...mapGetters(['userInfo']),
...mapGetters(['userInfo']),
avatarText(){
return userAvatarText(this.userInfo.name);
},
showEmpty(){ //是否显示空信息内容
if(this.active==1 && this.followList.length==0){
return true;
}else if(this.active==2 && this.mypageList.length==0){
return true;
}
return false;
}
},
data(){
@@ -97,80 +107,85 @@ import apiUser from "@/api/system/user.js";
}
},
mounted() {
this.pageId = this.$route.query.id;
this.pageId = this.$xpage.getHomeId(this.$route);
},
methods:{
cancel(item) {
apiFollow.remove(item.followId).then(res=>{
if(res.status == 200) {
this.getPage()
methods:{
cancel(item) {
apiFollow.remove(item.followId).then(res=>{
if(res.status == 200) {
this.getPage()
}
})
},
//展示全部
tagTab(num) {
this.active = num;
if(num == 1) {
if(this.followList.length==0){
this.getPage()
}
} else {
if(this.mypageList.length==0){
this.getMyPage()
}
}
})
},
//展示全部
tagTab(num) {
this.active = num;
if(num == 1) {
this.getPage()
} else {
this.getMyPage()
}
},
getMyPage() {//关注我的,关注他的
this.page.aid = this.pageId;
apiFollow.mypage(this.page).then(res=>{
if(res.status== 200) {
this.count = res.result.count;
res.result.list.forEach(item=>{
item.userFollow.authorInfo = { aid: "",name: "",orgInfo: "",avatar: "",sex: null ,sign:''}
})
this.mypageList = res.result.list;
console.log(this.mypageList,'this.mypageList');
this.getUserData(res.result.list);
}
})
},
getPage() { //我关注的,他关注的
this.page.aid = this.pageId;
apiFollow.page(this.page).then(res=>{
if(res.status== 200) {
this.count = res.result.count;
res.result.list.forEach(item=>{
item.authorInfo = { aid: "",name: "",orgInfo: "",avatar: "",sex: null ,sign:''}
})
this.followList = res.result.list;
this.getUserData(res.result.list);
}
})
},
getUserData(list) {
let ids = [];
if(this.active == 1) {
ids = list.map(item=> item.followId);
} else {
ids = list.map(item=> item.userFollow.aid);
}
apiUser.getByIds(ids).then(res => {
if (res.status == 200) {
list.forEach((item, index) => {
res.result.some(author => {
if (this.active == 1 && author.aid == item.followId) {
item.authorInfo = author;
return true;
} else if ( this.active == 2 && author.aid == item.userFollow.aid) {
item.userFollow.authorInfo = author;
return true;
} else {
return false;
}
});
});
} else {
this.$message.error(res.message);
}
});
},
}
getMyPage() {//关注我的,关注他的
this.page.aid = this.pageId;
apiFollow.mypage(this.page).then(res=>{
if(res.status== 200) {
this.count = res.result.count;
res.result.list.forEach(item=>{
item.userFollow.authorInfo = { aid: "",name: "",orgInfo: "",avatar: "",sex: null ,sign:''}
})
this.mypageList = res.result.list;
//console.log(this.mypageList,'this.mypageList');
this.getUserData(res.result.list);
}
})
},
getPage() { //我关注的,他关注的
this.page.aid = this.pageId;
apiFollow.page(this.page).then(res=>{
if(res.status== 200) {
this.count = res.result.count;
res.result.list.forEach(item=>{
item.authorInfo = { aid: "",name: "",orgInfo: "",avatar: "",sex: null ,sign:''}
})
this.followList = res.result.list;
this.getUserData(res.result.list);
}
})
},
getUserData(list) {
let ids = [];
if(this.active == 1) {
ids = list.map(item=> item.followId);
} else {
ids = list.map(item=> item.userFollow.aid);
}
apiUser.getByIds(ids).then(res => {
if (res.status == 200) {
list.forEach((item, index) => {
res.result.some(author => {
if (this.active == 1 && author.aid == item.followId) {
item.authorInfo = author;
return true;
} else if ( this.active == 2 && author.aid == item.userFollow.aid) {
item.userFollow.authorInfo = author;
return true;
} else {
return false;
}
});
});
} else {
this.$message.error(res.message);
}
});
},
}
}
</script>
<style lang="scss" scoped>
@@ -179,6 +194,7 @@ import apiUser from "@/api/system/user.js";
padding: 4px 0;
.tabs-index{
padding:0 60px 10px 10px;
cursor: pointer;
.line{
display: inline-block;
width: 100%;
@@ -202,4 +218,4 @@ import apiUser from "@/api/system/user.js";
width: 140px;
}
}
</style>
</style>