...
|
...
|
@@ -2,8 +2,8 @@ |
|
|
<Layout class="article-detail">
|
|
|
<RecycleScrollReveal :size="10" ref="scroll" @scroll="onScroll" :offset="2000" :on-fetch="onFetch" :manual-init="true">
|
|
|
<template v-slot:eternalTop>
|
|
|
<ArticleDeatilLong v-if="article.sort == 2" ref="detailLong" :data="article" :scroll-top="scrollTop" :list-title="listTitle" :scroll-to="scrollTo" @on-show-more="onShowMore" @on-follow="onFollowAuthor"></ArticleDeatilLong>
|
|
|
<ArticleDeatilNote v-else ref="detailNote" :data="article" :scroll-top="scrollTop" :list-title="listTitle" :scroll-to="scrollTo" @on-show-more="onShowMore" @on-follow="onFollowAuthor"></ArticleDeatilNote>
|
|
|
<ArticleDeatilLong v-if="articleInfo.sort == 2" ref="detailLong" :data="articleInfo" :scroll-top="scrollTop" :list-title="listTitle" :scroll-to="scrollTo" @on-show-more="onShowMore" @on-follow="onFollowAuthor"></ArticleDeatilLong>
|
|
|
<ArticleDeatilNote v-else ref="detailNote" :data="articleInfo" :scroll-top="scrollTop" :list-title="listTitle" :scroll-to="scrollTo" @on-show-more="onShowMore" @on-follow="onFollowAuthor"></ArticleDeatilNote>
|
|
|
</template>
|
|
|
<template class="article-item" #item="{ data }">
|
|
|
<ArticleItem2
|
...
|
...
|
@@ -59,17 +59,32 @@ export default { |
|
|
this.init();
|
|
|
}
|
|
|
},
|
|
|
serverPrefetch() {
|
|
|
async serverPrefetch() {
|
|
|
this.id = parseInt(this.$route.params.id, 10);
|
|
|
|
|
|
return this.id > 0 ? this.syncServiceArticleDetail(true) : Promise.resolve();
|
|
|
if (this.id > 0) {
|
|
|
return this.fetchArticleList({
|
|
|
articleId: this.id,
|
|
|
singleDetail: 'Y',
|
|
|
thumb: true
|
|
|
})
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
},
|
|
|
mounted() {
|
|
|
this.colWidthForTwo = Math.floor(this.$el.offsetWidth / 2);
|
|
|
},
|
|
|
computed: {
|
|
|
...mapYohoState(['yoho']),
|
|
|
...mapState(['articleSingleDetail'])
|
|
|
...mapState(['articleSingleDetail']),
|
|
|
articleInfo() {
|
|
|
if (this.articleSingleDetail.thumb) {
|
|
|
return this.articleSingleDetail;
|
|
|
} else {
|
|
|
return this.article;
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(['fetchArticleList', 'fetchDetailRecommendAricles']),
|
...
|
...
|
@@ -87,13 +102,12 @@ export default { |
|
|
this.scrolling = false;
|
|
|
}, 400);
|
|
|
},
|
|
|
syncServiceArticleDetail(thumb) {
|
|
|
syncServiceArticleDetail() {
|
|
|
const articleId = parseInt(this.id, 10);
|
|
|
|
|
|
return this.fetchArticleList({
|
|
|
articleId,
|
|
|
singleDetail: 'Y',
|
|
|
thumb
|
|
|
singleDetail: 'Y'
|
|
|
}).then(res => {
|
|
|
const emptyData = {
|
|
|
articleId,
|
...
|
...
|
@@ -104,16 +118,6 @@ export default { |
|
|
|
|
|
if (res.code === 200) {
|
|
|
article = get(res, 'data.detailList[0]', {...emptyData});
|
|
|
|
|
|
if (thumb) {
|
|
|
article.comments = [];
|
|
|
article.hasAttention = '';
|
|
|
article.hasFavor = '';
|
|
|
article.hasPraise = '';
|
|
|
article.commentCount = 0;
|
|
|
article.favoriteCount = 0;
|
|
|
article.praiseCount = 0;
|
|
|
}
|
|
|
} else if (res.code === 403) {
|
|
|
article = {...emptyData};
|
|
|
} else {
|
...
|
...
|
|