|
|
let shareData = {
|
|
|
let baseShareData = {
|
|
|
title: '来YO!社区,一起玩潮流!',
|
|
|
link: '',
|
|
|
desc: 'Yoho!buy有货App',
|
|
|
imgUrl: 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png'
|
|
|
};
|
|
|
|
|
|
let shareData = {...baseShareData};
|
|
|
|
|
|
let jsApiList = [
|
|
|
'checkJsApi',
|
|
|
'onMenuShareTimeline',
|
...
|
...
|
@@ -14,13 +16,12 @@ let jsApiList = [ |
|
|
'onMenuShareQZone'
|
|
|
];
|
|
|
|
|
|
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);
|
|
|
const setWxShareData = function() {
|
|
|
window.wx.onMenuShareTimeline(shareData);
|
|
|
window.wx.onMenuShareAppMessage(shareData);
|
|
|
window.wx.onMenuShareQQ(shareData);
|
|
|
window.wx.onMenuShareQZone(shareData);
|
|
|
window.wx.onMenuShareWeibo(shareData);
|
|
|
};
|
|
|
|
|
|
function loadScript(url, success) {
|
...
|
...
|
@@ -117,21 +118,19 @@ function init(qs) { |
|
|
export default {
|
|
|
init,
|
|
|
setShareInfo(data) {
|
|
|
setTimeout(() => {
|
|
|
let shareInfo = Object.assign({}, shareData, data || {});
|
|
|
shareData = Object.assign({}, baseShareData, data || {});
|
|
|
|
|
|
shareInfo.link = shareInfo.link || location.href;
|
|
|
shareData.link = shareData.link || location.href;
|
|
|
|
|
|
if (window.wx) {
|
|
|
setWxShareData(shareInfo);
|
|
|
setWxShareData();
|
|
|
}
|
|
|
|
|
|
window.setShareInfo && window.setShareInfo({
|
|
|
title: shareInfo.title,
|
|
|
summary: shareInfo.desc,
|
|
|
pic: shareInfo.imgUrl,
|
|
|
url: shareInfo.link
|
|
|
title: shareData.title,
|
|
|
summary: shareData.desc,
|
|
|
pic: shareData.imgUrl,
|
|
|
url: shareData.link
|
|
|
});
|
|
|
}, 100);
|
|
|
}
|
|
|
}; |
...
|
...
|
|