国内流行的内容管理系统(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.

72 lines
2.7KB

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