Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
fix: 修复资讯详情删除最后一条评论时列表没有刷新的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoe committed Jun 29, 2018
1 parent 09b004a commit 38e2883
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions src/page/news/newsDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@
:key="`comment-${comment.id}`"
:comment="comment"
@click="replyComment" />
<div v-if="news.audit_status===0" class="m-box m-aln-center m-justify-center load-more-box">
<span v-if="noMoreCom" class="load-more-ph">---没有更多---</span>
<span v-else class="load-more-btn" @click.stop="fetchNewsComments(maxComId)">
{{fetchComing ? "加载中..." : "点击加载更多"}}
</span>
<!-- <button v-else class="load-more-btn" @click.stop="fetchNewsComments(maxComId)"></button> -->
</div>
<div v-if="news.audit_status===0" class="m-box m-aln-center m-justify-center load-more-box">
<span v-if="noMoreCom" class="load-more-ph">---没有更多---</span>
<span v-else class="load-more-btn" @click.stop="fetchNewsComments(maxComId)">
{{fetchComing ? "加载中..." : "点击加载更多"}}
</span>
<!-- <button v-else class="load-more-btn" @click.stop="fetchNewsComments(maxComId)"></button> -->
</div>
</div>
</article-card>
</template>
Expand Down Expand Up @@ -172,7 +172,7 @@ export default {
return this.news.comment_count || 0;
},
set(val) {
val > 0 && (this.news.comment_count = val);
this.news.comment_count = val;
}
},
time() {
Expand Down Expand Up @@ -246,23 +246,16 @@ export default {
this.fetchComing = true;
this.$http
.get(`/news/${this.newsID}/comments`, {
params: {
after
}
params: { after }
})
.then(({ data: { pinneds = [], comments = [] } }) => {
pinneds &&
pinneds.length &&
(this.pinnedCom = after ? [...this.pinneds, ...pinneds] : pinneds);
comments && comments.length
? ((this.comments = after
? [...this.comments, ...comments]
: comments),
(this.maxComId = comments[comments.length - 1].id))
this.pinnedCom = after ? [...this.pinneds, ...pinneds] : pinneds;
this.comments = after ? [...this.comments, ...comments] : comments;
comments.length
? (this.maxComId = comments[comments.length - 1].id)
: (this.noMoreCom = true);
this.fetchComing = false;
})
.catch(() => {
.finally(() => {
this.fetchComing = false;
});
},
Expand Down

0 comments on commit 38e2883

Please sign in to comment.