审查视图

public/themes/simpleboot3_mobile/portal/login/wx_share.html 2.3 KB
jinglong authored
1 2 3 4 5 6 7 8 9 10 11 12 13
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<h1>分享主题</h1>
</body>
</html>
jinglong authored
14
<script src="__TMPL__/public/assets/js/jquery-2.1.0.js"></script>
jinglong authored
15
<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
jinglong authored
16 17 18 19 20 21 22 23 24
<script>
    $(function () {
        wx.config({
            debug: true,
            appId: '{$data.appId}',
            timestamp: '{$data.timestamp}',
            nonceStr: '{$data.nonceStr}',
            signature: '{$data.signature}',
            jsApiList: [
jinglong authored
25 26
                'updateAppMessageShareData',
                'updateTimelineShareData',
jinglong authored
27 28
            ]
        });
jinglong authored
29 30 31 32 33 34 35 36 37 38
        wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
            wx.updateAppMessageShareData({
                title: '分享标题', // 分享标题
                desc: '分享描述', // 分享描述
                link: 'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                imgUrl: '', // 分享图标
                success: function (e) {
                    // 设置成功
                    alert('分享朋友');
                }
jinglong authored
39
            });
jinglong authored
40 41
            wx.updateTimelineShareData({
                title: '分享朋友圈', // 分享标题
jinglong authored
42 43
                link: 'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                imgUrl: '', // 分享图标
jinglong authored
44
                success: function () {
jinglong authored
45 46
                    // 设置成功
                    alert('分享朋友圈 ');
jinglong authored
47
                }
jinglong authored
48
            });
jinglong authored
49
        });
jinglong authored
50 51 52 53 54
        wx.error(function (res) {
            // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
            alert(res);
        });
jinglong authored
55 56 57
    });

</script>