|
|
|
@ -76,7 +76,7 @@
|
|
|
|
|
</div>
|
|
|
|
|
<div class=heatlist style="margin-top:20px;display: flex;flex-direction:row;">
|
|
|
|
|
<div
|
|
|
|
|
style="position:relative; display: flex;flex-direction:column; color: white; font-weight: bold;margin-left: 20px ;gap:51px">
|
|
|
|
|
style="position:relative; display: flex;flex-direction:column; color: white; font-weight: bold;margin-left: 20px ;gap:51px;margin-top:10px">
|
|
|
|
|
<div class=Hotsearchnum style="background-color:red;">1</div>
|
|
|
|
|
<div class=Hotsearchnum style="background-color:#ff8e51;">2</div>
|
|
|
|
|
<div class=Hotsearchnum style="background-color:#ffc74fd2;">3</div>
|
|
|
|
@ -85,16 +85,16 @@
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
style="font-size: 14px; font-weight: 500; margin-left: 30px; display: flex; flex-direction: column; gap: 17px;width: 100%;">
|
|
|
|
|
style="font-size: 14px; font-weight: 500; margin-left: 20px; display: flex; flex-direction: column; gap: 17px;width: 100%; ">
|
|
|
|
|
<div
|
|
|
|
|
style="overflow: hidden; list-style-type: none; width: 90%; height: 20%; background-color: rgba(255, 225, 240, 0.7); border-radius: 10%; position: relative; cursor: pointer;"
|
|
|
|
|
style="overflow: hidden; list-style-type: none; width: 90%; height: 20%;max-height: 60px; background-color: rgba(255, 225, 240, 0.7); border-radius: 10%; position: relative; cursor: pointer;"
|
|
|
|
|
v-for="(Hotsearch, index) in HotsearchList" :key="index" @click="checkbypostid(Hotsearch.postid)">
|
|
|
|
|
|
|
|
|
|
<div style=" font-weight: bold; margin-left: 10%; margin-top: 1%; ">{{ Hotsearch.username }}:</div>
|
|
|
|
|
<div style="left:10%;width: 70%; font-size: 12px;position: relative;">{{ Hotsearch.content}}</div>
|
|
|
|
|
|
|
|
|
|
<svg width="20" height="20" viewBox="0 0 15 15" xmlns="http://www.w3.org/2000/svg" id="fire-station"
|
|
|
|
|
style="position: absolute;right:7% ;top:20%;fill:red ">
|
|
|
|
|
style="position: absolute;right:5.8% ;top:20%;fill:red ">
|
|
|
|
|
<path
|
|
|
|
|
d="M7.5 14C11.0899 14 14 11 14 7.50003C14 4.5 11.5 2 11.5 2L10.5 5.5L7.5 1L4.5 5.5L3.5 2C3.5 2 1 4.5 1 7.50003C1 11 3.91015 14 7.5 14ZM7.5 12.5C6.11929 12.5 5 11.3807 5 10C5 8.61929 7.5 5.5 7.5 5.5C7.5 5.5 10 8.61929 10 10C10 11.3807 8.88071 12.5 7.5 12.5Z" />
|
|
|
|
|
</svg>
|
|
|
|
@ -123,8 +123,8 @@
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<div class="familystorelist"
|
|
|
|
|
style="margin-top: 20px; display: flex; justify-content: center; flex-direction: column; gap: 10px;">
|
|
|
|
|
<div v-for="(story, index) in familystories" :key="index" class="familystore"
|
|
|
|
|
style="margin-top: 20px; display: flex; justify-content: center; flex-direction: column; gap: 10px;margin-left: 20px;">
|
|
|
|
|
<div v-for="(story, index) in checkfamilystories" :key="index" class="familystore"
|
|
|
|
|
style="width: 95%; height: 70px; background-color: rgba(255, 225, 240, 0.7); border-radius: 10%; position: relative;cursor: pointer;"
|
|
|
|
|
@click="checkbypostid(story.postid)">
|
|
|
|
|
<img class="touxiang" src="../../assets/pictures/touxiang.png" />
|
|
|
|
@ -142,7 +142,8 @@
|
|
|
|
|
<script>
|
|
|
|
|
import PostCard from './PostCard.vue';
|
|
|
|
|
import PostForm from './Postform.vue';
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
import axios from '@/utils/axiosConfig';
|
|
|
|
|
// import {getToken} from '@/token/auth'
|
|
|
|
|
export default {
|
|
|
|
|
name: 'CommunityIndex', // 添加组件名称
|
|
|
|
|
components: { PostCard, PostForm },
|
|
|
|
@ -156,12 +157,13 @@
|
|
|
|
|
hoverIndex: -1,
|
|
|
|
|
selectedIndex: -1,
|
|
|
|
|
isloading: false,
|
|
|
|
|
loaddone: 0,
|
|
|
|
|
checkPostsindex: 0,
|
|
|
|
|
checkPosts: [],
|
|
|
|
|
page: 1,
|
|
|
|
|
userid: 1,
|
|
|
|
|
totalPages: 1,
|
|
|
|
|
familystoriespage:0,
|
|
|
|
|
checkfamilystories:[],
|
|
|
|
|
posts: [
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -207,14 +209,14 @@
|
|
|
|
|
async fllowlist() {
|
|
|
|
|
|
|
|
|
|
const userid = this.userid;//获取用户id
|
|
|
|
|
axios.get(`http://localhost:8082/loveforest/Myfollows/userid=${userid}`)
|
|
|
|
|
axios.get(`/Myfollows/userid=${userid}`)
|
|
|
|
|
.then(response => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.myfollows.splice(0, this.myfollows.length);
|
|
|
|
|
this.myfollows.push(...response.data);
|
|
|
|
|
this.myfollows.push(...response);
|
|
|
|
|
|
|
|
|
|
return response.data;
|
|
|
|
|
return response;
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
console.error('Error:', error);
|
|
|
|
@ -223,20 +225,20 @@
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
submitPost(newpost) {//发布帖子后,本地显示帖子
|
|
|
|
|
this.checkPosts = [newpost, ...this.checkPosts];
|
|
|
|
|
this.checkPosts.unshift(newpost);
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
async load() {//加载帖子函数
|
|
|
|
|
if (this.isloading) {
|
|
|
|
|
try {
|
|
|
|
|
const response = await axios.get(`http://localhost:8082/loveforest/posts`, {
|
|
|
|
|
const response = await axios.get(`/posts`, {
|
|
|
|
|
params: {
|
|
|
|
|
page: this.page,
|
|
|
|
|
size: 5,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const filteredPostsList = response.data.records;
|
|
|
|
|
const filteredPostsList = response.records;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.$message("动态加载中page" + this.page);
|
|
|
|
@ -253,14 +255,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await axios.get(`http://localhost:8082/loveforest/posts/postid=${postid}`);
|
|
|
|
|
const response = await axios.get(`/posts/postid=${postid}`);
|
|
|
|
|
this.isloading = false;
|
|
|
|
|
console.error('动态动态!!!!:',response);
|
|
|
|
|
this.checkPosts.splice(0, this.checkPosts.length);
|
|
|
|
|
this.checkPosts.push(response.data);
|
|
|
|
|
this.checkPosts.push(response);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('动态获取失败', error);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -268,13 +272,13 @@
|
|
|
|
|
|
|
|
|
|
async loaduserlikes() {//加载user点赞列表 并会传入每个帖子做是否已经点赞的判断
|
|
|
|
|
const userid = this.userid;//获取用户id
|
|
|
|
|
axios.get(`http://localhost:8082/loveforest/likes/userid=${userid}`)
|
|
|
|
|
axios.get(`/likes/userid=${userid}`)
|
|
|
|
|
.then(response => {
|
|
|
|
|
|
|
|
|
|
this.userlikelist.splice(0, this.myfollows.length);
|
|
|
|
|
this.userlikelist.push(...response.data);
|
|
|
|
|
this.userlikelist.splice(0, this.userlikelist.length);
|
|
|
|
|
this.userlikelist.push(...response);
|
|
|
|
|
|
|
|
|
|
return response.data;
|
|
|
|
|
return response;
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
console.error('Error:', error);
|
|
|
|
@ -293,9 +297,9 @@
|
|
|
|
|
},
|
|
|
|
|
async loadhotpost() {//加载热门动态
|
|
|
|
|
try {
|
|
|
|
|
const response = await axios.get(`http://localhost:8082/loveforest/posts/topposts`);
|
|
|
|
|
this.HotsearchList.push(...response.data);
|
|
|
|
|
console.log(response.data);
|
|
|
|
|
const response = await axios.get(`/posts/topposts`);
|
|
|
|
|
this.HotsearchList.push(...response);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
this.$message.error("热门动态获取失败");
|
|
|
|
@ -306,8 +310,9 @@
|
|
|
|
|
|
|
|
|
|
async loadhotfamilystory() {//加载热门家族故事
|
|
|
|
|
try {
|
|
|
|
|
const response = await axios.get(`http://localhost:8082/loveforest/posts/topfamilystory`);
|
|
|
|
|
this.familystories.push(...response.data);
|
|
|
|
|
const response = await axios.get(`/posts/topfamilystory`);
|
|
|
|
|
this.familystories.push(...response);
|
|
|
|
|
this.checkfamilystories.push(...response.slice(0, 4));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
@ -323,12 +328,12 @@
|
|
|
|
|
this.selectedIndex = index; // 点击后设置选中的项
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await axios.get(`http://localhost:8082/loveforest/posts/userid=${userid}`);
|
|
|
|
|
const response = await axios.get(`/posts/userid=${userid}`);
|
|
|
|
|
this.isloading = false;
|
|
|
|
|
this.checkPosts.splice(0, this.checkPosts.length);
|
|
|
|
|
|
|
|
|
|
this.checkPosts.push(...response.data);
|
|
|
|
|
if (response.data.length === 0) {
|
|
|
|
|
this.checkPosts.push(...response);
|
|
|
|
|
if (response.length === 0) {
|
|
|
|
|
this.$message("对方还没有发过动态哦");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -350,8 +355,8 @@
|
|
|
|
|
async toggleCommentsVisibility(index, postid) {//展开评论以及获取评论列表
|
|
|
|
|
this.$message("评论区展开" + index);
|
|
|
|
|
try {
|
|
|
|
|
const response = await axios.get(`http://localhost:8082/loveforest/comments/postid=${postid}`);
|
|
|
|
|
this.checkPosts[index].comments = response.data;
|
|
|
|
|
const response = await axios.get(`/comments/postid=${postid}`);
|
|
|
|
|
this.checkPosts[index].comments = response;
|
|
|
|
|
//等待获取user名字接口
|
|
|
|
|
this.checkPosts[index].isCommentsVisible = !this.checkPosts[index].isCommentsVisible;
|
|
|
|
|
|
|
|
|
@ -365,7 +370,7 @@
|
|
|
|
|
async addComment(index, commentText, postid) {//发送评论
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await axios.post('http://localhost:8082/loveforest/comments/addcomments', {
|
|
|
|
|
const response = await axios.post('/comments/addcomments', {
|
|
|
|
|
userid: this.userid,
|
|
|
|
|
postid: postid,
|
|
|
|
|
content: commentText
|
|
|
|
@ -375,7 +380,7 @@
|
|
|
|
|
'Accept': 'application/json'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (response.data === "评论成功!") {
|
|
|
|
|
if (response=== "评论成功!") {
|
|
|
|
|
this.$message.success("评论成功!");
|
|
|
|
|
this.checkPosts[index].comments.push({
|
|
|
|
|
username: '用户名',//等待user接口
|
|
|
|
@ -386,7 +391,7 @@
|
|
|
|
|
this.checkPosts[index].commentCount += 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.$message.error(response.data);
|
|
|
|
|
this.$message.error(response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
@ -400,6 +405,14 @@
|
|
|
|
|
refresh() {//热门家族故事刷新换一批按钮
|
|
|
|
|
// 点击后触发的刷新动作
|
|
|
|
|
console.log('Refreshing...');
|
|
|
|
|
|
|
|
|
|
this.familystoriespage+=4;
|
|
|
|
|
if(this.familystoriespage>12){
|
|
|
|
|
this.familystoriespage=0;
|
|
|
|
|
}
|
|
|
|
|
this.checkfamilystories.splice(0, this.checkfamilystories.length);
|
|
|
|
|
this.checkfamilystories.push(...this.familystories.slice(this.familystoriespage, this.familystoriespage+4));
|
|
|
|
|
|
|
|
|
|
this.triggerAnimation();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|