Authored by yyq

fix share

... ... @@ -11,6 +11,7 @@
</template>
<script>
import Share from 'plugins/share';
import {get, find} from 'lodash';
import {mapState, mapMutations} from 'vuex';
... ... @@ -35,7 +36,6 @@ export default {
});
});
const barColor = get(this.$route, 'meta.statusBarColor');
if (barColor) {
... ... @@ -71,6 +71,10 @@ export default {
});
}
if (!this.$yoho.isApp) {
Share.init();
}
this.reportEnter();
},
methods: {
... ...
... ... @@ -82,6 +82,8 @@
<script>
import {get} from 'lodash';
import Share from 'plugins/share';
import {getDetailShareData} from 'utils/share-handler';
import YAS from 'utils/yas-constants';
import ArticleDetailHeader from './components/detail/article-header';
... ... @@ -97,8 +99,7 @@ const {mapState, mapActions, mapMutations} = createNamespacedHelpers('article');
export default {
name: 'ArticleDetailPage',
props: {
share: Boolean,
setShareData: Function
share: Boolean
},
data() {
return {
... ... @@ -124,6 +125,7 @@ export default {
this.id = +this.$route.params.id;
this.init();
} else {
this.setShareData(this.articleInfo);
this.reportProductShow(this.articleInfo);
}
this.$yoho.safetyInterface(() => {
... ... @@ -286,9 +288,8 @@ export default {
const article = get(res, 'data.detailList[0]', this.articleInfo);
this.reportProductShow(article);
if (this.share && this.setShareData) {
this.setShareData(article);
}
this.setShareData(article);
});
},
async onFetch() {
... ... @@ -367,6 +368,13 @@ export default {
this.$refs.detailNote.onComment(comment);
}
},
setShareData(article) {
if (this.$yoho.isApp || !article) {
return;
}
Share.setShareInfo(getDetailShareData(article));
},
reportArticleShow(items) {
if (!items || !items.length) {
return;
... ...
... ... @@ -42,6 +42,7 @@
<script>
import {throttle, get} from 'lodash';
import Share from 'plugins/share';
import {getTopicShareData} from 'utils/share-handler';
import YAS from 'utils/yas-constants';
import ArticleItem2 from './components/article/article-item2';
import TopicHeader from './components/topic/header';
... ... @@ -96,6 +97,8 @@ export default {
this.topicName = this.$route.params.topicName;
this.reload = true;
this.init();
} else {
this.setPageShareInfo(this.topicSimpleInfo);
}
},
mounted() {
... ... @@ -291,18 +294,12 @@ export default {
toDownloadPage() {
!this.publishUrl && this.$links.toDownloadApp();
},
setPageShareInfo({topicName, topicImageUrl, topicDesc}) {
if (this.share) {
document && (document.title = topicName || '话题');
if (!this.$yoho.isApp) {
Share.setShareInfo({
title: topicName,
imgUrl: topicImageUrl,
desc: '我在有货的社区发现一个热门话题。' + topicDesc,
});
}
setPageShareInfo(topic) {
if (this.$yoho.isApp || !topic) {
return;
}
Share.setShareInfo(getTopicShareData(topic));
},
reportTopicFollow() {
this.$store.dispatch('reportYas', {
... ...
let shareData = {
title: '',
title: '有货社区',
link: '',
desc: '',
desc: '',
imgUrl: 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png'
};
... ... @@ -114,20 +114,22 @@ function init(qs) {
export default {
init,
setShareInfo(data) {
shareData.title = data.title;
shareData.desc = data.desc || '逛';
shareData.link = data.link || location.href;
shareData.imgUrl = data.imgUrl || shareData.imgUrl;
setTimeout(() => {
shareData.title = data.title || document.title || '有货社区';
shareData.desc = data.desc || document.description || '';
shareData.link = data.link || location.href;
shareData.imgUrl = data.imgUrl || shareData.imgUrl;
if (window.wx) {
setWxShareData();
}
if (window.wx) {
setWxShareData();
}
window.setShareInfo && window.setShareInfo({
title: shareData.title,
summary: shareData.desc,
pic: shareData.imgUrl,
url: shareData.link
});
window.setShareInfo && window.setShareInfo({
title: shareData.title,
summary: shareData.desc,
pic: shareData.imgUrl,
url: shareData.link
});
}, 100);
}
};
... ...