国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

widget_article_digg.htm 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. {dede:comment text="顶踩模块"/}
  2. <div class="row justify-content-center digg">
  3. <div class="comment-container mb-3" onclick="javascript:PostDigg('good',{dede:field.id/})">
  4. <div class="comment-top">
  5. <i class="fa fa-thumbs-o-up" aria-hidden="true"></i>
  6. <p class="comment-top-text">顶一下[<span id="goodpost">{dede:field.goodpost/}</span>]</p>
  7. </div>
  8. <div class="progress" style="height: 10px;">
  9. <div class="progress-bar" role="progressbar" id="goodper" style="width: {dede:field.goodper/}%"
  10. aria-valuenow="{dede:field.goodper/}" aria-valuemin="0" aria-valuemax="100"></div>
  11. </div>
  12. </div>
  13. <div class="comment-container mb-3" onclick="javascript:PostDigg('bad',{dede:field.id/})">
  14. <div class="comment-top">
  15. <i class="fa fa-thumbs-o-down" aria-hidden="true"></i>
  16. <p class="comment-top-text-danger">踩一下[<span id="badpost">{dede:field.badpost/}</span>]</p>
  17. </div>
  18. <div class="progress" style="height: 10px;">
  19. <div class="progress-bar bg-danger" role="progressbar" id="badper" style="width:{dede:field.badper/}%"
  20. aria-valuenow="{dede:field.badper/}" aria-valuemin="0" aria-valuemax="100"></div>
  21. </div>
  22. </div>
  23. </div> <!-- ./digg -->
  24. <script>
  25. // 获取顶踩数据
  26. function GetDigg(aid,cid) {
  27. let url = `{dede:global.cfg_phpurl/}/digg_ajax.php?id=${aid}&cid=${cid}&format=json`;
  28. $.get(url, function (data) {
  29. let reval = JSON.parse(data);
  30. if (reval.code === 200) {
  31. $("#goodpost").html(reval.data.goodpost);
  32. $("#badpost").html(reval.data.badpost);
  33. $("#goodper").css("width", `${reval.data.goodper}%`)
  34. $("#badper").css("width", `${reval.data.badper}%`)
  35. }
  36. })
  37. }
  38. function PostDigg(ftype, aid) {
  39. var saveid = GetCookie('diggid');
  40. if (saveid != null) {
  41. var saveids = saveid.split(',');
  42. var hasid = false;
  43. saveid = '';
  44. j = 1;
  45. for (i = saveids.length - 1; i >= 0; i--) {
  46. if (saveids[i] == aid && hasid) continue;
  47. else {
  48. if (saveids[i] == aid && !hasid) hasid = true;
  49. saveid += (saveid == '' ? saveids[i] : ',' + saveids[i]);
  50. j++;
  51. if (j == 20 && hasid) break;
  52. if (j == 19 && !hasid) break;
  53. }
  54. }
  55. if (hasid) { ShowMsg("您已经顶过该帖,请不要重复顶帖 !"); return; }
  56. else saveid += ',' + aid;
  57. SetCookie('diggid', saveid, 1);
  58. }
  59. else {
  60. SetCookie('diggid', aid, 1);
  61. }
  62. let url = "{dede:global.cfg_phpurl/}/digg_ajax.php?action=" + ftype + "&id=" + aid + "&format=json&cid={dede:field.channel/}";
  63. $.get(url, function (data) {
  64. let reval = JSON.parse(data);
  65. if (reval.code === 200) {
  66. $("#goodpost").html(reval.data.goodpost);
  67. $("#badpost").html(reval.data.badpost);
  68. $("#goodper").css("width", `${reval.data.goodper}%`)
  69. $("#badper").css("width", `${reval.data.badper}%`)
  70. }
  71. });
  72. }
  73. GetDigg("{dede:field.id/}", "{dede:field.channel/}");
  74. </script>