热门家族故事头像接口

main
QMZ 1 month ago
parent 4e9f643ab2
commit 0504222892

@ -127,7 +127,7 @@
<div v-for="(story, index) in checkfamilystories" :key="index" class="familystore" <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;" style="width: 95%; height: 70px; background-color: rgba(255, 225, 240, 0.7); border-radius: 10%; position: relative;cursor: pointer;"
@click="checkbypostid(story.postid)"> @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="familytitle">{{ story.username }}</div>
<div class="familycontent">{{ story.content }}</div> <div class="familycontent">{{ story.content }}</div>
</div> </div>
@ -163,8 +163,8 @@
page: 1, page: 1,
userid: 1, userid: 1,
totalPages: 1, totalPages: 1,
familystoriespage:0, familystoriespage: 0,
checkfamilystories:[], checkfamilystories: [],
posts: [ posts: [
{ {
@ -343,7 +343,32 @@
try { try {
const response = await axios.get(`/posts/topfamilystory`); const response = await axios.get(`/posts/topfamilystory`);
this.familystories.push(...response); 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) { } catch (error) {
this.$message.error("热门家族故事获取失败"); this.$message.error("热门家族故事获取失败");
@ -462,12 +487,12 @@
refresh() {// refresh() {//
// //
this.familystoriespage+=4; this.familystoriespage += 4;
if(this.familystoriespage>12){ if (this.familystoriespage > 12) {
this.familystoriespage=0; this.familystoriespage = 0;
} }
this.checkfamilystories.splice(0, this.checkfamilystories.length); 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(); this.triggerAnimation();
}, },

Loading…
Cancel
Save