Showing
1 changed file
with
26 additions
and
10 deletions
@@ -22,6 +22,30 @@ let shareData = { | @@ -22,6 +22,30 @@ let shareData = { | ||
22 | imgUrl: 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png' | 22 | imgUrl: 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png' |
23 | }; | 23 | }; |
24 | 24 | ||
25 | +const getShareData = function(shareType) { | ||
26 | + let data = { | ||
27 | + success: function() { | ||
28 | + window._yas.sendCustomInfo && window._yas.sendCustomInfo({ | ||
29 | + op: 'YB_SHARE_SUCCESS_L', | ||
30 | + param: JSON.stringify({ | ||
31 | + SHARE_TYPE: shareType, | ||
32 | + SHARE_URL: location.href | ||
33 | + }) | ||
34 | + }, true); | ||
35 | + } | ||
36 | + }; | ||
37 | + | ||
38 | + return Object.assign(data, shareData); | ||
39 | +}; | ||
40 | + | ||
41 | +const setShareData = function() { | ||
42 | + window.wx.onMenuShareAppMessage(getShareData('1')); | ||
43 | + window.wx.onMenuShareTimeline(getShareData('2')); | ||
44 | + window.wx.onMenuShareWeibo(getShareData('3')); | ||
45 | + window.wx.onMenuShareQQ(getShareData('4')); | ||
46 | + window.wx.onMenuShareQZone(getShareData('5')); | ||
47 | +}; | ||
48 | + | ||
25 | if (/QQ/i.test(navigator.userAgent)) { | 49 | if (/QQ/i.test(navigator.userAgent)) { |
26 | $.ajax({ | 50 | $.ajax({ |
27 | url: '//qzonestyle.gtimg.cn/qzone/qzact/common/share/share.js', | 51 | url: '//qzonestyle.gtimg.cn/qzone/qzact/common/share/share.js', |
@@ -60,11 +84,7 @@ if (/MicroMessenger/i.test(navigator.userAgent)) { | @@ -60,11 +84,7 @@ if (/MicroMessenger/i.test(navigator.userAgent)) { | ||
60 | jsApiList: jsApiList | 84 | jsApiList: jsApiList |
61 | }); | 85 | }); |
62 | window.wx.ready(function() { | 86 | window.wx.ready(function() { |
63 | - window.wx.onMenuShareAppMessage(shareData); | ||
64 | - window.wx.onMenuShareTimeline(shareData); | ||
65 | - window.wx.onMenuShareQQ(shareData); | ||
66 | - window.wx.onMenuShareWeibo(shareData); | ||
67 | - window.wx.onMenuShareQZone(shareData); | 87 | + setShareData(); |
68 | }); | 88 | }); |
69 | } | 89 | } |
70 | } | 90 | } |
@@ -95,11 +115,7 @@ module.exports = function(data) { | @@ -95,11 +115,7 @@ module.exports = function(data) { | ||
95 | shareData = data; | 115 | shareData = data; |
96 | 116 | ||
97 | if (window.wx) { | 117 | if (window.wx) { |
98 | - window.wx.onMenuShareAppMessage(shareData); | ||
99 | - window.wx.onMenuShareTimeline(shareData); | ||
100 | - window.wx.onMenuShareQQ(shareData); | ||
101 | - window.wx.onMenuShareWeibo(shareData); | ||
102 | - window.wx.onMenuShareQZone(shareData); | 118 | + setShareData(); |
103 | } | 119 | } |
104 | 120 | ||
105 | window.setShareInfo && window.setShareInfo({ | 121 | window.setShareInfo && window.setShareInfo({ |
-
Please register or login to post a comment