html分享QQ,微信,显示分享图片,标题,简介

一、分享QQ

<meta itemprop="name" content="VV音乐再相聚"/>
<meta itemprop="image" name="shareimage" content="http://upcdn.mpres.51vv.com/v_block/02496797c18f5846082ec6c6d8024d6d.jpg" />
<meta name="description" content="即刻下载VV音乐,唱享现在!"/>

二、分享微信

1.引入JS文件
 
 <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
2.配置
wx = {
    isWX: (/micromessenger/gi).test(navigator.userAgent),
    icon: '//live.51vv.com/wx/m/article/dist/images/logo.png',
    // 微信二次分享
    share: function(res) {
        var _this = this,
        shareData = {
            title: res.title || 'VV直播',
            desc: res.desc || '',
            link: res.link || location.href,
            imgUrl: res.imgUrl || _this.icon,
            type: res.type || 'link',
            dataUrl: res.dataUrl || ''
        };
        if(_this.isWX) {
            $.ajax({
                url : '//live.51vv.com/wx/s/getWxMpSign.htm?url=' + encodeURIComponent(location.href),
                success : function(data) {
                    wx.config({
                        debug: false,
                        appId: data.wx_appid,
                        timestamp: parseInt(data.wx_timestamp),
                        nonceStr: data.wx_nonceStr,
                        signature: data.wx_signature,
                        jsApiList: [
                            'onMenuShareTimeline',
                            'onMenuShareAppMessage',
                            'onMenuShareQQ',
                            'onMenuShareWeibo',
                            'onMenuShareQZone'
                        ]
                    });
                    wx.ready(function(){
                        wx.onMenuShareAppMessage(shareData);
                        wx.onMenuShareTimeline(shareData);
                        wx.onMenuShareQQ(shareData);
                        wx.onMenuShareWeibo(shareData);
                        wx.onMenuShareQZone(shareData);
                    });
                }
            });
        }
    }
};

3.调用

vv.wx.share({
    title: 'VV音乐再相聚', // 分享标题,默认为“VV直播”
    desc: '即刻下载VV音乐,唱享现在!', // 分享描述,默认为空
    imgUrl: 'http://upcdn.mpres.51vv.com/v_block/02496797c18f5846082ec6c6d8024d6d.jpg' // 分享图标,默认VV直播的icon0
});

 

posted @ 2018-07-12 17:36  yuesu  阅读(628)  评论(0编辑  收藏  举报