zoukankan      html  css  js  c++  java
  • bshare

    function shareInit(){
        $('.bshare').each(function(index, element) {
            var c1 = $('.p3-dialog').attr('tips');
            var item = $(this).closest('li');
            var shareDetails = {
                desc : item.find('.des').text(),
                text : item.find('.title').find('h2').text(), // 标题
                comment : item.find('.des').text(),    // 概要
                searchPic : 1,        // '0为抓取,1为不抓取,默认为0,目前只针对新浪微博'
                url : global.domain+'?'+'c1='+c1+'&del=t',
                pic : item.find('img').attr('src'),
            };
                    
            var d = "{"+
                    "'desc':'"+shareDetails.desc+
                    "','text':'"+shareDetails.text+
                    "','comment':'"+shareDetails.comment+
                    "','searchPic':'"+shareDetails.searchPic+
                    "','url':'"+shareDetails.url+
                    "','pic':'"+shareDetails.pic+
                    "'}";
            $(this).attr('data',d);
        });    
    };


    function doBshare(){
        $('.bshare a').bind('click', function(){
            //console.log($(this).parent().attr('data'))
            var data = eval('(' +  $(this).parent().attr('data') + ')');
            var rel = $(this).attr('rel');        
            var url = encodeURIComponent(data.url),
                title = data.text,
                summary = data.desc,
                pic = 'http://'+window.location.host+data.pic;
            console.log('c2?  '+url);
            var h = 'http://api.bshare.cn/share/'+rel+'?url='+url+'&title='+title+'&summary='+summary+'&pic='+pic;
            if(rel!='weixin'){
                window.open(h);
            }else{
                if($('.weixinShare').size()==0){
                    var html = '<div class="weixinShare"><span>分享到微信朋友圈</span><b class="close">×</b><div class="img"><img src="" id="wxcode" /></div><div class="foot"><p>打开微信,点击底部的“发现”,<p>使用“扫一扫”即可将网页分享至朋友圈。</p></div></div>';                
                    $('body').append(html);    
                    $('.weixinShare .close').click(function(){
                        $('.weixinShare').hide();
                    });
                }else{
                    $('.weixinShare').show();    
                };
                $('#wxcode').attr('src',h);    
                        
            };
        });
    };
  • 相关阅读:
    bzoj 1084: [SCOI2005]最大子矩阵
    Python之深浅拷贝
    2,版本控制git --分支
    1,版本控制git--仓库管理
    python-openpyxl操作excel
    ansible-3
    ansible-2
    ansible-1
    celery
    6,MongoDB 之 Array Object 的特殊操作
  • 原文地址:https://www.cnblogs.com/iloveyou-sky/p/5945041.html
Copyright © 2011-2022 走看看