diff --git a/admin/assets/js/comment/comment.js b/admin/assets/js/comment/comment.js index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..cf1da455875c9229b07c683ba71ae0924a4cb16c 100644 --- a/admin/assets/js/comment/comment.js +++ b/admin/assets/js/comment/comment.js @@ -0,0 +1,44 @@ +$(function() { + // 引入layui方法 + let layer = layui.layer; + // 获取列表 + getList(); + function getList() { + $.ajax({ + url: 'admin/comments', + success: function (res) { + const paddZero = (n) => (n < 10 ? "0" + n : n); + // 1. 往模板中导入过滤器函数 + template.defaults.imports.filterTime = function (time) { + // 得到年月日。。。 + let d = new Date(time); + let y = d.getFullYear(); + let m = paddZero(d.getMonth() + 1); + let day = paddZero(d.getDate()); + + return `${y}-${m}-${day}`; + }; + htmlStr = template('tb',res) + + $('.comm_list').html(htmlStr) + + } + }) + } + + // 删除评论 + $('body').on('click','.del_btn',function () { + $.ajax({ + url: 'admin/comments/' + $(this).attr('data-id'), + type: 'DELETE', + success: function (res) { + if(res.status === 0) { + layer.msg('删除成功!'); + } else { + layer.msg('删除失败!') + getList() + } + } + }) + }) +}) \ No newline at end of file diff --git a/admin/comment/comment.html b/admin/comment/comment.html index b59b1d19f622a4a129c16db2b18a0e4971b091de..60119adb2ee757db2fb8edb29f85090b0debe3b2 100644 --- a/admin/comment/comment.html +++ b/admin/comment/comment.html @@ -1,10 +1,64 @@ + + - - - 评论模块 - - - - - \ No newline at end of file + + + + 评论模块 + + + + +
+
评论管理
+
+ + + + + + + + + + + + + + + + + + + +
id评论人评论内容评论时间操作
+
+
+ + + + + + + + +