|
|
|
@ -127,7 +127,7 @@
|
|
|
|
|
<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" />
|
|
|
|
|
<img class="touxiang" src="story.photo" />
|
|
|
|
|
<div class="familytitle">{{ story.username }}</div>
|
|
|
|
|
<div class="familycontent">{{ story.content }}</div>
|
|
|
|
|
</div>
|
|
|
|
@ -163,8 +163,8 @@
|
|
|
|
|
page: 1,
|
|
|
|
|
userid: 1,
|
|
|
|
|
totalPages: 1,
|
|
|
|
|
familystoriespage:0,
|
|
|
|
|
checkfamilystories:[],
|
|
|
|
|
familystoriespage: 0,
|
|
|
|
|
checkfamilystories: [],
|
|
|
|
|
posts: [
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -343,7 +343,32 @@
|
|
|
|
|
try {
|
|
|
|
|
const response = await axios.get(`/posts/topfamilystory`);
|
|
|
|
|
this.familystories.push(...response);
|
|
|
|
|
this.checkfamilystories.push(...response.slice(0, 4));
|
|
|
|
|
// 获取每个家庭故事帖子的用户信息(头像和用户名)
|
|
|
|
|
const familystoriesWithUserInfo = await Promise.all(
|
|
|
|
|
this.familystories.map(async (story) => {
|
|
|
|
|
const { userId } = story; // 假设每个帖子有一个 userId 字段
|
|
|
|
|
try {
|
|
|
|
|
// 获取每个帖子的用户信息
|
|
|
|
|
const userResponse = await axios.get(`/user/info/${userId}`);
|
|
|
|
|
const { photo } = userResponse.data; // 假设 `data` 中包含 `username` 和 `photo`
|
|
|
|
|
|
|
|
|
|
// 返回包含用户信息的帖子对象
|
|
|
|
|
return {
|
|
|
|
|
...story,
|
|
|
|
|
photo
|
|
|
|
|
};
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(`获取用户信息失败: ${error.message}`);
|
|
|
|
|
return {
|
|
|
|
|
...story,
|
|
|
|
|
photo: null
|
|
|
|
|
}; // 如果获取用户信息失败,可以设置为 null 或默认值
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
this.familystories = familystoriesWithUserInfo;
|
|
|
|
|
|
|
|
|
|
this.checkfamilystories.push(...this.familystories.slice(0, 4));
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
this.$message.error("热门家族故事获取失败");
|
|
|
|
@ -462,12 +487,12 @@
|
|
|
|
|
refresh() {//热门家族故事刷新换一批按钮
|
|
|
|
|
// 点击后触发的刷新动作
|
|
|
|
|
|
|
|
|
|
this.familystoriespage+=4;
|
|
|
|
|
if(this.familystoriespage>12){
|
|
|
|
|
this.familystoriespage=0;
|
|
|
|
|
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.checkfamilystories.push(...this.familystories.slice(this.familystoriespage, this.familystoriespage + 4));
|
|
|
|
|
this.triggerAnimation();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|