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

分享

... ... @@ -523,25 +523,25 @@ class LoginController extends HomeBaseController
//获取微信分享配置信息
public function wxShare($url=''){
// $jsapiTicket = $this->getSignature();
// // 注意 URL 一定要动态获取,不能 hardcode.
// $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
// if($url === '') {
// $url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
// }
// $timestamp = time();
// $nonceStr = $this->createNonceStr();
// $string = 'jsapi_ticket='.$jsapiTicket.'&noncestr='.$nonceStr.'&timestamp='.$timestamp.'&url='.$url;
// $signature = sha1($string);
// $data = [
// "appId" => $this->appkey2,
// "nonceStr" => $nonceStr,
// "timestamp" => $timestamp,
// "url" => $url,
// "signature" => $signature,
// "rawString" => $string
// ];
// $this->assign('data',$data);
$jsapiTicket = $this->getSignature();
// 注意 URL 一定要动态获取,不能 hardcode.
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
if($url === '') {
$url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
}
$timestamp = time();
$nonceStr = $this->createNonceStr();
$string = 'jsapi_ticket='.$jsapiTicket.'&noncestr='.$nonceStr.'&timestamp='.$timestamp.'&url='.$url;
$signature = sha1($string);
$data = [
"appId" => $this->appkey2,
"nonceStr" => $nonceStr,
"timestamp" => $timestamp,
"url" => $url,
"signature" => $signature,
"rawString" => $string
];
$this->assign('data',$data);
return $this->fetch();
}
... ...
... ... @@ -31,7 +31,7 @@
title: '分享标题', // 分享标题
desc: '分享描述', // 分享描述
link: 'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
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', // 分享图标
imgUrl: '', // 分享图标
success: function (e) {
// 设置成功
alert('分享朋友');
... ...