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,79 +52,85 @@ if (!$('#newUser').html()) { @@ -52,79 +52,85 @@ 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) {  
62 - var _appId, _timestamp, _nonceStr, _signature;  
63 - if (json !== undefined && json !== '') {  
64 - _appId = json.appId.toString();  
65 - _timestamp = json.timestamp;  
66 - _nonceStr = json.nonceStr.toString();  
67 - _signature = json.signature.toString(); 57 + encodeURIComponent(location.href.split('#')[0]) + '&callback=?',
  58 + function(json) {
  59 + var _appId, _timestamp, _nonceStr, _signature;
68 60
69 - wx.config({  
70 - debug: false,  
71 - appId: _appId,  
72 - timestamp: _timestamp,  
73 - nonceStr: _nonceStr,  
74 - signature: _signature,  
75 - jsApiList: [  
76 - 'checkJsApi',  
77 - 'onMenuShareTimeline',  
78 - 'onMenuShareAppMessage',  
79 - 'onMenuShareQQ',  
80 - 'onMenuShareWeibo',  
81 - 'hideMenuItems',  
82 - 'showMenuItems',  
83 - 'hideAllNonBaseMenuItem',  
84 - 'showAllNonBaseMenuItem',  
85 - 'translateVoice',  
86 - 'startRecord',  
87 - 'stopRecord',  
88 - 'onRecordEnd',  
89 - 'playVoice',  
90 - 'pauseVoice',  
91 - 'stopVoice',  
92 - 'uploadVoice',  
93 - 'downloadVoice',  
94 - 'chooseImage',  
95 - 'previewImage',  
96 - 'uploadImage',  
97 - 'downloadImage',  
98 - 'getNetworkType',  
99 - 'openLocation',  
100 - 'getLocation',  
101 - 'hideOptionMenu',  
102 - 'showOptionMenu',  
103 - 'closeWindow',  
104 - 'scanQRCode',  
105 - 'chooseWXPay',  
106 - 'openProductSpecificView',  
107 - 'addCard',  
108 - 'chooseCard',  
109 - 'openCard'  
110 - ]  
111 - });  
112 - }  
113 - });  
114 - wx.ready(function() { 61 + if (json) {
  62 + _appId = json.appId.toString();
  63 + _timestamp = json.timestamp;
  64 + _nonceStr = json.nonceStr.toString();
  65 + _signature = json.signature.toString();
115 66
  67 + wx.config({
  68 + debug: false,
  69 + appId: _appId,
  70 + timestamp: _timestamp,
  71 + nonceStr: _nonceStr,
  72 + signature: _signature,
  73 + jsApiList: [
  74 + 'checkJsApi',
  75 + 'onMenuShareTimeline',
  76 + 'onMenuShareAppMessage',
  77 + 'onMenuShareQQ',
  78 + 'onMenuShareWeibo',
  79 + 'hideMenuItems',
  80 + 'showMenuItems',
  81 + 'hideAllNonBaseMenuItem',
  82 + 'showAllNonBaseMenuItem',
  83 + 'translateVoice',
  84 + 'startRecord',
  85 + 'stopRecord',
  86 + 'onRecordEnd',
  87 + 'playVoice',
  88 + 'pauseVoice',
  89 + 'stopVoice',
  90 + 'uploadVoice',
  91 + 'downloadVoice',
  92 + 'chooseImage',
  93 + 'previewImage',
  94 + 'uploadImage',
  95 + 'downloadImage',
  96 + 'getNetworkType',
  97 + 'openLocation',
  98 + 'getLocation',
  99 + 'hideOptionMenu',
  100 + 'showOptionMenu',
  101 + 'closeWindow',
  102 + 'scanQRCode',
  103 + 'chooseWXPay',
  104 + 'openProductSpecificView',
  105 + 'addCard',
  106 + 'chooseCard',
  107 + 'openCard'
  108 + ]
  109 + });
  110 + }
  111 + });
  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();