Authored by shuaiguo

Merge branch 'feature/long-article-save-image' into 'develop'

长按保存图片以及长文章开启评论



See merge request !126
@@ -58,7 +58,7 @@ @@ -58,7 +58,7 @@
58 <DownloadBottom v-if="share" :class="{'scroll-opacity': scrolling}"></DownloadBottom> 58 <DownloadBottom v-if="share" :class="{'scroll-opacity': scrolling}"></DownloadBottom>
59 59
60 <ArticleDetailFooter ref="footer" class="detail-fixed-footer" :style="`transform: translate3d(0, ${viewMoreArticles ? '100%' : '0'}, 0)`" v-bind="footerData" @on-comment-click="onComment"> 60 <ArticleDetailFooter ref="footer" class="detail-fixed-footer" :style="`transform: translate3d(0, ${viewMoreArticles ? '100%' : '0'}, 0)`" v-bind="footerData" @on-comment-click="onComment">
61 - <template v-if="articleInfo.sort != 2" v-slot:before> 61 + <template v-if="articleInfo.sort" v-slot:before>
62 <div class="footer-comment"> 62 <div class="footer-comment">
63 <CommentPlaceholder 63 <CommentPlaceholder
64 ref="commentInput" 64 ref="commentInput"
@@ -388,6 +388,9 @@ export default { @@ -388,6 +388,9 @@ export default {
388 if (get(this.$refs, 'detailNote.onComment')) { 388 if (get(this.$refs, 'detailNote.onComment')) {
389 this.$refs.detailNote.onComment(comment); 389 this.$refs.detailNote.onComment(comment);
390 } 390 }
  391 + if (get(this.$refs, 'detailLong.onComment')) {
  392 + this.$refs.detailLong.onComment(comment);
  393 + }
391 }, 394 },
392 setShareData(article) { 395 setShareData(article) {
393 if (this.$yoho.isApp || !article) { 396 if (this.$yoho.isApp || !article) {
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 <div class="article-context"> 13 <div class="article-context">
14 <div class="context-title">{{data.articleTitle}}</div> 14 <div class="context-title">{{data.articleTitle}}</div>
15 <ClientOnly> 15 <ClientOnly>
16 - <div ref="richTextWrapper" @touchstart="tStart" @touchend="tEnd" class="context-rich-text"> 16 + <div ref="richTextWrapper" class="context-rich-text">
17 <VRuntimeTemplate v-once ref="richText" :template="richText" :parent="{}" 17 <VRuntimeTemplate v-once ref="richText" :template="richText" :parent="{}"
18 :templateProps="{getNoteProduct}"></VRuntimeTemplate> 18 :templateProps="{getNoteProduct}"></VRuntimeTemplate>
19 </div> 19 </div>
@@ -62,6 +62,8 @@ const { mapState: mapArticleState, mapActions, mapGetters } = createNamespacedHe @@ -62,6 +62,8 @@ const { mapState: mapArticleState, mapActions, mapGetters } = createNamespacedHe
62 62
63 let timeOutEvent = null; 63 let timeOutEvent = null;
64 64
  65 +let isMoving = false;
  66 +
65 export default { 67 export default {
66 name: 'ArticleDetailLong', 68 name: 'ArticleDetailLong',
67 props: { 69 props: {
@@ -170,17 +172,27 @@ export default { @@ -170,17 +172,27 @@ export default {
170 ...mapMutations(['SET_STATUS_BAR_COLOR']), 172 ...mapMutations(['SET_STATUS_BAR_COLOR']),
171 ...mapActions(['fetchProductBySknList']), 173 ...mapActions(['fetchProductBySknList']),
172 tStart(e) { 174 tStart(e) {
173 - if (e.target.src) { 175 + isMoving = false;
  176 + if (e.currentTarget && e.currentTarget.dataset.src) {
  177 + let src = e.currentTarget.dataset.src;
  178 +
174 timeOutEvent = setTimeout(() => { 179 timeOutEvent = setTimeout(() => {
175 - this.$yoho.longClickSaveImage({ url: e.target.src });  
176 - }, 1000); 180 + if (!isMoving) {
  181 + this.$yoho.longClickSaveImage({ url: src });
  182 + }
  183 +
  184 + }, 500);
177 } 185 }
178 }, 186 },
179 tEnd() { 187 tEnd() {
  188 + isMoving = false;
180 if (timeOutEvent) { 189 if (timeOutEvent) {
181 clearTimeout(timeOutEvent); 190 clearTimeout(timeOutEvent);
182 } 191 }
183 }, 192 },
  193 + tMove() {
  194 + isMoving = true;
  195 + },
184 onFollowAuthor(follow) { 196 onFollowAuthor(follow) {
185 this.$emit('on-follow', this.data, follow); 197 this.$emit('on-follow', this.data, follow);
186 }, 198 },
@@ -240,6 +252,24 @@ export default { @@ -240,6 +252,24 @@ export default {
240 }); 252 });
241 } 253 }
242 254
  255 + // 处理长按图片下载
  256 + if (childNodes.length > 0) {
  257 + let childsImgs = richText.querySelectorAll('img');
  258 +
  259 + childsImgs.forEach((item) => {
  260 + if (item.parentNode && /P/i.test(item.parentNode.nodeName)) {
  261 + item.className += ' download-img';
  262 + item.parentNode.className += ' download-img-container';
  263 + if (item.src) {
  264 + item.parentNode.dataset.src = item.src;
  265 + item.parentNode.addEventListener('touchstart', vm.tStart);
  266 + item.parentNode.addEventListener('touchend', vm.tEnd);
  267 + item.parentNode.addEventListener('touchmove', vm.tMove);
  268 + }
  269 + }
  270 + });
  271 + }
  272 +
243 richText.querySelectorAll('a').forEach(ele => { 273 richText.querySelectorAll('a').forEach(ele => {
244 if (ele && ele.querySelector && ele.querySelector('img')) { 274 if (ele && ele.querySelector && ele.querySelector('img')) {
245 ele.classList.add('yoho-img-link'); 275 ele.classList.add('yoho-img-link');
@@ -417,6 +447,10 @@ export default { @@ -417,6 +447,10 @@ export default {
417 display: block; 447 display: block;
418 } 448 }
419 449
  450 + img.download-img {
  451 + pointer-events: none;
  452 + }
  453 +
420 p { 454 p {
421 font-size: 32px !important; 455 font-size: 32px !important;
422 456
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.