• 常用分享功能.超级简单,qq 微信 新浪微博分享


    <div id="share">
                <a href="javascript:void(0)"  share-type="qzone"  style="background-position: 0 0;"     target="_blank"  title="分享到QQ空间"></a>
                <a href="javascript:void(0)"  share-type="tsina"  style="background-position: -35px 0;" target="_blank"  title="分享到新浪微博"></a>
                <a href="javascript:void(0)"  share-type="weixin" style="background-position: -70px 0;" target="_blank"  title="分享到微信朋友圈"><div class="erweima"><div id="qrcode"></div></div></a>
            </div>
    

    这是html;

    下边是JS

    $(function () {
    
        var qrcode = new QRCode(document.getElementById("qrcode"), {
            width : 160,//设置宽高
            height : 160
        });
        qrcode.makeCode(location.href);
        
        $('#share a').on('click',share);
    
    
        var shareDara = {
            pic:(function () {
                var pics = ''
                $('.contenr-main .text img').each(function (i,k) {
                    if(i<1){
                        pics +=  $(k).attr('src')
                    }else{
                        pics += '||'+$(k).attr('src')
                    }
                })
                return pics
            })(),
            title:(function () {
               return $('.contenr-main .title').html()
            })(),
            url:location.href,
            desc:(function () {
                return $('.contenr-main .text p').eq(0).html()
            })()
        }
    
    
    
        function share (){
            var self = $(this);
            var shareType = self.attr('share-type');
                //console.log(shareType);
            switch (shareType){
                case 'weixin':
                    break;
                case 'tsina':
                    self.attr('href',
                        'http://service.weibo.com/share/share.php?' +
                        'url=' +encodeURIComponent(shareDara.url)+
                        '&title=' +encodeURIComponent(shareDara.title)+
                        '&appkey=93034926' +
                        '&pic='+encodeURIComponent(shareDara.pic)+
                        '&searchPic=false')
                    break;
                case 'qzone':
                    self.attr('href',
                        'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?' +
                        'url='  +encodeURIComponent(shareDara.url)+
                        '&title=' +encodeURIComponent(shareDara.title)+
                        '&desc=' + encodeURIComponent(shareDara.desc)+
                        '&summary=' +encodeURIComponent(shareDara.pic)+
                        '&site='
                        )
                    break;
                default:
                    break;
    
            }
        }
    
    });
    

      再从网上下载一个qrcode.min.js用来生成二维码超级简单实用

    不自见,故明;不自是,故彰;不自伐,故有功;不自矜;故长;夫唯不争,故天下莫能与之争。
  • 相关阅读:
    GDB编辑、搜索源码以及在线帮助
    GDB查看栈信息
    GDB信号处理
    GDB反向调试
    GDB调试多进程程序
    GDB后台调试命令
    GDB non-stop模式
    GDB调试多线程程序
    GDB禁用删除断点
    解决Mac OS下Eclipse、IntelliJ IDEA打开其他窗口默认全屏
  • 原文地址:https://www.cnblogs.com/chengfeng6/p/6694117.html
Copyright © 2020-2023  润新知