|
@@ -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
|
+ |