Authored by 张丽霞

二次分享

@@ -10,7 +10,10 @@ const sign = require(`${library}/sign`); @@ -10,7 +10,10 @@ const sign = require(`${library}/sign`);
10 */ 10 */
11 const getPageInfo = (pageInfo) => { 11 const getPageInfo = (pageInfo) => {
12 var dest = {}; 12 var dest = {};
13 - dest.pageInfo = pageInfo; 13 + dest.shareTitle = pageInfo.data.shareTitle;
  14 + dest.shareDesc = pageInfo.data.shareContent;
  15 + dest.shareImg = pageInfo.data.shareImgUrl;
  16 + dest.shareLink = pageInfo.data.shareUrl;
14 dest.code = pageInfo.code; 17 dest.code = pageInfo.code;
15 dest.activityID = pageInfo.id; 18 dest.activityID = pageInfo.id;
16 dest.title = pageInfo.data.h5Title; 19 dest.title = pageInfo.data.h5Title;
@@ -10,7 +10,11 @@ @@ -10,7 +10,11 @@
10 <p class="hidden" id="newUser">{{newUser}}</p> 10 <p class="hidden" id="newUser">{{newUser}}</p>
11 <p class="hidden" id="tipMessage">{{message}}</p> 11 <p class="hidden" id="tipMessage">{{message}}</p>
12 <p class="hidden" id="activityID">{{activityID}}</p> 12 <p class="hidden" id="activityID">{{activityID}}</p>
13 - <p class="hidden" id="pageInfo">{{pageInfo}}</p> 13 + <input type="hidden" id="shareTitle" value="{{shareTitle}}">
  14 + <input type="hidden" id="shareDesc" value="{{shareDesc}}">
  15 + <input type="hidden" id="shareImg" value="{{shareImg}}">
  16 + <input type="hidden" id="shareLink" value="{{shareLink}}">
  17 +
14 <div class="page"> 18 <div class="page">
15 <div class="gain-coupon-centent hidden"> 19 <div class="gain-coupon-centent hidden">
16 <div class="coupon"> 20 <div class="coupon">
@@ -9,11 +9,11 @@ var $ = require('yoho-jquery'), @@ -9,11 +9,11 @@ var $ = require('yoho-jquery'),
9 activityID = $('#activityID').html(), 9 activityID = $('#activityID').html(),
10 pageInfo = $('#pageInfo').html(), 10 pageInfo = $('#pageInfo').html(),
11 _weChatInterface = 'http://www.yohoshow.com/api/wechat/getSignPackage', 11 _weChatInterface = 'http://www.yohoshow.com/api/wechat/getSignPackage',
12 - shareTitle = pageInfo.shareTitle,  
13 - shareImg = pageInfo.shareImg,  
14 - shareDesc = pageInfo.shareDesc,  
15 - shareLink = pageInfo.shareUrl;  
16 -var wx = window.wx; 12 + shareTitle = $('#shareTitle').val(),
  13 + shareImg = $('#shareImg').val(),
  14 + shareDesc = $('#shareDesc').val(),
  15 + shareLink = $('#shareLink').val(),
  16 + wx = window.wx;
17 17
18 $('#phone').bind('input propertychange', function() { 18 $('#phone').bind('input propertychange', function() {
19 if ($(this).val().length === 11) { 19 if ($(this).val().length === 11) {
@@ -52,15 +52,13 @@ if (!$('#newUser').html()) { @@ -52,15 +52,13 @@ if (!$('#newUser').html()) {
52 /** 52 /**
53 * 微信分享 53 * 微信分享
54 */ 54 */
55 -(function() {  
56 - if (typeof(wx) === 'undefined') {  
57 - return;  
58 - }  
59 - 55 +if (typeof wx !== 'undefined') {
60 $.getJSON(_weChatInterface + '?pageurl=' + 56 $.getJSON(_weChatInterface + '?pageurl=' +
61 - encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function(json) { 57 + encodeURIComponent(location.href.split('#')[0]) + '&callback=?',
  58 + function(json) {
62 var _appId, _timestamp, _nonceStr, _signature; 59 var _appId, _timestamp, _nonceStr, _signature;
63 - if (json !== undefined && json !== '') { 60 +
  61 + if (json) {
64 _appId = json.appId.toString(); 62 _appId = json.appId.toString();
65 _timestamp = json.timestamp; 63 _timestamp = json.timestamp;
66 _nonceStr = json.nonceStr.toString(); 64 _nonceStr = json.nonceStr.toString();
@@ -111,20 +109,28 @@ if (!$('#newUser').html()) { @@ -111,20 +109,28 @@ if (!$('#newUser').html()) {
111 }); 109 });
112 } 110 }
113 }); 111 });
114 - wx.ready(function() {  
115 112
  113 + wx.ready(function() {
116 var shareData = { 114 var shareData = {
117 title: shareTitle, 115 title: shareTitle,
118 desc: shareDesc, 116 desc: shareDesc,
119 imgUrl: shareImg, 117 imgUrl: shareImg,
120 link: shareLink 118 link: shareLink
121 }; 119 };
  120 +
  121 + // 分享给朋友
122 wx.onMenuShareAppMessage(shareData); 122 wx.onMenuShareAppMessage(shareData);
  123 +
  124 + // 分享到朋友圈
123 wx.onMenuShareTimeline(shareData); 125 wx.onMenuShareTimeline(shareData);
  126 +
  127 + // 分享到QQ
124 wx.onMenuShareQQ(shareData); 128 wx.onMenuShareQQ(shareData);
  129 +
  130 + // 分享到微博
125 wx.onMenuShareWeibo(shareData); 131 wx.onMenuShareWeibo(shareData);
126 }); 132 });
127 -}()); 133 +}
128 134
129 $('.input-content div').on('click', function() { 135 $('.input-content div').on('click', function() {
130 phone = $(this).siblings('input').val(); 136 phone = $(this).siblings('input').val();