css部分:
<style>
.share-list{
position: fixed;
top: 200px;
width: 1200px;
padding: 0 19%;
}
.share-list ul li{
line-height:55px;
}
.share-container li{
position: relative;
float: left;
width: 23px;
height: 23px;
margin-left: 5px;
margin-top: 20px;
}
.share-container li a{
display: inline-block;
width: 100%;
height: 23px;
}
.share-container li a img{
width: 100%;
}
.bds_weixin:hover .wechat-share{
display: block;
}
.wechat-share img{
width: 100%;
}
.share-list ul li div.wechat-share{
display:none;
position: absolute;
left:16%;
top: 100px;
width: 120px;
height: 180px;
padding: 20px 20px 0;
background: #fff;
border: 1px solid #ddd;
border-radius: 4px;
box-shadow: 0 3px 5px rgba(0,0,0,.1);
}
.share-list ul li div.wechat-share p{
display:block;
line-height:2;
}
.js_qrcode_close{
width: 15px;
height: 15px;
position: absolute;
right: 2px;
top: 2px;
background: url(/statics/images/qrcode/sprite.png) no-repeat -156px -156px;
}
</style>
html部分:
<div class="share-list">
<span class="post_top_share_title">分享至</span>
<ul class="share-container">
<li>
<a href="javascript:void(0)" class="bds_weixin">
<img src="/statics/images/share/wechat.png">
</a>
<div class="wechat-share" id="qrcode" title="https://www.cnfisher.com/2024/renwangzixun_0827/98966.html"><a href="javascript:;" target="_self" class="js_qrcode_close" title="关闭"></a>
<canvas width="120" height="120" style="display: none;"></canvas><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAAAXNSR0IArs4c6QAACWFJREFUeF7tndl240AIROP//+jM8aKxZEHfKlpekjBPc9JSLxQFBZLt09fX1/fXAf++v/fTnE6n/zOvx5e/R38737D8Pbuftru+L7o2mn99nbp+dX/LWmQfOqcyfkagAX6w1K8EOGIgeQh5YDZnxOD1WrMMjxicRYtlXRqPGJ7Zp3I+Oj9hEd1//tt/BjfA90CmhvgGOMjLF6+65WaH4VG0oAiSsa7C8F/FYNWDSWTMAkBRJdsnCb4oLFMIJAdzRNqsg4+E45pAaYhugPcmbIChTHq2h2ciY8RWikDZnBRZKmWQU0Z+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2dtgK+mqShqNddn85NKJgen9S85uAH+IwBXEz7VYaNx8lAK4Q7rqtdGeyAR9Yw6mGyR4Vf6niwqWdTxBvj+Nf/VHEtViNyLpjrwSBFCrCEHIm+nvVI0o9yn3k/X0TloH5ccrD5saIDvFiDDEnBUZRCwyzjtowFeWfLZObpCEAJaAlhV0bRYVP85ZQAZgACo5LBMA6jCkWxy5PwUFSL7WWUSHaYB3luoAYZWo6Oym8GxRghfm3XYGiX8Z9SJWQgalQnVFEEihh5WqCGeHJjSUobT5r7RD2M5QNNmiGHUi22A9z+NZwGsKLLHCR0PjDZDOYoc7F3rU6dKjWrktJGuOf+NsFrbRf6eLAego0JYA3y3gEOGBvhmN8doTpXw8QymmivqxDg5eCSMlBBE0YSYH407Yc+5drQW2VnJsXRW+Wd1onxBOZByTHZAMmADrP90fAN88xZyKiecEzNne9G01006UX/5zGGwGoKdCEChqDKeGepVIjFTyZTDKUU2wMDaBvj7mC8Kc4SZ2h3LRJoTYtUIRHWqs6ZzPkckPiUHqyKoAY7rXArRDfAtwhDDKG87Kp9arSSMXspgOngUwugAkbGrDH6GCiXl65R86v4qNqN9PGL3lFYlOchsL1c1oNMoaIADazkiohm8N+BLGUyso/Fos1UHoLVIxBHDK+OUTmjPDpiUAqmMCx820AZpvAEeW6gBJg+CcVKxkTghlXxkp+1dAP8DVtLvB/ahEgwAAAAASUVORK5CYII=" style="display: block;"><p>用微信扫码二维码</p><p>分享至好友和朋友圈</p></div>
</li>
<li>
<a title="分享到新浪微博" href="javascript:void(0)" class="share_xlwb" onclick="shareToSinaWB(event)">
<img src="/statics/images/share/weibo.png">
</a>
</li>
<li>
<a title="分享到QQ好友" href="javascript:void(0)" class="share_qq" onclick="shareToqq(event)">
<img src="/statics/images/share/qq.png">
</a>
</li>
<li>
<a title="分享到QQ空间" href="javascript:void(0)" class="share_qzone" onclick="shareToQzone(event)">
<img src="/statics/images/share/qq_zone.png">
</a>
</li>
</ul>
</div>
js部分:
<script>
var _title = '中国钓鱼人网 CNFISHER.COM 整站出售,如果您也是爱站之人';
var _desc = '各位, 由于本人精力有限,我想将此平台转手给有时间、有能力,愿意为这个平台投入的爱站之人或钓鱼玩家。希望平台能在阁下的手上发扬 ';
var _url = 'https://www.cnfisher.com/2024/renwangzixun_0827/98966.html';
var _pic = 'https://www.cnfisher.com/uploadfile/2024/0827/20240827112413132.gif';
var _source = '';
var _sourceUrl ='';
var _shareUrl = '';
var _showcount = '';
var _summary = '';
var _site = '';
//分享至微信 css控制二维码隐藏和出现
//分享到新浪微博
function shareToSinaWB(event){
event.preventDefault();
var _shareUrl = 'https://service.weibo.com/share/share.php'; //真实的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 += '&appkey=' + '1580730830';
_shareUrl += '&content=' + 'utf-8'; //参数content设置页面编码gb2312|utf-8,可选参数
_shareUrl += '&pic=' + encodeURIComponent(_pic||''); //参数pic设置图片链接|默认为空,可选参数
window.open(_shareUrl,'_blank');
}
//分享到QQ空间
function shareToQzone(event){
event.preventDefault();
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');
}
//分享到qq
function shareToqq(event){
event.preventDefault();
var _shareUrl = 'https://connect.qq.com/widget/shareqq/iframe_index.html?';
_shareUrl += 'url=' + encodeURIComponent(_url||location.href); //分享的链接
_shareUrl += '&title=' + encodeURIComponent(_title||document.title); //分享的标题
window.open(_shareUrl,'_blank');
}
</script>
<script type="text/javascript" src="/statics/js/qrcode/qrcode.min.js"></script>
<script>
$(function(){
$('.bds_weixin').click(function(){
$('.wechat-share').toggle();
})
})
var qrcode = new QRCode(document.getElementById("qrcode"), {
width : 120,
height : 120
});
function makeCode () {
var url = 'https://www.cnfisher.com/2024/renwangzixun_0827/98966.html';
$('#qrcode').prepend('<a href="javascript:;" target="_self" class="js_qrcode_close" title="关闭"></a>');
qrcode.makeCode(url);
$('#qrcode').append('<p>用微信扫码二维码</p><p>分享至好友和朋友圈</p>');
}
makeCode();
$('.js_qrcode_close').click(function(){
$('.wechat-share').hide();
})
</script>