Showing
3 changed files
with
35 additions
and
13 deletions
@@ -2,8 +2,8 @@ | @@ -2,8 +2,8 @@ | ||
2 | <Layout class="article-detail"> | 2 | <Layout class="article-detail"> |
3 | <RecycleScrollReveal :size="10" ref="scroll" @scroll="onScroll" :offset="2000" :on-fetch="onFetch" :manual-init="true"> | 3 | <RecycleScrollReveal :size="10" ref="scroll" @scroll="onScroll" :offset="2000" :on-fetch="onFetch" :manual-init="true"> |
4 | <template v-slot:eternalTop> | 4 | <template v-slot:eternalTop> |
5 | - <ArticleDeatilLong v-if="article.sort == 2" ref="detailLong" :data="article" :scroll-top="scrollTop" :list-title="listTitle"></ArticleDeatilLong> | ||
6 | - <ArticleDeatilNote v-else :data="article" :scroll-top="scrollTop" :list-title="listTitle"></ArticleDeatilNote> | 5 | + <ArticleDeatilLong v-if="article.sort == 2" ref="detailLong" :data="article" :scroll-top="scrollTop" :list-title="listTitle" :scroll-to="scrollTo"></ArticleDeatilLong> |
6 | + <ArticleDeatilNote v-else :data="article" :scroll-top="scrollTop" :list-title="listTitle" :scroll-to="scrollTo"></ArticleDeatilNote> | ||
7 | </template> | 7 | </template> |
8 | <template class="article-item" #item="{ data }"> | 8 | <template class="article-item" #item="{ data }"> |
9 | <ArticleItem2 | 9 | <ArticleItem2 |
@@ -41,7 +41,7 @@ export default { | @@ -41,7 +41,7 @@ export default { | ||
41 | scrolling: false, | 41 | scrolling: false, |
42 | article: {}, | 42 | article: {}, |
43 | share: false, | 43 | share: false, |
44 | - listTitle: '推荐阅读', | 44 | + listTitle: '', |
45 | colWidthForTwo: 370, | 45 | colWidthForTwo: 370, |
46 | posId: 0 | 46 | posId: 0 |
47 | }; | 47 | }; |
@@ -91,6 +91,7 @@ export default { | @@ -91,6 +91,7 @@ export default { | ||
91 | if (this.$refs.scroll) { | 91 | if (this.$refs.scroll) { |
92 | this.$refs.scroll.$el.scrollTop = 0; | 92 | this.$refs.scroll.$el.scrollTop = 0; |
93 | this.$refs.scroll.clear(); | 93 | this.$refs.scroll.clear(); |
94 | + this.listTitle = ''; | ||
94 | 95 | ||
95 | this.$nextTick(() => { | 96 | this.$nextTick(() => { |
96 | this.$refs.scroll.init(); | 97 | this.$refs.scroll.init(); |
@@ -117,6 +118,7 @@ export default { | @@ -117,6 +118,7 @@ export default { | ||
117 | }); | 118 | }); |
118 | 119 | ||
119 | this.fetching = false; | 120 | this.fetching = false; |
121 | + this.recommendArticles[this.id] = true; | ||
120 | 122 | ||
121 | if (result.code === 200) { | 123 | if (result.code === 200) { |
122 | list = get(result, 'data', []); | 124 | list = get(result, 'data', []); |
@@ -124,7 +126,7 @@ export default { | @@ -124,7 +126,7 @@ export default { | ||
124 | if (!list || !list.length) { | 126 | if (!list || !list.length) { |
125 | list = false; | 127 | list = false; |
126 | } else { | 128 | } else { |
127 | - this.recommendArticles[this.id] = true; | 129 | + this.listTitle = '推荐阅读'; |
128 | } | 130 | } |
129 | } else { | 131 | } else { |
130 | this.$createToast && this.$createToast({ | 132 | this.$createToast && this.$createToast({ |
@@ -135,6 +137,10 @@ export default { | @@ -135,6 +137,10 @@ export default { | ||
135 | } | 137 | } |
136 | 138 | ||
137 | return list; | 139 | return list; |
140 | + }, | ||
141 | + scrollTo({scrollTop}) { | ||
142 | + this.$refs.scroll.$el.scrollTop = scrollTop; | ||
143 | + this.scrollTop = scrollTop; | ||
138 | } | 144 | } |
139 | }, | 145 | }, |
140 | components: { | 146 | components: { |
@@ -27,7 +27,7 @@ | @@ -27,7 +27,7 @@ | ||
27 | <ProductGroup :data="recomendProduct" model="2"></ProductGroup> | 27 | <ProductGroup :data="recomendProduct" model="2"></ProductGroup> |
28 | </div> | 28 | </div> |
29 | 29 | ||
30 | - <LayoutTitle class="rec-article-title">{{listTitle}}</LayoutTitle> | 30 | + <LayoutTitle v-if="listTitle" class="rec-article-title">{{listTitle}}</LayoutTitle> |
31 | </div> | 31 | </div> |
32 | <ArticleDetailFooter class="detail-fixed-footer" v-bind="footerData" @on-comment-click="onComment"> | 32 | <ArticleDetailFooter class="detail-fixed-footer" v-bind="footerData" @on-comment-click="onComment"> |
33 | <template v-slot:after> | 33 | <template v-slot:after> |
@@ -54,7 +54,7 @@ import ArticleItemHeader from '../article/article-item-header'; | @@ -54,7 +54,7 @@ import ArticleItemHeader from '../article/article-item-header'; | ||
54 | import ArticleItemTopics from '../article/article-item-topics'; | 54 | import ArticleItemTopics from '../article/article-item-topics'; |
55 | import ArticleDetailFooter from './article-footer'; | 55 | import ArticleDetailFooter from './article-footer'; |
56 | import ArticleDetailHeader from './article-header'; | 56 | import ArticleDetailHeader from './article-header'; |
57 | -import {mapState} from 'vuex'; | 57 | +import {mapState, mapMutations} from 'vuex'; |
58 | 58 | ||
59 | export default { | 59 | export default { |
60 | name: 'ArticleDetailLong', | 60 | name: 'ArticleDetailLong', |
@@ -67,7 +67,7 @@ export default { | @@ -67,7 +67,7 @@ export default { | ||
67 | }, | 67 | }, |
68 | listTitle: String, | 68 | listTitle: String, |
69 | scrollTop: Number, | 69 | scrollTop: Number, |
70 | - share: Boolean, | 70 | + share: Boolean |
71 | }, | 71 | }, |
72 | data() { | 72 | data() { |
73 | return { | 73 | return { |
@@ -131,7 +131,12 @@ export default { | @@ -131,7 +131,12 @@ export default { | ||
131 | } else if (this.scrollTop > 0) { | 131 | } else if (this.scrollTop > 0) { |
132 | let step = Math.round(this.scrollTop - 10 / (this.coverHeight - 10) * 100); | 132 | let step = Math.round(this.scrollTop - 10 / (this.coverHeight - 10) * 100); |
133 | 133 | ||
134 | - return Math.max(Math.min(step, 100), 0); | 134 | + step = Math.max(Math.min(step, 100), 0); |
135 | + this.SET_STATUS_BAR_COLOR({ | ||
136 | + color: step > 55 ? 'black' : 'white' | ||
137 | + }); | ||
138 | + | ||
139 | + return step; | ||
135 | } else { | 140 | } else { |
136 | return 0; | 141 | return 0; |
137 | } | 142 | } |
@@ -143,7 +148,7 @@ export default { | @@ -143,7 +148,7 @@ export default { | ||
143 | if (this.$refs && this.$refs.header) { | 148 | if (this.$refs && this.$refs.header) { |
144 | scrollTop += this.$refs.header.$el.offsetHeight; | 149 | scrollTop += this.$refs.header.$el.offsetHeight; |
145 | } | 150 | } |
146 | -console.log(scrollTop, top, height) | 151 | + |
147 | if (top && height) { | 152 | if (top && height) { |
148 | if (scrollTop >= top + height) { | 153 | if (scrollTop >= top + height) { |
149 | return 100; | 154 | return 100; |
@@ -191,6 +196,7 @@ console.log(scrollTop, top, height) | @@ -191,6 +196,7 @@ console.log(scrollTop, top, height) | ||
191 | } | 196 | } |
192 | }, | 197 | }, |
193 | methods: { | 198 | methods: { |
199 | + ...mapMutations(['SET_STATUS_BAR_COLOR']), | ||
194 | onClick() { | 200 | onClick() { |
195 | if (this.share) { | 201 | if (this.share) { |
196 | return this.$links.toDownloadApp(); | 202 | return this.$links.toDownloadApp(); |
@@ -17,10 +17,10 @@ | @@ -17,10 +17,10 @@ | ||
17 | <ArticleDetailIntro :data="introData"></ArticleDetailIntro> | 17 | <ArticleDetailIntro :data="introData"></ArticleDetailIntro> |
18 | <ArticleItemTopics class="topics-wrap" :data="topicsData" :share="share"></ArticleItemTopics> | 18 | <ArticleItemTopics class="topics-wrap" :data="topicsData" :share="share"></ArticleItemTopics> |
19 | <p class="publish-time">{{publishTime}}</p> | 19 | <p class="publish-time">{{publishTime}}</p> |
20 | - <ArticleDetailCommentList v-if="data.commentCount" :article-id="data.articleId" :comment-count="data.commentCount"></ArticleDetailCommentList> | ||
21 | - <LayoutTitle class="rec-article-title">{{listTitle}}</LayoutTitle> | 20 | + <ArticleDetailCommentList ref="commentList" v-if="data.commentCount" :article-id="data.articleId" :comment-count="data.commentCount"></ArticleDetailCommentList> |
21 | + <LayoutTitle v-if="listTitle" class="rec-article-title">{{listTitle}}</LayoutTitle> | ||
22 | </div> | 22 | </div> |
23 | - <ArticleDetailFooter class="detail-fixed-footer" v-bind="footerData" @on-comment-click="onComment"> | 23 | + <ArticleDetailFooter class="detail-fixed-footer" v-bind="footerData" @on-comment-click="toCommentList"> |
24 | <template v-slot:before> | 24 | <template v-slot:before> |
25 | <div class="footer-comment"> | 25 | <div class="footer-comment"> |
26 | <CommentPlaceholder | 26 | <CommentPlaceholder |
@@ -67,7 +67,8 @@ export default { | @@ -67,7 +67,8 @@ export default { | ||
67 | listTitle: String, | 67 | listTitle: String, |
68 | scrollTop: Number, | 68 | scrollTop: Number, |
69 | share: Boolean, | 69 | share: Boolean, |
70 | - thumb: Boolean | 70 | + thumb: Boolean, |
71 | + scrollTo: Function | ||
71 | }, | 72 | }, |
72 | data() { | 73 | data() { |
73 | return { | 74 | return { |
@@ -154,6 +155,15 @@ export default { | @@ -154,6 +155,15 @@ export default { | ||
154 | }, | 155 | }, |
155 | onComment() { | 156 | onComment() { |
156 | 157 | ||
158 | + }, | ||
159 | + toCommentList() { | ||
160 | + if (this.data.commentCount) { | ||
161 | + if (this.$refs.commentList && this.scrollTo) { | ||
162 | + this.scrollTo({scrollTop: this.$refs.commentList.$el.offsetTop}); | ||
163 | + } | ||
164 | + } else { | ||
165 | + this.$refs.commentInput.$el.click(); | ||
166 | + } | ||
157 | } | 167 | } |
158 | }, | 168 | }, |
159 | components: { | 169 | components: { |
-
Please register or login to post a comment