wx_share.html 1.4 KB
<!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 onclick="weixinSendAppMessage()">分享主题</h1>
</body>
</html>
<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script type="text/javascript">
    $(function () {
        wx.config({
            debug: true,
            appId: '{$data.appId}',
            timestamp: '{$data.timestamp}',
            nonceStr: '{$data.nonceStr}',
            signature: '{$data.signature}',
            jsApiList: [
                'updateAppMessageShareData',
                'updateTimelineShareData',
            ]
        });

    });

    function weixinSendAppMessage(){
        WeixinJSBridge.invoke('updateAppMessageShareData',{
            title: '分享标题', // 分享标题
            desc: '分享描述', // 分享描述
            link: 'http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=81', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
            imgUrl: '', // 分享图标
            success: function (e) {
                // 设置成功
                alert('分享朋友');
            }
        });
    }

</script>