Authored by yyq

Merge branch 'feature/0530' into release/6.9.5

... ... @@ -25,6 +25,7 @@
:add-type="1"
:user="parentComment.userName"
:column-type="columnType"
:share="share"
@on-comment="onReply">
{{parentComment.content}}
</CommentPlaceholder>
... ... @@ -39,6 +40,7 @@
:add-type="1"
:user="reply.userName"
:column-type="columnType"
:share="share"
@on-comment="onReplyChildren">
<span class="reply-user">{{reply.userName}}</span>
<template v-if="reply.parentUserName">
... ... @@ -68,6 +70,7 @@ export default {
type: Number,
default: 1001
},
share: Boolean,
posId: Number,
articleId: Number
},
... ...
... ... @@ -147,51 +147,53 @@ export default {
}
}
if (!get(result, 'data.total')) {
this.empty = true;
} else {
this.empty = false;
}
return result;
},
async fetchComments(pre) {
const result = await this.fetchCommentsAsync(pre);
let dirty = false;
let dirty = true;
if (result.code === 200) {
const comments = get(result, 'data.commentInfos', []);
if (!get(result, 'data.total')) {
this.empty = true;
} else {
if (comments.length) {
this.empty = false;
this.$emit('on-page-change', {
page: result.data.page,
size: result.data.total
});
if (comments.length) {
this.$emit('on-page-change', {
page: result.data.page,
size: result.data.total
});
if (pre) {
this.commentPreList.unshift(comments);
this.$nextTick(() => {
this.loadPreComment();
});
} else {
if (this.page <= 2) {
this.commentList = comments;
// 将评论滚动到可视区域
if (this.commentId) {
setTimeout(() => {
let scrollHeight = this.$refs.scroll.$el.offsetHeight;
let dom = this.$refs.commentList.getElementsByClassName('comment-' + this.commentId);
if (scrollHeight && dom.length && (dom[0].offsetHeight + dom[0].offsetTop > scrollHeight)) {
this.$refs.scroll.scrollTo(0, scrollHeight - this.$refs.commentList.offsetHeight);
}
}, 500);
}
} else {
this.commentList = this.commentList.concat(comments);
if (pre) {
this.commentPreList.unshift(comments);
this.$nextTick(() => {
this.loadPreComment();
});
} else {
if (this.page <= 2) {
this.commentList = comments;
// 将评论滚动到可视区域
if (this.commentId) {
setTimeout(() => {
let scrollHeight = this.$refs.scroll.$el.offsetHeight;
let dom = this.$refs.commentList.getElementsByClassName('comment-' + this.commentId);
if (scrollHeight && dom.length && (dom[0].offsetHeight + dom[0].offsetTop > scrollHeight)) {
this.$refs.scroll.scrollTo(0, scrollHeight - this.$refs.commentList.offsetHeight);
}
}, 500);
}
} else {
this.commentList = this.commentList.concat(comments);
}
dirty = true;
}
} else {
dirty = false;
}
this.firstLoading = false;
... ...
... ... @@ -89,6 +89,10 @@ export default {
},
methods: {
onClick(e) {
if (this.share) {
return this.$links.toDownloadApp();
}
if (e.timeStamp - this._lastTime < 1200) {
return;
}
... ...
<template>
<ArticleDetail :share="true" :set-share-data="setShareData"></ArticleDetail>
</template>
<script>
import Share from 'plugins/share';
import {getDetailShareData} from 'utils/share-handler';
import ArticleDetail from './article-detail';
export default {
name: 'ArticleDetailShare',
mounted() {
if (!this.$yoho.isApp) {
Share.init();
}
},
methods: {
setShareData(article) {
if (!article) {
return;
}
let shareData = getDetailShareData(article);
document && (document.title = shareData.title);
if (!this.$yoho.isApp) {
Share.setShareInfo(shareData);
}
}
},
components: {
ArticleDetail
}
};
</script>
<style lang="scss" scoped>
/deep/ {
.article-detail-header {
display: none;
}
}
</style>
... ...
... ... @@ -2,8 +2,30 @@
<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="articleInfo.sort == 2" ref="detailLong" :data="articleInfo" :scroll-top="scrollTop" :list-title="listTitle" :scroll-to="scrollTo" :pos-id="posId" @on-show-more="onShowMore" @on-follow="onFollowAuthor"></ArticleDeatilLong>
<ArticleDeatilNote v-else ref="detailNote" :data="articleInfo" :scroll-top="scrollTop" :list-title="listTitle" :scroll-to="scrollTo" :pos-id="posId" @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"
:share="share"
:pos-id="posId"
@on-show-more="onShowMore"
@on-follow="onFollowAuthor">
</ArticleDeatilLong>
<ArticleDeatilNote
v-else
ref="detailNote"
:data="articleInfo"
:scroll-top="scrollTop"
:list-title="listTitle"
:scroll-to="scrollTo"
:share="share"
:pos-id="posId"
@on-show-more="onShowMore"
@on-follow="onFollowAuthor">
</ArticleDeatilNote>
</template>
<template class="article-item" #item="{ data }">
<ArticleItem2
... ... @@ -38,12 +60,15 @@ const {mapState, mapActions, mapMutations} = createNamespacedHelpers('article');
export default {
name: 'ArticleDetailPage',
props: {
share: Boolean,
setShareData: Function
},
data() {
return {
id: 0,
scrollTop: 0,
scrolling: false,
share: false,
listTitle: '',
colWidthForTwo: 370,
posId: YAS.scene.newsDetail
... ... @@ -119,9 +144,13 @@ export default {
if (this.$refs.scroll) {
this.listTitle = '';
this.$nextTick(() => {
setTimeout(() => {
this.$refs.scroll.init();
});
}, 500);
}
if (this.share && this.setShareData) {
this.setShareData(get(res, 'data.detailList[0]', this.articleInfo));
}
});
},
... ...
... ... @@ -150,6 +150,10 @@ export default {
},
async praiseArticle(e) {
if (e.timeStamp - this._preTimeStamp < dblclickDdelay) {
if (this.share) {
return this.$links.toDownloadApp();
}
const user = await this.$sdk.getUser();
if (user && user.uid) {
... ...
... ... @@ -14,7 +14,7 @@
<span class="name">{{data.authorName}}</span>
</div>
<div class="fav">
<WidgetFav :articleId="data.articleId" :num="data.praiseCount" :option="favOption"></WidgetFav>
<WidgetFav :articleId="data.articleId" :num="data.praiseCount" :share="share" :option="favOption"></WidgetFav>
</div>
</div>
</div>
... ... @@ -78,8 +78,10 @@ export default {
return get(get(this.data, 'blockList', []).filter(block => block.templateKey === 'text'), '[0].contentData', this.data.content);
},
actionUrl() {
if (this.data.sort === 3) {
return this.data.actionUrl;
if (!this.share) {
if (this.data.sort === 3) {
return this.data.actionUrl;
}
}
return '';
... ... @@ -94,12 +96,6 @@ export default {
}
},
methods: {
onFollow(follow) {
this.$emit('on-follow', follow);
},
onPraise() {
this.$refs.articleIntro.onPraise();
},
toUserPage() {
if (this.share) {
return this.$links.toDownloadApp();
... ...
... ... @@ -2,9 +2,9 @@
<div class="article-footer-wrapper">
<slot name="before"></slot>
<div class="tool-bar">
<WidgetIconBtn ref="favIcon" class="item" type="fav" :pos-id="sceneId" :text="praiseCount" :articleId="articleId" :option="optionPraise"></WidgetIconBtn>
<WidgetIconBtn class="item" type="star" :pos-id="sceneId" :text="favoriteCount" :articleId="articleId" :option="optionFav" ></WidgetIconBtn>
<WidgetIconBtn class="item" type="msg" :text="commentCount" :option="optionComment" @click="onComment"></WidgetIconBtn>
<WidgetIconBtn ref="favIcon" class="item" type="fav" :pos-id="sceneId" :text="praiseCount" :articleId="articleId" :option="optionPraise" :share="share"></WidgetIconBtn>
<WidgetIconBtn class="item" type="star" :pos-id="sceneId" :text="favoriteCount" :articleId="articleId" :option="optionFav" :share="share"></WidgetIconBtn>
<WidgetIconBtn class="item" type="msg" :text="commentCount" :option="optionComment" :share="share" @click="onComment"></WidgetIconBtn>
</div>
<slot name="after">
<div class="close ml20" @click="onClose">收起</div>
... ... @@ -18,7 +18,7 @@ import YAS from 'utils/yas-constants';
export default {
name: 'ArticleFooter',
props: ['favoriteCount', 'praiseCount', 'commentCount', 'hasFavor', 'hasPraise', 'articleId'],
props: ['favoriteCount', 'praiseCount', 'commentCount', 'hasFavor', 'hasPraise', 'articleId', 'share'],
data() {
return {
optionComment: {
... ...
<template>
<div class="article-detail-long">
<ArticleDetailHeader ref="header" :data="data" :step="headerAnimateStep" :title-step="headerTitleAnimateStep">
<ArticleDetailHeader ref="header" class="article-detail-header" :data="data" :step="headerAnimateStep" :title-step="headerTitleAnimateStep">
<div v-if="data.articleId && !data.empty" class="title-main">
<div class="title-info" :style="`transform: translate3d(0, ${viewMoreArticles ? '-50%' : '0'}, 0)`">
<ArticleItemHeader class="title-info-author" :share="share" :data="authorData" :lazy="lazy" :more="showMoreOpt" @on-follow="onFollowAuthor"></ArticleItemHeader>
... ... @@ -24,7 +24,7 @@
<div v-if="recomendProduct.length">
<LayoutTitle class="rec-goods-title">推荐商品</LayoutTitle>
<ProductGroup :data="recomendProduct" model="2"></ProductGroup>
<ProductGroup :data="recomendProduct" :share="share" model="2"></ProductGroup>
</div>
<LayoutTitle v-if="listTitle" class="rec-article-title">{{listTitle}}</LayoutTitle>
... ... @@ -42,6 +42,7 @@
:popup="true"
:article-id="data.articleId"
:commentCount="articleState.commentCount"
:share="share"
:pos-id="posId"
@on-close="onCloseComment"
@on-comment="onActionComment"></Comment>
... ... @@ -203,7 +204,8 @@ export default {
commentCount: this.articleState.commentCount,
hasFavor: this.articleState.hasFavor,
hasPraise: this.articleState.hasPraise,
articleId: this.data.articleId
articleId: this.data.articleId,
share: this.share
};
},
lazy() {
... ...
<template>
<div class="article-detail-notes">
<ArticleDetailHeader ref="header" :data="data" :step="100" :title-step="100">
<ArticleDetailHeader ref="header" class="article-detail-header" :data="data" :step="100" :title-step="100">
<div v-if="data.articleId && !data.empty" class="title-main">
<div class="title-info" :style="`transform: translate3d(0, ${viewMoreArticles ? '-50%' : '0'}, 0)`">
<ArticleItemHeader class="title-info-author" :share="share" :data="authorData" :lazy="lazy" :more="false" @on-follow="onFollowAuthor"></ArticleItemHeader>
... ... @@ -9,7 +9,9 @@
</div>
</ArticleDetailHeader>
<LayoutHeader style="visibility: hidden;"></LayoutHeader>
<ArticleItemHeader v-if="share" :share="share" :data="authorData" :lazy="lazy" :more="false" @on-follow="onFollowAuthor"></ArticleItemHeader>
<LayoutHeader v-else style="visibility: hidden;"></LayoutHeader>
<div v-if="data.empty" class="article-empty">
{{data.emptyTip || '文章不存在或文章被删除'}}
</div>
... ... @@ -22,11 +24,11 @@
<div class="publish-time">
<span>{{publishTime}}</span>
<div v-if="data.articleId" class="more-wrap">
<div v-if="data.articleId && !share" class="more-wrap">
<i class="iconfont icon-more1" @click="onMore"></i>
</div>
</div>
<ArticleDetailCommentList ref="commentList" v-if="data.articleId && !thumb" :article-id="data.articleId" :comment-count="articleState.commentCount"></ArticleDetailCommentList>
<ArticleDetailCommentList ref="commentList" v-if="data.articleId && !thumb" :article-id="data.articleId" :share="share" :comment-count="articleState.commentCount"></ArticleDetailCommentList>
</div>
<div v-if="listTitle" class="rec-article-title">
... ... @@ -156,7 +158,8 @@ export default {
commentCount: this.articleState.commentCount,
hasFavor: this.articleState.hasFavor,
hasPraise: this.articleState.hasPraise,
articleId: this.data.articleId
articleId: this.data.articleId,
share: this.share
};
},
publishTime() {
... ...
... ... @@ -11,6 +11,7 @@
:parent-comment="comment.parentComment"
:children-comments="comment.childrenComments"
:column-type="columnType"
:share="share"
:pos-id="0"
:article-id="articleId"
@on-reply="onReply">
... ...
... ... @@ -7,18 +7,26 @@ export default [{
keepAlive: true
}
},{
path: '/article/share/:id',
name: 'article.share',
alias: '/article/share/:id',
component: () => import(/* webpackChunkName: "article" */ './article-detail-share'),
meta: {
keepAlive: true
}
}, {
path: '/article/list/:id',
name: 'article.list',
name: 'articlelist',
alias: '/article/list/:id',
component: () => import(/* webpackChunkName: "article" */ './article'),
component: () => import(/* webpackChunkName: "article-list" */ './article'),
meta: {
keepAlive: true
}
}, {
path: '/article/share/:id',
name: 'article.share',
alias: '/article/share/:id',
component: () => import(/* webpackChunkName: "article" */ './article-share'),
path: '/article/list/share/:id',
name: 'articlelist.share',
alias: '/article/list/share/:id',
component: () => import(/* webpackChunkName: "article-list" */ './article-share'),
meta: {
keepAlive: true
}
... ... @@ -26,7 +34,7 @@ export default [{
path: '/article/detail/:id',
name: 'article.detail',
alias: '/article/detail/:id',
component: () => import(/* webpackChunkName: "article-detail" */ './article-detail'),
component: () => import(/* webpackChunkName: "article" */ './article-detail'),
meta: {
keepAlive: true
}
... ... @@ -34,7 +42,7 @@ export default [{
path: '/article/:id/user/:type/:authorType/:authorUid',
name: 'article.user',
alias: '/article/:id/user/:type/:authorType/:authorUid',
component: () => import(/* webpackChunkName: "article" */ './user-article'),
component: () => import(/* webpackChunkName: "article-list" */ './user-article'),
meta: {
keepAlive: true
}
... ... @@ -42,7 +50,7 @@ export default [{
path: '/topic/share/:topicId',
alias: '/topic/share/:topicId',
name: 'topic.share',
component: () => import(/* webpackChunkName: "article" */ './topic'),
component: () => import(/* webpackChunkName: "topic" */ './topic'),
meta: {
keepAlive: true
}
... ... @@ -50,7 +58,7 @@ export default [{
path: '/topic/:topicId',
alias: '/topic/:topicId',
name: 'topic',
component: () => import(/* webpackChunkName: "article" */ './topic'),
component: () => import(/* webpackChunkName: "topic" */ './topic'),
meta: {
keepAlive: true,
statusBarColor: 'white'
... ...