作者 jinglong
1 个管道 的构建 通过 耗费 0 秒

调试微信分享

1 <div class="share"> 1 <div class="share">
2 <ul> 2 <ul>
3 <li class="share1"> 3 <li class="share1">
4 - <div class="share1_Img weixin"> 4 + <div class="share1_Img weixin" onclick="wx_share()">
5 <img src="__TMPL__/public/assets/images/bicon_04.png" alt="" /> 5 <img src="__TMPL__/public/assets/images/bicon_04.png" alt="" />
6 </div> 6 </div>
7 <p class="share1_Txt">{$share.post_share_wx}</p> 7 <p class="share1_Txt">{$share.post_share_wx}</p>
@@ -38,52 +38,54 @@ @@ -38,52 +38,54 @@
38 <script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script> 38 <script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
39 <script> 39 <script>
40 $(function () { 40 $(function () {
41 - var appid = '';  
42 - var timestamp = '';  
43 - var nonceStr = '';  
44 - var signature = '';  
45 - $.ajax({  
46 - type: 'POST',  
47 - url: '/portal/login/configShareWx',  
48 - data: {  
49 - },  
50 - dataType: 'json',  
51 - async: false,  
52 - success: function(data) {  
53 - console.log(data);  
54 - if (data.code == 1) {  
55 - appid = data.appid;  
56 - timestamp = data.timestamp;  
57 - nonceStr = data.nonceStr;  
58 - signature = data.signature;  
59 - } else { 41 + function wx_share(){
  42 + var appid = '';
  43 + var timestamp = '';
  44 + var nonceStr = '';
  45 + var signature = '';
  46 + $.ajax({
  47 + type: 'POST',
  48 + url: '/portal/login/configShareWx',
  49 + data: {
  50 + },
  51 + dataType: 'json',
  52 + async: false,
  53 + success: function(data) {
60 console.log(data); 54 console.log(data);
  55 + if (data.code == 1) {
  56 + appid = data.appid;
  57 + timestamp = data.timestamp;
  58 + nonceStr = data.nonceStr;
  59 + signature = data.signature;
  60 + } else {
  61 + console.log(data);
  62 + }
61 } 63 }
62 - }  
63 - });  
64 - wx.config({  
65 - debug: false,  
66 - appId: appid,  
67 - timestamp: timestamp,  
68 - nonceStr: nonceStr,  
69 - signature: signature,  
70 - jsApiList: [  
71 - 'checkJsApi',  
72 - 'onMenuShareTimeline',  
73 - 'onMenuShareAppMessage'  
74 - ]  
75 - });  
76 - wx.ready(function () { //需在用户可能点击分享按钮前就先调用  
77 - wx.updateAppMessageShareData({  
78 - title: '分享标题', // 分享标题  
79 - desc: '分享描述', // 分享描述  
80 - link: 'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致  
81 - imgUrl: '', // 分享图标  
82 - success: function () {  
83 - // 设置成功  
84 - }  
85 - })  
86 - }); 64 + });
  65 + wx.config({
  66 + debug: false,
  67 + appId: appid,
  68 + timestamp: timestamp,
  69 + nonceStr: nonceStr,
  70 + signature: signature,
  71 + jsApiList: [
  72 + 'checkJsApi',
  73 + 'updateAppMessageShareData',
  74 + ]
  75 + });
  76 + wx.ready(function () { //需在用户可能点击分享按钮前就先调用
  77 + wx.updateAppMessageShareData({
  78 + title: '分享标题', // 分享标题
  79 + desc: '分享描述', // 分享描述
  80 + link: 'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  81 + imgUrl: '', // 分享图标
  82 + success: function () {
  83 + // 设置成功
  84 + }
  85 + })
  86 + });
  87 + }
  88 +
87 }); 89 });
88 90
89 </script> 91 </script>