|
@@ -108,7 +108,7 @@ $(function () {
|
|
|
$.ajax({
|
|
|
method: "get",
|
|
|
dataType: "json",
|
|
|
- url: globalConfig.context + "/open/comment/list",
|
|
|
+ url: globalConfig.context + "/open/unlanded/comment/list",
|
|
|
data: {
|
|
|
pageNo: pageNo || 1,
|
|
|
pageSize:4,
|
|
@@ -128,7 +128,7 @@ $(function () {
|
|
|
theArrs.push(`
|
|
|
<li>
|
|
|
<div class="stasf">
|
|
|
- <p>用户 :<span class="uName">${thisdata.commenter}</span></p>
|
|
|
+ <p>用户名 :<span class="uName">${thisdata.uname}</span></p>
|
|
|
<div class="satisfied">
|
|
|
<span>满意度:</span>
|
|
|
<ol>
|
|
@@ -140,17 +140,16 @@ $(function () {
|
|
|
</ol>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div><time>${times}</time></div>
|
|
|
<div class="satisfiedContent">
|
|
|
<p>${thisdata.content}</p>
|
|
|
- <time>${times}</time>
|
|
|
</div>
|
|
|
</li>`);
|
|
|
};
|
|
|
- console.log(data.data)
|
|
|
if(data.data.totalCommentCount>0){
|
|
|
- let good = ((data.data.positiveCommentCount)/(data.data.totalCommentCount)).toFixed(2)*100,
|
|
|
- middle = ((data.data.ordinaryCommentCount)/(data.data.totalCommentCount)).toFixed(2)*100,
|
|
|
- bad = ((data.data.negativeCommentCount)/(data.data.totalCommentCount)).toFixed(2)*100;
|
|
|
+ let good = (((data.data.positiveCommentCount)/(data.data.totalCommentCount))*100).toFixed(1),
|
|
|
+ middle = (((data.data.ordinaryCommentCount)/(data.data.totalCommentCount))*100).toFixed(1),
|
|
|
+ bad = (100-good-middle).toFixed(1);
|
|
|
$('.commentDetails').html(`
|
|
|
评价 :<span>好评(${good+'%'})</span><span>中评(${middle+'%'})</span><span>差评(${bad+'%'})</span>
|
|
|
`)
|
|
@@ -160,11 +159,13 @@ $(function () {
|
|
|
$('.numberBars').html(data.data.totalCommentCount>10?'10+':data.data.totalCommentCount)
|
|
|
$('.evaluateList>ul').empty();
|
|
|
$('.evaluateList>ul').append(theArrs.join(''));
|
|
|
- $('.pagination_box').css('display', 'block');
|
|
|
- if (data.data.comments.list.length === 0) {
|
|
|
- $('.evaluateList ul').html("<div class='list_none'>暂无评论</div>");
|
|
|
+
|
|
|
+ if (!(data.data.comments.list.length)) {
|
|
|
+ $('.evaluateList>ul').html("<div class='list_none'>暂无评论</div>");
|
|
|
$('.pagination_box').css('display', 'none')
|
|
|
- };
|
|
|
+ }else{
|
|
|
+ $('.pagination_box').css('display', 'block');
|
|
|
+ }
|
|
|
thePageLength = data.data.comments.totalCount ? Math.ceil(data.data.comments.totalCount / pageSize) : 1;
|
|
|
$('.totalCount').html(`共${data.data.comments.totalCount}条数据 ${thePageLength}页`)
|
|
|
var pageArr = [],
|
|
@@ -187,7 +188,6 @@ $(function () {
|
|
|
);
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
$('.pageNumber').remove();
|
|
|
$('.pagePre').after(pageArr.join(''));
|
|
|
}
|
|
@@ -231,4 +231,49 @@ $(function () {
|
|
|
$('#msg').val('');
|
|
|
}, 2000)
|
|
|
}
|
|
|
+ //评论星星
|
|
|
+ star();
|
|
|
+ function star(){
|
|
|
+ $('.commentStar .ulStar span').hover(function(){
|
|
|
+ $(this).addClass('glyphicon-star').removeClass('glyphicon-star-empty').prevAll().addClass('glyphicon-star').removeClass('glyphicon-star-empty');
|
|
|
+ $(this).nextAll().removeClass('glyphicon-star').addClass('glyphicon-star-empty').stop(true);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //新建评论
|
|
|
+ addComment();
|
|
|
+ function addComment(){
|
|
|
+ $('.CommentSend .btn').click(function(e){
|
|
|
+ e.preventDefault();
|
|
|
+ let starNum = $('.commentStar .ulStar span.glyphicon-star').length,
|
|
|
+ textVal = $('#commentArea').val();
|
|
|
+ console.log(starNum,textVal)
|
|
|
+ if(!starNum){
|
|
|
+ msg('请您选择星级!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(!textVal){
|
|
|
+ msg('请您填写评论内容!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ method:'post',
|
|
|
+ url: globalConfig.context + "/open/addComment",
|
|
|
+ dataType:'json',
|
|
|
+ data:{
|
|
|
+ commodityId:ids,
|
|
|
+ content:textVal,
|
|
|
+ star:starNum,
|
|
|
+ }
|
|
|
+ }).done(function(data){
|
|
|
+ if(data&&data.error.length){
|
|
|
+ msg(data.error[0].message);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ msg('评论成功,感谢您的评论。');
|
|
|
+ $('#commentArea').val('');
|
|
|
+ $('.ulStar span').removeClass('glyphicon-star').addClass('glyphicon-star-empty');
|
|
|
+ loadDate();
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|