微信 qq微博分享功能

 

 

<script type="text/javascript" src="${ctx}/static_pc/layer/layer.js"></script>

 

<script type="text/javascript" src="${ctx}/static_pc/js/qrcode.js"></script>

/**

 * 分享-公用
 */
var _title,_source,_sourceUrl,_pic,_showcount,_desc,_summary,_site,
     _width = 975,
     _height = 655,
     _top = (screen.height-_height)/2,
     _left = (screen.width-_width)/2,
     _url = window.location.href  ,
     _pic = '';
 
/** QQ空间*/
function sendQQKj(){
clickCount();
var _shareUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?';
    _shareUrl += 'url=' + encodeURIComponent(_url||document.location);   //参数url设置分享的内容链接|默认当前页location
    _shareUrl += '&showcount=' + _showcount||0;      //参数showcount是否显示分享总数,显示:'1',不显示:'0',默认不显示
    _shareUrl += '&desc=' + encodeURIComponent(_desc||'分享的描述');    //参数desc设置分享的描述,可选参数
    _shareUrl += '&summary=' + encodeURIComponent(_summary||'分享摘要');    //参数summary设置分享摘要,可选参数
    _shareUrl += '&title=' + encodeURIComponent(_title||document.title);    //参数title设置分享标题,可选参数
    _shareUrl += '&site=' + encodeURIComponent(_site||'');   //参数site设置分享来源,可选参数
    _shareUrl += '&pics=' + encodeURIComponent(_pic||'');   //参数pics设置分享图片的路径,多张图片以"|"隔开,可选参数
    window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',top='+(screen.height-_height)/2+',left='+(screen.width-_width)/2+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
}
/** 微博*/
function sendWeiBo(){
clickCount();
var _shareUrl = 'http://v.t.sina.com.cn/share/share.php?&appkey=895033136';     //真实的appkey ,必选参数
    _shareUrl += '&url='+ encodeURIComponent(_url||document.location);     //参数url设置分享的内容链接|默认当前页location,可选参数
    _shareUrl += '&title=' + encodeURIComponent(_title||document.title);    //参数title设置分享的标题|默认当前页标题,可选参数
    _shareUrl += '&source=' + encodeURIComponent(_source||'');
    _shareUrl += '&sourceUrl=' + encodeURIComponent(_sourceUrl||'');
    _shareUrl += '&content=' + 'utf-8';   //参数content设置页面编码gb2312|utf-8,可选参数
    _shareUrl += '&pic=' + encodeURIComponent(_pic||'');  //参数pic设置图片链接|默认为空,可选参数
    window.open(_shareUrl,'_blank','toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0,' + 'width=' + _width + ',height=' + _height + ',top=' + (screen.height-_height)/2 + ',left=' + (screen.width-_width)/2);  
}
/** QQ*/
function sendQQ(){
clickCount();
var _shareUrl = 'http://connect.qq.com/widget/shareqq/index.html?';     //真实的appkey ,必选参数
   _shareUrl += '&url='+ encodeURIComponent(_url||document.location);     //参数url设置分享的内容链接|默认当前页location,可选参数
   _shareUrl += '&title=' + encodeURIComponent(_title||document.title);    //参数title设置分享的标题|默认当前页标题,可选参数
   _shareUrl += '&source=' + encodeURIComponent(_source||'');
   _shareUrl += '&sourceUrl=' + encodeURIComponent(_sourceUrl||'');
   _shareUrl += '&content=' + 'utf-8';   //参数content设置页面编码gb2312|utf-8,可选参数
   _shareUrl += '&pic=' + encodeURIComponent(_pic||'');  //参数pic设置图片链接|默认为空,可选参数
//document.write(['<a class="qcShareQQDiv" href="http://connect.qq.com/widget/shareqq/index.html?',s.join('&'),'" target="_blank">分享到QQ</a>'].join(''));
window.open(_shareUrl,'_blank','toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0,' + 'width=' + _width + ',height=' + _height + ',top=' + (screen.height-_height)/2 + ',left=' + (screen.width-_width)/2); 
}
/** 微信分享**/
function sendWX(){
 clickCount();
 layer.open({
 type: 1,
 title:"分享到微信朋友圈",
 area: ['230px', '230px'],
 shadeClose: true, //点击遮罩关闭
 content: "<div id='qrcode' style='text-align:center;' ></div>"
 });
var qrcode = new QRCode(document.getElementById("qrcode"), {
   text: _url,
   width: 128,
   height: 128,
   colorDark : "#000000",
   colorLight : "#ffffff",
   correctLevel : QRCode.CorrectLevel.H
});
$("#qrcode").children("img").css({"margin":"0 auto","padding-top":"25px"});
}
function clickCount(){
$.ajax({
type : "post",
async : false,
url : CTX_URL+"/news/clickCount.html",
data :{newsId:$("#newsId").val()},
success : function(data) {
}
    });
}
posted @ 2016-10-20 09:46  汪星人  阅读(391)  评论(0编辑  收藏  举报