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

71 lines
2.7KB

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