Showing
3 changed files
with
39 additions
and
18 deletions
@@ -69,6 +69,8 @@ | @@ -69,6 +69,8 @@ | ||
69 | 69 | ||
70 | <script> | 70 | <script> |
71 | import {assign, get} from 'lodash'; | 71 | import {assign, get} from 'lodash'; |
72 | +import Share from 'plugins/share'; | ||
73 | +import {getAuthorShareData} from 'utils/share-handler'; | ||
72 | import {Scroll, Loading} from 'cube-ui'; | 74 | import {Scroll, Loading} from 'cube-ui'; |
73 | import FavTabBlock from './fav-tab-block'; | 75 | import FavTabBlock from './fav-tab-block'; |
74 | import WaterFall from './scroll-reveal'; | 76 | import WaterFall from './scroll-reveal'; |
@@ -306,6 +308,7 @@ export default { | @@ -306,6 +308,7 @@ export default { | ||
306 | data.showAvatar = true; | 308 | data.showAvatar = true; |
307 | this.authorBaseData = data; | 309 | this.authorBaseData = data; |
308 | this.isOwner = +data.userType === 1; | 310 | this.isOwner = +data.userType === 1; |
311 | + this.setShareInfo({...data, ...this.authorInfo}); | ||
309 | }); | 312 | }); |
310 | 313 | ||
311 | this[this._apiNamePre + 'AritcleNum'](this.authorInfo).then(res => { | 314 | this[this._apiNamePre + 'AritcleNum'](this.authorInfo).then(res => { |
@@ -421,6 +424,13 @@ export default { | @@ -421,6 +424,13 @@ export default { | ||
421 | }); | 424 | }); |
422 | } | 425 | } |
423 | }, | 426 | }, |
427 | + setShareInfo(author) { | ||
428 | + if (this.$yoho.isApp || !author) { | ||
429 | + return; | ||
430 | + } | ||
431 | + | ||
432 | + Share.setShareInfo(getAuthorShareData(author)); | ||
433 | + }, | ||
424 | toDownloadPage() { | 434 | toDownloadPage() { |
425 | !this.publishUrl && this.$links.toDownloadApp(); | 435 | !this.publishUrl && this.$links.toDownloadApp(); |
426 | }, | 436 | }, |
1 | let shareData = { | 1 | let shareData = { |
2 | - title: '有货社区', | 2 | + title: '来YO!社区,一起玩潮流!', |
3 | link: '', | 3 | link: '', |
4 | - desc: '', | 4 | + desc: 'Yoho!buy有货App', |
5 | imgUrl: 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png' | 5 | imgUrl: 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png' |
6 | }; | 6 | }; |
7 | 7 | ||
@@ -14,12 +14,13 @@ let jsApiList = [ | @@ -14,12 +14,13 @@ let jsApiList = [ | ||
14 | 'onMenuShareQZone' | 14 | 'onMenuShareQZone' |
15 | ]; | 15 | ]; |
16 | 16 | ||
17 | -const setWxShareData = function() { | ||
18 | - window.wx.onMenuShareTimeline(shareData); | ||
19 | - window.wx.onMenuShareAppMessage(shareData); | ||
20 | - window.wx.onMenuShareQQ(shareData); | ||
21 | - window.wx.onMenuShareQZone(shareData); | ||
22 | - window.wx.onMenuShareWeibo(shareData); | 17 | +const setWxShareData = function(shareInfo) { |
18 | + shareInfo = shareInfo || shareData; | ||
19 | + window.wx.onMenuShareTimeline(shareInfo); | ||
20 | + window.wx.onMenuShareAppMessage(shareInfo); | ||
21 | + window.wx.onMenuShareQQ(shareInfo); | ||
22 | + window.wx.onMenuShareQZone(shareInfo); | ||
23 | + window.wx.onMenuShareWeibo(shareInfo); | ||
23 | }; | 24 | }; |
24 | 25 | ||
25 | function loadScript(url, success) { | 26 | function loadScript(url, success) { |
@@ -115,20 +116,19 @@ export default { | @@ -115,20 +116,19 @@ export default { | ||
115 | init, | 116 | init, |
116 | setShareInfo(data) { | 117 | setShareInfo(data) { |
117 | setTimeout(() => { | 118 | setTimeout(() => { |
118 | - shareData.title = data.title || document.title || '有货社区'; | ||
119 | - shareData.desc = data.desc || document.description || ''; | ||
120 | - shareData.link = data.link || location.href; | ||
121 | - shareData.imgUrl = data.imgUrl || shareData.imgUrl; | 119 | + let shareInfo = Object.assign({}, shareData, data || {}); |
120 | + | ||
121 | + shareInfo.link = shareInfo.link || location.href; | ||
122 | 122 | ||
123 | if (window.wx) { | 123 | if (window.wx) { |
124 | - setWxShareData(); | 124 | + setWxShareData(shareInfo); |
125 | } | 125 | } |
126 | 126 | ||
127 | window.setShareInfo && window.setShareInfo({ | 127 | window.setShareInfo && window.setShareInfo({ |
128 | - title: shareData.title, | ||
129 | - summary: shareData.desc, | ||
130 | - pic: shareData.imgUrl, | ||
131 | - url: shareData.link | 128 | + title: shareInfo.title, |
129 | + summary: shareInfo.desc, | ||
130 | + pic: shareInfo.imgUrl, | ||
131 | + url: shareInfo.link | ||
132 | }); | 132 | }); |
133 | }, 100); | 133 | }, 100); |
134 | } | 134 | } |
@@ -50,7 +50,18 @@ const getTopicShareData = (topic) => { | @@ -50,7 +50,18 @@ const getTopicShareData = (topic) => { | ||
50 | }; | 50 | }; |
51 | }; | 51 | }; |
52 | 52 | ||
53 | +const getAuthorShareData = (author) => { | ||
54 | + return { | ||
55 | + title: `@${author.nickName} 在YO!社区,一起来玩潮流!`, | ||
56 | + imgUrl: handleProtocol(get(author, 'headIco', '').split('?')[0] || DEFAULT_SHARE_IMAGE), | ||
57 | + link: handleProtocol(`${location.origin}/grass/author/${author.authorType}/${author.authorUid}`), | ||
58 | + desc: author.signature || '', | ||
59 | + hideType: ['7', '8', '9'] | ||
60 | + }; | ||
61 | +}; | ||
62 | + | ||
53 | export { | 63 | export { |
54 | getDetailShareData, | 64 | getDetailShareData, |
55 | - getTopicShareData | 65 | + getTopicShareData, |
66 | + getAuthorShareData | ||
56 | }; | 67 | }; |
-
Please register or login to post a comment