Authored by 杨延青

Merge branch 'hotfix/share' into 'feature/0715'

Hotfix/share



See merge request !108
... ... @@ -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', {
... ...
... ... @@ -69,6 +69,8 @@
<script>
import {assign, get} from 'lodash';
import Share from 'plugins/share';
import {getAuthorShareData} from 'utils/share-handler';
import {Scroll, Loading} from 'cube-ui';
import FavTabBlock from './fav-tab-block';
import WaterFall from './scroll-reveal';
... ... @@ -306,6 +308,7 @@ export default {
data.showAvatar = true;
this.authorBaseData = data;
this.isOwner = +data.userType === 1;
this.setShareInfo({...data, ...this.authorInfo});
});
this[this._apiNamePre + 'AritcleNum'](this.authorInfo).then(res => {
... ... @@ -421,6 +424,13 @@ export default {
});
}
},
setShareInfo(author) {
if (this.$yoho.isApp || !author) {
return;
}
Share.setShareInfo(getAuthorShareData(author));
},
toDownloadPage() {
!this.publishUrl && this.$links.toDownloadApp();
},
... ...
let shareData = {
title: '',
title: '来YO!社区,一起玩潮流!',
link: '',
desc: '',
desc: 'Yoho!buy有货App',
imgUrl: 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png'
};
... ... @@ -14,12 +14,13 @@ let jsApiList = [
'onMenuShareQZone'
];
const setWxShareData = function() {
window.wx.onMenuShareTimeline(shareData);
window.wx.onMenuShareAppMessage(shareData);
window.wx.onMenuShareQQ(shareData);
window.wx.onMenuShareQZone(shareData);
window.wx.onMenuShareWeibo(shareData);
const setWxShareData = function(shareInfo) {
shareInfo = shareInfo || shareData;
window.wx.onMenuShareTimeline(shareInfo);
window.wx.onMenuShareAppMessage(shareInfo);
window.wx.onMenuShareQQ(shareInfo);
window.wx.onMenuShareQZone(shareInfo);
window.wx.onMenuShareWeibo(shareInfo);
};
function loadScript(url, success) {
... ... @@ -114,20 +115,21 @@ 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(() => {
let shareInfo = Object.assign({}, shareData, data || {});
if (window.wx) {
setWxShareData();
}
shareInfo.link = shareInfo.link || location.href;
window.setShareInfo && window.setShareInfo({
title: shareData.title,
summary: shareData.desc,
pic: shareData.imgUrl,
url: shareData.link
});
if (window.wx) {
setWxShareData(shareInfo);
}
window.setShareInfo && window.setShareInfo({
title: shareInfo.title,
summary: shareInfo.desc,
pic: shareInfo.imgUrl,
url: shareInfo.link
});
}, 100);
}
};
... ...
... ... @@ -50,7 +50,18 @@ const getTopicShareData = (topic) => {
};
};
const getAuthorShareData = (author) => {
return {
title: `@${author.nickName} YO!社区,一起来玩潮流!`,
imgUrl: handleProtocol(get(author, 'headIco', '').split('?')[0] || DEFAULT_SHARE_IMAGE),
link: handleProtocol(`${location.origin}/grass/author/${author.authorType}/${author.authorUid}`),
desc: author.signature || '',
hideType: ['7', '8', '9']
};
};
export {
getDetailShareData,
getTopicShareData
getTopicShareData,
getAuthorShareData
};
... ...