切换导航条
此项目
正在载入...
登录
景龙
/
xingqiu
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
jinglong
6 years ago
提交
58788098ded92c057773dfacb5524dc0e07e93b7
1 个父辈
3b10b787
1 个管道 的构建
通过
耗费 0 秒
调试
变更
2
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
35 行增加
和
59 行删除
app/portal/controller/LoginController.php
public/themes/simpleboot3_mobile/portal/login/wx_share.html
app/portal/controller/LoginController.php
查看文件 @
5878809
...
...
@@ -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
.
'×tamp='
.
$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.'×tamp='.$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
();
}
...
...
public/themes/simpleboot3_mobile/portal/login/wx_share.html
查看文件 @
5878809
...
...
@@ -9,49 +9,25 @@
</head>
<body>
<h1>
分享主题
</h1>
<button
data-mshare=
"0"
>
点击弹出原生分享面板
</button>
<button
data-mshare=
"1"
>
点击触发朋友圈分享
</button>
<button
data-mshare=
"2"
>
点击触发发送给微信朋友
</button>
</body>
</html>
<script
src=
"__TMPL__/public/assets/js/jquery-2.1.0.js"
></script>
<script
src=
"
http://res.wx.qq.com/open/js/jweixin-1.4.0
.js"
></script>
<script
src=
"
__TMPL__/public/assets/js/mshare
.js"
></script>
<script>
$
(
function
()
{
wx
.
config
({
debug
:
true
,
appId
:
'{$data.appId}'
,
timestamp
:
'{$data.timestamp}'
,
nonceStr
:
'{$data.nonceStr}'
,
signature
:
'{$data.signature}'
,
jsApiList
:
[
'updateAppMessageShareData'
,
'updateTimelineShareData'
,
]
});
wx
.
ready
(
function
()
{
//需在用户可能点击分享按钮前就先调用
wx
.
updateAppMessageShareData
({
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'
,
// 分享图标
success
:
function
(
e
)
{
// 设置成功
alert
(
'分享朋友'
);
}
});
wx
.
updateTimelineShareData
({
title
:
'分享朋友圈'
,
// 分享标题
link
:
'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81'
,
// 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl
:
''
,
// 分享图标
success
:
function
()
{
// 设置成功
alert
(
'分享朋友圈 '
);
}
});
});
wx
.
error
(
function
(
res
)
{
// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
alert
(
res
);
});
var
mshare
=
new
mShare
({
title
:
'Lorem ipsum dolor sit.'
,
url
:
'http://m.ly.com'
,
desc
:
'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat inventore minima voluptates.'
,
img
:
'http://placehold.it/150x150'
});
$
(
'button'
).
click
(
function
()
{
// 1 ==> 朋友圈 2 ==> 朋友 0 ==> 直接弹出原生
mshare
.
init
(
+
$
(
this
).
data
(
'mshare'
));
});
</script>
...
...
请
注册
或
登录
后发表评论