返回官网

微信文章分享以后 会有标题和图片

狒狒 2016-11-8 技术札记 730 次

在boby 和head之间添加下面的代码即可

<script>

    document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {

    window.shareData = {

        "timeLineLink": "这里是一个链接",   

        "sendFriendLink": "这里是一个链接",

        "weiboLink": "这里是一个链接",

        "tTitle": "这里是title",

        "tContent": "这里是显示的内容",

        "fTitle": "这里是title",

        "fContent": "这里是显示的内容",

        "wContent": "这里是显示的内容"

        };

        // 发送给好友

        WeixinJSBridge.on('menu:share:appmessage', function (argv) {

            WeixinJSBridge.invoke('sendAppMessage', {

                "img_url": "img/logo_white.png",

                "img_width": "401",

                "img_height": "275",

                "link": window.shareData.sendFriendLink,

                "desc": window.shareData.fContent,

                "title": window.shareData.fTitle

            }, function (res) {

                _report('send_msg', res.err_msg);

            })

        });

        // 分享到朋友圈

        WeixinJSBridge.on('menu:share:timeline', function (argv) {

            WeixinJSBridge.invoke('shareTimeline', {

                "img_url": "img/logo_white.png",

                "img_width": "401",

                "img_height": "275",

                "link": window.shareData.timeLineLink,

                "desc": window.shareData.tContent,

                "title": window.shareData.tTitle

            }, function (res) {

                _report('timeline', res.err_msg);

            });

        });

 

    }, false)

</script>

发表评论

Copyright © 2016 DEWEBSTUDIO