zoukankan      html  css  js  c++  java
  • 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
    });
  • 相关阅读:
    Java 线程池原理分析
    基于 Java NIO 实现简单的 HTTP 服务器
    Java NIO之选择器
    Java NIO之套接字通道
    Django【基础篇-1】
    paramiko_sftp封装
    python random模块生成随机验证码
    Python3 os与sys模块用法
    python生成器并行实例
    python装饰器无参及有参案例
  • 原文地址:https://www.cnblogs.com/yuesu/p/9300725.html
Copyright © 2011-2022 走看看