diff --git a/pages/homepages/community/community/community.vue b/pages/homepages/community/community/community.vue index d6b9742..31a8a60 100644 --- a/pages/homepages/community/community/community.vue +++ b/pages/homepages/community/community/community.vue @@ -27,30 +27,30 @@ - + - 今天去海边锻炼看见的,真是太美了啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊 + {{item.word}} - + - 10 + {{item.comments_num}} @@ -70,30 +70,79 @@ export default { return { posts:[ { - content:'' + avatar:'../../../../static/homepages/community/community/pictures/dog_image.png', + name:'cat', + date:'2024年9月31日', + word:'今天去海边锻炼看见的,真是太美了啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊', + imgList:[ + '../../../../static/homepages/community/community/pictures/dog_image.png', + '../../../../static/homepages/community/community/pictures/dog_image.png', + '../../../../static/homepages/community/community/pictures/dog_image.png', + '../../../../static/homepages/community/community/pictures/dog_image.png', + ], + comments_num:1, + like_num:100, + islike:false, }, { - content:'' + avatar:'../../../../static/homepages/community/community/pictures/dog_image.png', + name:'puppy', + date:'2024年11月13日', + word:'今天去海边锻炼看见的,真是太美了', + imgList:[ + '../../../../static/homepages/community/community/pictures/dog_image.png', + '../../../../static/homepages/community/community/pictures/dog_image.png', + '../../../../static/homepages/community/community/pictures/dog_image.png', + ], + comments_num:12, + like_num:17, + islike:false, }, { - content:'' + avatar:'../../../../static/homepages/community/community/pictures/dog_image.png', + name:'cat', + date:'2024年10月13日', + word:'今天去海边锻炼看见的', + imgList:[ + '../../../../static/homepages/community/community/pictures/dog_image.png', + '../../../../static/homepages/community/community/pictures/dog_image.png', + ], + comments_num:10, + like_num:100, + islike:false, }, { - content:'' + avatar:'../../../../static/homepages/community/community/pictures/dog_image.png', + name:'cat', + date:'2024年1月13日', + word:'今天去锻炼', + imgList:[ + '../../../../static/homepages/community/community/pictures/dog_image.png', + ], + comments_num:10, + like_num:100, + islike:false, }, ], - imgList: [ - '../../../../static/homepages/community/community/pictures/dog_image.png', - '../../../../static/homepages/community/community/pictures/dog_image.png', - '../../../../static/homepages/community/community/pictures/dog_image.png', - '../../../../static/homepages/community/community/pictures/dog_image.png', - ] }; }, mounted(){ this.getAllPost() }, + computed:{ + likeImages() { + return this.posts.map((post, index) => ({ + index, + image: post.islike ? '../../../../static/homepages/community/community/pictures/red_love_image.png' : '../../../../static/homepages/community/community/pictures/love_image.png' + })); + } + }, methods:{ + getLikeImage(index) { + //TODO:获取点赞的图片 + const item = this.likeImages.find(item => item.index === index); + return item ? item.image : ''; + }, getAllPost(){ //TODO:获取所有的帖子 const app = getApp() @@ -110,8 +159,9 @@ export default { }, }) }, - likeClick(){ + likeClick(index){ //TODO:点赞 + this.posts[index].islike = this.posts[index].islike ? false:true }, toAddPostPage(){ //TODO:转到发布帖子界面 diff --git a/static/homepages/community/community/pictures/red_love_image.png b/static/homepages/community/community/pictures/red_love_image.png new file mode 100644 index 0000000..2008c0a Binary files /dev/null and b/static/homepages/community/community/pictures/red_love_image.png differ