添加评论回复功能

This commit is contained in:
2023-06-09 15:48:57 +08:00
parent 345c2614cf
commit ddc99aeaad
4 changed files with 127 additions and 19 deletions

View File

@@ -251,21 +251,21 @@
</div>
</div>
</div>
<div class="comments">
<div class="comment-wrap">
<div class="photo">
<div class="avatar" style="background-image: url('./static/img/头像修改.png')"></div>
</div>
<div class="comment-block">
<form action="">
<textarea name="" cols="30" rows="3" placeholder="Say somthing..."
style="resize:none"></textarea>
<button type="button" class="layui-btn layui-btn-xs">
<i class="layui-icon layui-icon-release"></i> 回复
</button>
</form>
</div>
</div>
<%-- <div class="comments">--%>
<%-- <div class="comment-wrap">--%>
<%-- <div class="photo">--%>
<%-- <div class="avatar" style="background-image: url('./static/img/头像修改.png')"></div>--%>
<%-- </div>--%>
<%-- <div class="comment-block">--%>
<%-- <form action="">--%>
<%-- <textarea name="content" id="replyContent" cols="30" rows="3" placeholder="Say somthing..."--%>
<%-- style="resize:none"></textarea>--%>
<%-- <button type="button" class="layui-btn layui-btn-xs" onclick="reply(${list.userId})">--%>
<%-- <i class="layui-icon layui-icon-release"></i> 回复--%>
<%-- </button>--%>
<%-- </form>--%>
<%-- </div>--%>
<%-- </div>--%>
</c:when>
<c:otherwise>
<div class="comments">
@@ -275,9 +275,9 @@
</div>
<div class="comment-block">
<form action="">
<textarea name="" id="" cols="30" rows="3" placeholder="Say somthing..."
<textarea name="" id="replyContent" cols="30" rows="3" placeholder="Say somthing..."
style="resize:none"></textarea>
<button type="button" class="layui-btn layui-btn-xs">
<button type="button" class="layui-btn layui-btn-xs" onclick="reply(${list.userId})">
<i class="layui-icon layui-icon-release"></i> 回复
</button>
</form>
@@ -329,7 +329,7 @@
})
})
// 发布评论
function publish() {
var name = document.getElementById('name').value;
var qq = document.getElementById('qq').value;
@@ -353,7 +353,24 @@
console.log(result);
})
}
// 回复
function reply(userId){
var content = document.getElementById('replyContent').value;
axios({
// 请求方式
method: 'post',
// 请求的地址
url: 'http://localhost:8080${pageContext.request.contextPath}/reply',
// URL 中的查询参数
params: {
userId: userId,
replyContent:content
}
}).then(function (result) {
//定位 span id 名称 error 修改
console.log(result);
})
}
$(function () {
// 还能输入的字得个数