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

调试

@@ -523,25 +523,25 @@ class LoginController extends HomeBaseController @@ -523,25 +523,25 @@ class LoginController extends HomeBaseController
523 523
524 //获取微信分享配置信息 524 //获取微信分享配置信息
525 public function wxShare($url=''){ 525 public function wxShare($url=''){
526 - $jsapiTicket = $this->getSignature();  
527 - // 注意 URL 一定要动态获取,不能 hardcode.  
528 - $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";  
529 - if($url === '') {  
530 - $url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";  
531 - }  
532 - $timestamp = time();  
533 - $nonceStr = $this->createNonceStr();  
534 - $string = 'jsapi_ticket='.$jsapiTicket.'&noncestr='.$nonceStr.'&timestamp='.$timestamp.'&url='.$url;  
535 - $signature = sha1($string);  
536 - $data = [  
537 - "appId" => $this->appkey2,  
538 - "nonceStr" => $nonceStr,  
539 - "timestamp" => $timestamp,  
540 - "url" => $url,  
541 - "signature" => $signature,  
542 - "rawString" => $string  
543 - ];  
544 - $this->assign('data',$data); 526 +// $jsapiTicket = $this->getSignature();
  527 +// // 注意 URL 一定要动态获取,不能 hardcode.
  528 +// $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
  529 +// if($url === '') {
  530 +// $url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
  531 +// }
  532 +// $timestamp = time();
  533 +// $nonceStr = $this->createNonceStr();
  534 +// $string = 'jsapi_ticket='.$jsapiTicket.'&noncestr='.$nonceStr.'&timestamp='.$timestamp.'&url='.$url;
  535 +// $signature = sha1($string);
  536 +// $data = [
  537 +// "appId" => $this->appkey2,
  538 +// "nonceStr" => $nonceStr,
  539 +// "timestamp" => $timestamp,
  540 +// "url" => $url,
  541 +// "signature" => $signature,
  542 +// "rawString" => $string
  543 +// ];
  544 +// $this->assign('data',$data);
545 return $this->fetch(); 545 return $this->fetch();
546 } 546 }
547 547
@@ -9,49 +9,25 @@ @@ -9,49 +9,25 @@
9 </head> 9 </head>
10 <body> 10 <body>
11 <h1>分享主题</h1> 11 <h1>分享主题</h1>
  12 +<button data-mshare="0">点击弹出原生分享面板</button>
  13 +<button data-mshare="1">点击触发朋友圈分享</button>
  14 +<button data-mshare="2">点击触发发送给微信朋友</button>
12 </body> 15 </body>
13 </html> 16 </html>
14 <script src="__TMPL__/public/assets/js/jquery-2.1.0.js"></script> 17 <script src="__TMPL__/public/assets/js/jquery-2.1.0.js"></script>
15 -<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script> 18 +<script src="__TMPL__/public/assets/js/mshare.js"></script>
16 <script> 19 <script>
17 - $(function () {  
18 - wx.config({  
19 - debug: true,  
20 - appId: '{$data.appId}',  
21 - timestamp: '{$data.timestamp}',  
22 - nonceStr: '{$data.nonceStr}',  
23 - signature: '{$data.signature}',  
24 - jsApiList: [  
25 - 'updateAppMessageShareData',  
26 - 'updateTimelineShareData',  
27 - ]  
28 - });  
29 - wx.ready(function () { //需在用户可能点击分享按钮前就先调用  
30 - wx.updateAppMessageShareData({  
31 - title: '分享标题', // 分享标题  
32 - desc: '分享描述', // 分享描述  
33 - link: 'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致  
34 - imgUrl: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1562352770741&di=353c660582a6727a64cdfdc93c4fb0f0&imgtype=0&src=http%3A%2F%2Fpic.k73.com%2Fup%2Fsoft%2F2016%2F0102%2F092635_44907394.jpg', // 分享图标  
35 - success: function (e) {  
36 - // 设置成功  
37 - alert('分享朋友');  
38 - }  
39 - });  
40 - wx.updateTimelineShareData({  
41 - title: '分享朋友圈', // 分享标题  
42 - link: 'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致  
43 - imgUrl: '', // 分享图标  
44 - success: function () {  
45 - // 设置成功  
46 - alert('分享朋友圈 ');  
47 - }  
48 - });  
49 - });  
50 - wx.error(function (res) {  
51 - // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。  
52 - alert(res);  
53 - });  
54 - 20 + var mshare = new mShare({
  21 + title: 'Lorem ipsum dolor sit.',
  22 + url: 'http://m.ly.com',
  23 + desc: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat inventore minima voluptates.',
  24 + img: 'http://placehold.it/150x150'
  25 + });
  26 + $('button').click(function () {
  27 + // 1 ==> 朋友圈 2 ==> 朋友 0 ==> 直接弹出原生
  28 + mshare.init(+$(this).data('mshare'));
55 }); 29 });
56 -  
57 </script> 30 </script>
  31 +
  32 +
  33 +