正在显示
3 个修改的文件
包含
46 行增加
和
55 行删除
@@ -522,7 +522,7 @@ class LoginController extends HomeBaseController | @@ -522,7 +522,7 @@ class LoginController extends HomeBaseController | ||
522 | } | 522 | } |
523 | 523 | ||
524 | //获取微信分享配置信息 | 524 | //获取微信分享配置信息 |
525 | - public function configShareWx($url=''){ | 525 | + public function wx_share($url=''){ |
526 | $jsapiTicket = $this->getSignature(); | 526 | $jsapiTicket = $this->getSignature(); |
527 | // 注意 URL 一定要动态获取,不能 hardcode. | 527 | // 注意 URL 一定要动态获取,不能 hardcode. |
528 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; | 528 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; |
@@ -541,7 +541,8 @@ class LoginController extends HomeBaseController | @@ -541,7 +541,8 @@ class LoginController extends HomeBaseController | ||
541 | "signature" => $signature, | 541 | "signature" => $signature, |
542 | "rawString" => $string | 542 | "rawString" => $string |
543 | ]; | 543 | ]; |
544 | - $this->apiResponse(1, '成功',$data); | 544 | + $this->assign('data',$data); |
545 | + return $this->fetch(); | ||
545 | } | 546 | } |
546 | 547 | ||
547 | //获取微信分享签名随机字符串 | 548 | //获取微信分享签名随机字符串 |
1 | +<!doctype html> | ||
2 | +<html lang="en"> | ||
3 | +<head> | ||
4 | + <meta charset="UTF-8"> | ||
5 | + <meta name="viewport" | ||
6 | + content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
7 | + <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
8 | + <title>Document</title> | ||
9 | +</head> | ||
10 | +<body> | ||
11 | +<h1>分享主题</h1> | ||
12 | +</body> | ||
13 | +</html> | ||
14 | +<script src="__TMPL__/public/assets/js/jquery-2.1.0.js"></script> | ||
15 | +<script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script> | ||
16 | +<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 | + ] | ||
27 | + }); | ||
28 | + wx.ready(function () { //需在用户可能点击分享按钮前就先调用 | ||
29 | + wx.updateAppMessageShareData({ | ||
30 | + title: '分享标题', // 分享标题 | ||
31 | + desc: '分享描述', // 分享描述 | ||
32 | + link: 'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | ||
33 | + imgUrl: '', // 分享图标 | ||
34 | + success: function (e) { | ||
35 | + // 设置成功 | ||
36 | + console.log(e); | ||
37 | + } | ||
38 | + }) | ||
39 | + }); | ||
40 | + | ||
41 | + }); | ||
42 | + | ||
43 | +</script> |
@@ -34,56 +34,3 @@ | @@ -34,56 +34,3 @@ | ||
34 | </li> | 34 | </li> |
35 | </ul> | 35 | </ul> |
36 | </div> | 36 | </div> |
37 | -<script src="__TMPL__/public/assets/js/jquery-2.1.0.js"></script> | ||
38 | -<script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script> | ||
39 | -<script> | ||
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 | - wx.config({ | ||
60 | - debug: true, | ||
61 | - appId: appid, | ||
62 | - timestamp: timestamp, | ||
63 | - nonceStr: nonceStr, | ||
64 | - signature: signature, | ||
65 | - jsApiList: [ | ||
66 | - 'updateAppMessageShareData', | ||
67 | - ] | ||
68 | - }); | ||
69 | - wx.ready(function () { //需在用户可能点击分享按钮前就先调用 | ||
70 | - wx.updateAppMessageShareData({ | ||
71 | - title: '分享标题', // 分享标题 | ||
72 | - desc: '分享描述', // 分享描述 | ||
73 | - link: 'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | ||
74 | - imgUrl: '', // 分享图标 | ||
75 | - success: function (e) { | ||
76 | - // 设置成功 | ||
77 | - console.log(e); | ||
78 | - } | ||
79 | - }) | ||
80 | - }); | ||
81 | - } else { | ||
82 | - console.log(data); | ||
83 | - } | ||
84 | - } | ||
85 | - }); | ||
86 | - | ||
87 | - }); | ||
88 | - | ||
89 | -</script> |
-
请 注册 或 登录 后发表评论