Authored by yyq

fix status

1 <template> 1 <template>
2 - <ArticleDetail :share="true"></ArticleDetail> 2 + <ArticleDetail :share="true" :set-share-data="setShareData"></ArticleDetail>
3 </template> 3 </template>
4 4
5 <script> 5 <script>
  6 +import Share from 'plugins/share';
  7 +import {getDetailShareData} from 'utils/share-handler';
6 import ArticleDetail from './article-detail'; 8 import ArticleDetail from './article-detail';
7 9
8 export default { 10 export default {
9 name: 'ArticleDetailShare', 11 name: 'ArticleDetailShare',
  12 + mounted() {
  13 + if (!this.$yoho.isApp) {
  14 + Share.init();
  15 + }
  16 + },
  17 + methods: {
  18 + setShareData(article) {
  19 + if (!article) {
  20 + return;
  21 + }
  22 +
  23 + let shareData = getDetailShareData(article);
  24 +
  25 + document && (document.title = shareData.title);
  26 +console.log(shareData);
  27 + if (!this.$yoho.isApp) {
  28 + Share.setShareInfo(shareData);
  29 + }
  30 + }
  31 + },
10 components: { 32 components: {
11 ArticleDetail 33 ArticleDetail
12 } 34 }
@@ -61,7 +61,8 @@ const {mapState, mapActions, mapMutations} = createNamespacedHelpers('article'); @@ -61,7 +61,8 @@ const {mapState, mapActions, mapMutations} = createNamespacedHelpers('article');
61 export default { 61 export default {
62 name: 'ArticleDetailPage', 62 name: 'ArticleDetailPage',
63 props: { 63 props: {
64 - share: Boolean 64 + share: Boolean,
  65 + setShareData: Function
65 }, 66 },
66 data() { 67 data() {
67 return { 68 return {
@@ -154,9 +155,13 @@ export default { @@ -154,9 +155,13 @@ export default {
154 if (this.$refs.scroll) { 155 if (this.$refs.scroll) {
155 this.listTitle = ''; 156 this.listTitle = '';
156 157
157 - this.$nextTick(() => { 158 + setTimeout(() => {
158 this.$refs.scroll.init(); 159 this.$refs.scroll.init();
159 - }); 160 + }, 500);
  161 + }
  162 +
  163 + if (this.share && this.setShareData) {
  164 + this.setShareData(get(res, 'data.detailList[0]'));
160 } 165 }
161 }); 166 });
162 }, 167 },