查看: 83|回复: 0

分享到新浪微博、微信和QQ空间的代码

[复制链接]

1373

主题

14

回帖

3753

积分

管理员

金钱
2366
发表于 2026-7-8 19:46:56 | 显示全部楼层 |阅读模式

3746.png


1、打开 template\default\forum\viewthread_node.htm 模板,查找:

  1. <!--{if !IS_ROBOT && $post['first'] && !$_G['forum_thread']['archiveid']}-->
复制代码


在下边添加:

  1.         <div class="viewthread_share">
  2.                  <div class="bdsharebuttonbox">         
  3.                           <script>var TITLE_S='';TITLE_S=encodeURIComponent(document.title);</script><a href='javascript:void(0);' target="_blank" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>                                                      
  4.                           <a href="https://api.qrserver.com/v1/create-qr-code/?size=154x154&data=$_G[siteurl]thread-{$_G[tid]}-1-1.html" target="_blank" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
  5.                           <a href="javascript:void(0);"  target="_blank" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
  6.                  </div>
  7.                                 </div>
  8. <script language='javascript'>
  9. lastScrollY=0; var InterTime = 1;var maxWidth=-1;var minWidth=-85;var numInter = 3;var BigInter ;var SmallInter ;var SHARE_O =  document.getElementById('aaswc164bb');var SHARE_I = parseInt(SHARE_O.style.left);
  10. function SHARE_BIG(){if(parseInt(SHARE_O.style.left)<maxWidth){SHARE_I = parseInt(SHARE_O.style.left);SHARE_I += numInter;      SHARE_O.style.left=SHARE_I+'px';        if(SHARE_I==maxWidth)clearInterval(BigInter);}}
  11. function SHARE_TOBIG(){clearInterval(SmallInter);clearInterval(BigInter);BigInter = setInterval('SHARE_BIG()',InterTime);}
  12. function SHARE_SMALL(){if(parseInt(SHARE_O.style.left)>minWidth){SHARE_I = parseInt(SHARE_O.style.left);SHARE_I -= numInter;SHARE_O.style.left=SHARE_I+'px';if(SHARE_I==minWidth)clearInterval(SmallInter);}}
  13. function SHARE_TOSMALL(){clearInterval(SmallInter);clearInterval(BigInter);SmallInter = setInterval('SHARE_SMALL()',InterTime);}
  14. function postToWb(){var _t = encodeURI(document.title);var _url = encodeURI(document.location);var _appkey = encodeURI('appkey');var _pic = encodeURI('');var _site = '';var _u = 'http://share.v.t.qq.com/index.php?c=share&a=index&title='+_t+'&url='+_url+'&appkey='+_appkey+'&site='+_site+'&pic='+_pic;window.open( _u,'转播到腾讯微博', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no' );}
  15. function SHARE_CLOSE(id){
  16. document.getElementById(id).style.display='none';
  17. SHARE_SET_COOKIE('SHARE_DISPLAY','no');
  18. }
  19. function SHARE_SET_COOKIE(name,value){document.cookie = name+'='+value;}
  20. function SHARE_GET_COOKIE(name){
  21. var arg = name + '=';
  22. var alen = arg.length;
  23. var clen = document.cookie.length;
  24. var ii = 0;
  25. while (ii < clen) {
  26. var jj = ii + alen;
  27. if(document.cookie.substring(ii, jj) == arg){return GetCookieVal(jj);}
  28. ii = document.cookie.indexOf(' ', ii) + 1;
  29. if (ii == 0) break;
  30. }
  31. return null;
  32. }
  33. function GetCookieVal(offset)
  34. {
  35. var endstr = document.cookie.indexOf(';', offset);
  36. if (endstr == -1){endstr = document.cookie.length;}
  37. return unescape(document.cookie.substring(offset, endstr));
  38. }
  39. share=function (id,_top,_left){var me=id.charAt?document.getElementById(id):id, d1=document.body, d2=document.documentElement;d1.style.height=d2.style.height='100%';me.style.top=_top?_top+'px':0;me.style.left=_left+'px';me.style.position='absolute';setInterval(function (){me.style.top=parseInt(me.style.top)+(Math.max(d1.scrollTop,d2.scrollTop)+_top-parseInt(me.style.top))*0.1+'px';},10+parseInt(Math.random()*20));return arguments.callee;};
  40. window.onload=function (){
  41. share('aaswc164bb',200,-85);
  42. if(SHARE_GET_COOKIE('SHARE_DISPLAY')=='no'){
  43. document.getElementById('aaswc164bb').style.display='none';
  44. }else{
  45. document.getElementById('aaswc164bb').style.display='block';
  46. }
  47. var UPL = SHARE_GET_COOKIE('USER_PREF_LANG');if(UPL.length>0){
  48. if(UPL=='zh_TW'){
  49.   TSC('big5');
  50. }else if(UPL=='zh_CN'){
  51.   TSC('gb');
  52. }else{
  53.   TSC('big5');
  54. }
  55. }
  56. }
  57. </script>
复制代码


2、打开 template\default\common\common.css ,在最下边添加:

  1. /* 百度分享 */
  2. .viewthread_share {float: left;margin: 20px 0 10px;padding: 3em 0;}
  3. .viewthread_share .bdsharebuttonbox {line-height: 30px;font-size: 16px;color: #afafaf;vertical-align: middle;display: inline-block;}
  4. .viewthread_share .bdsharebuttonbox .bds_qzone {background-position: -1px -61px;border-color: #1499f7;}
  5. .viewthread_share .bdsharebuttonbox a {display: inline-block;border: 1px solid;border-radius: 3px;vertical-align: middle;text-indent: -999px;padding: 0;width: 28px;float: none;margin: -2px 7px 0 0;height: 28px;line-height: 28px;background: url({STYLEIMGDIR}/snsicon_n.png) no-repeat;}
  6. .viewthread_share .bdsharebuttonbox .bds_tsina {background-position: -1px -1px;border-color: #d2423c;border-radius: 5px;box-shadow: 0 0 5px 0px #d2423c;}
  7. .viewthread_share .bdsharebuttonbox .bds_weixin {background-position: -1px -31px;border-color: #39b41c;border-radius: 5px;box-shadow: 0 0 5px 0px #39b41c;}
  8. .viewthread_share .bdsharebuttonbox .bds_qzone {background-position: -1px -61px;border-color: #1499f7;border-radius: 5px;box-shadow: 0 0 5px 0px #1499f7;}
  9. .viewthread_share .bdsharebuttonbox .bds_more {background-position: -1px -91px;border-color: #aaa;}
  10. .viewthread_share .bdsharebuttonbox .bds_qzone:hover { background-position: -1px -181px;background-color: #1499f7;}
  11. .viewthread_share .bdsharebuttonbox .bds_tsina:hover {background-position: -1px -121px; background-color: #d2423c;}
  12. .viewthread_share .bdsharebuttonbox .bds_weixin:hover {background-position: -1px -151px;background-color: #39b41c;}
  13. .viewthread_share .bdsharebuttonbox .bds_more:hover {background-position: -1px -211px;background-color: #aaa;}
  14. .viewthread_share .cutlines { float: left;margin: 5px 11px 0px 0px; color: #ccc;display: inline-block;vertical-align: middle; }
  15. .viewthread_share .k_favorite {padding: 0 10px;height: 29px;line-height: 29px;border: 1px solid #4fc277;font-size: 14px;color: #4fc277;border-radius: 2px;display: inline-block;vertical-align: middle;zoom: 1;overflow: hidden;}
  16. .viewthread_share .bdsharebuttonbox a {
  17.     display: inline-block;
  18.     border: 1px solid;
  19.     border-radius: 3px;
  20.     vertical-align: middle;
  21.     text-indent: -999px;
  22.     padding: 0;
  23.     width: 28px;
  24.     float: none;
  25.     margin: -2px 7px 0 0;
  26.     height: 28px;
  27.     line-height: 28px;
  28.     background: url(这里输入图标地址) no-repeat;
  29. }
复制代码



分享图标:
3745.png



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|网站地图|文强阁

相关侵权、举报、投诉及建议等,请发 E-mail:admin@discuz.vip

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖
返回顶部