作者 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
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 title: '分享标题', // 分享标题 31 title: '分享标题', // 分享标题
32 desc: '分享描述', // 分享描述 32 desc: '分享描述', // 分享描述
33 link: 'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 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', // 分享图标 34 + imgUrl: '', // 分享图标
35 success: function (e) { 35 success: function (e) {
36 // 设置成功 36 // 设置成功
37 alert('分享朋友'); 37 alert('分享朋友');