From 6d10bf598b646bbb3b015734b7aeb186e6875a32 Mon Sep 17 00:00:00 2001 From: yanwenlong Date: Tue, 26 Sep 2023 11:10:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=B9=A6=E8=AF=84=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/comments/commentsDetail.vue | 166 +++++++++++++++++++++++------- pages/comments/commentsList.vue | 84 ++++++++++++--- 2 files changed, 203 insertions(+), 47 deletions(-) diff --git a/pages/comments/commentsDetail.vue b/pages/comments/commentsDetail.vue index 9da0ab6..05545e1 100644 --- a/pages/comments/commentsDetail.vue +++ b/pages/comments/commentsDetail.vue @@ -47,8 +47,8 @@ - - + + {{commentInfo.contlike}} {{commentInfo.commentNum}} @@ -73,14 +73,24 @@ user - - {{item.createTime}} + + - + + {{formatTimeDifferenceFromT(item.createTime)}} + + + + {{item.contlike}} + + {{item.commentNum}} + + + @@ -210,34 +220,34 @@ } } }, - // 获得书评评论列表 + // 获得书评回复列表 getCommPL(){ let data = { - 'bfa_id':this.bfa_id, + 'forumId':this.bfa_id, 'limit': 5, 'page': this.pPage, } console.log(data,'data') this.$http - .post('forum/comment/list', data) + .post('forum/articles/getCommentByForum', data) .then(res => { if(res.code == 0){ console.log(res,'书评评论') // this.plList = this.plList.concat(res.page.list) - this.plList = res.page.list - this.pTotal = res.page.totalPage + let plList1 = res.page.records + this.pTotal = res.page.size this.status = 3 // 评论格式化 var newarr = [] - this.plList.forEach((item1)=>{ + plList1.forEach((item1)=>{ var pjstr = '' pjstr = this.getHtmlComment(item1.content) - item1.phtml = pjstr - // console.log(pjstr) - newarr.push(item1) + item1.phtml = pjstr + // console.log(pjstr) + newarr.push(item1) }) - this.plList = newarr + this.plList = this.plList.concat(newarr) console.log('改变格式后', this.plList) } }).catch((e)=>{ @@ -257,6 +267,41 @@ console.log(e) }) }, + clickLikeshuping(item){ + this.$http + .post("forum/articles/chickForumContlike?forum_id=" + item.id,) + .then(res => { + if (res.code == 0) { + uni.showToast({ + title:'点赞成功!', + icon:'success' + }) + + item.contlike++ + } + }).catch((e)=>{ + console.log(e,'e') + }) + }, + clickLikehuifu(item){ + let data = { + comment_id: item.id + } + this.$http + .post("forum/articles/chickCommentConlike", data) + .then(res => { + if (res.code == 0) { + uni.showToast({ + title:'点赞成功!', + icon:'success' + }) + + item.contlike++ + } + }).catch((e)=>{ + console.log(e,'e') + }) + }, getProDetail(){ // 获取商品详情 uni.showLoading({ @@ -404,33 +449,61 @@ submitPJ(){ if(this.Pform.comment != ''){ - let data={ - 'content':this.Pform.comment, - 'userid':this.userInfo.id, - 'bookid':this.bookid, - 'bfaid' : this.bfa_id, - // 'id': this.pinglunId + // let data={ + // 'content':this.Pform.comment, + // 'userid':this.userInfo.id, + // 'bookid':this.bookid, + // 'bfaid' : this.bfa_id, + // // 'id': this.pinglunId + // } + // console.log(data,'data') + + + let data = { + forumId : this.bfa_id, + userId: this.userInfo.id, + content: this.Pform.comment, + pid: '', + puserId: '', } - console.log(data,'data') - $http.request({ - url: "forum/comment/save", - method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 - data, - header: { //默认 无 说明:请求头 - 'Content-Type': 'application/json' - }, - }).then(res => { - if (res.code == 0) { + this.$http + .post("forum/articles/pushMsgToForum", data) + .then(res => { + if (res.code == 0) { + if (res.code == 0) { uni.showToast({ title:'评论成功!', icon:'success' }) - this.getCommPL() + // this.getCommPL() this.pingjiaShow = false this.Pform.comment = '' this.pinglunId = null } - }) + } + }).catch((e)=>{ + console.log(e,'e') + }) + + // $http.request({ + // url: "forum/comment/save", + // method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 + // data, + // header: { //默认 无 说明:请求头 + // 'Content-Type': 'application/json' + // }, + // }).then(res => { + // if (res.code == 0) { + // uni.showToast({ + // title:'评论成功!', + // icon:'success' + // }) + // this.getCommPL() + // this.pingjiaShow = false + // this.Pform.comment = '' + // this.pinglunId = null + // } + // }) }else{ uni.showToast({ title:'请先输入您的评价内容 !', @@ -460,12 +533,35 @@ h4{color: #55aa00; font-size: 40rpx; margin:30rpx 0 ; text-align: center;} .time{color: #888; font-size: 24rpx;} .btns{ - color: #666; justify-content: space-between; + font-size: 22rpx; + justify-content: space-between; + align-items: center; + .left{ + width: 300rpx; + color: #a1a1a1; + } + .right{ + width: 300rpx; + display: flex; + justify-content: flex-end; + align-items: center; + } + .gzicon{ + margin:0 0 0 20rpx; + height: 40rpx; + width: 40rpx; + // float:left; + // border-radius: 20rpx; + // border:1rpx solid #e9e9e9; + } + .opbtns{ + .pingjia{margin-left: 10px;} + } } } // .mbtns{padding: 5px; background-color: #f4fff5; border-radius: 10px; font-size: 34rpx; color: #8b8a91; margin:15px 0; justify-content: space-between;} - .zhengwen{line-height: 50rpx; font-size: 30rpx;margin-top: 20rpx;} + .zhengwen{line-height: 50rpx; font-size: 28rpx;margin-top: 20rpx;} .flexbox{display: flex;} .container{padding: 10px;} .star{display: inline-block; width: 20px; height: 20px; margin-right: 10rpx;} diff --git a/pages/comments/commentsList.vue b/pages/comments/commentsList.vue index 546dcab..b7fee8f 100644 --- a/pages/comments/commentsList.vue +++ b/pages/comments/commentsList.vue @@ -31,8 +31,43 @@ {{formatTimeDifferenceFromT(item.createTime)}} - - + + + {{item.contlike}} + + {{item.commentNum}} + + + + + + + + + 暂无书评内容~ + + + + + + + + + {{item.title}} + + + + + {{item.bookname}} + + 全文 + + + + {{formatTimeDifferenceFromT(item.createTime)}} + + + {{item.contlike}} {{item.commentNum}} @@ -54,7 +89,7 @@ {{item.name}} - {{item.id}}篇书评 + {{item.forumNum}}篇书评 @@ -145,14 +180,20 @@ import { data } from 'jquery'; console.log('下拉刷新了') uni.stopPullDownRefresh(); - this.booklistpage=1, // 页码 - this.productList = [] - this.getBookList() + this.newestpage = 1 + this.hotestpage = 1 + this.booksetpage = 1 + this.newList = [] + this.hotList = [] + this.bookList = [] + this.getBookList(this.commentsListTab, true) }, onReachBottom() { - this.booklistpage++ - this.getBookList() + this.newestpage++ + this.hotestpage++ + this.booksetpage++ + this.getBookList(this.commentsListTab, true) }, onLoad(e) { this.windowWidth = uni.getSystemInfoSync().windowWidth; @@ -196,6 +237,9 @@ import { data } from 'jquery'; // 切换tab状态 commentsTabCLi(e) { this.commentsListTab = e + this.newestpage = 1 + this.hotestpage = 1 + this.booksetpage = 1 this.newList = [] this.hotList = [] this.bookList = [] @@ -215,6 +259,22 @@ import { data } from 'jquery'; url:'../comments/commentsDetail?bookid='+val.bookid+'&bfa_id='+val.id }) }, + clickLike(item){ + this.$http + .post("forum/articles/chickForumContlike?forum_id=" + item.id,) + .then(res => { + if (res.code == 0) { + uni.showToast({ + title:'点赞成功!', + icon:'success' + }) + + item.contlike++ + } + }).catch((e)=>{ + console.log(e,'e') + }) + }, getBookList(flag, clear){ // 根据tab不同,获取最新书评、最热书评、书集列表 uni.showLoading({ @@ -226,7 +286,7 @@ import { data } from 'jquery'; }else if(flag == 2){ httpurl = "forum/articles/getForumsHot?page=" + this.hotestpage + '&limit=10' }else{ - httpurl = "forum/articles/getForumsAndBook?page=" + this.booksetpage + '&limit=10&userId=10100'// + this.userId + httpurl = "forum/articles/getForumsAndBook?page=" + this.booksetpage + '&limit=10&userId=' + this.userInfo.id } this.$http .post(httpurl) @@ -459,10 +519,10 @@ import { data } from 'jquery'; -webkit-line-clamp: 5; line-clamp: 5; -webkit-box-orient: vertical; - font-size: 24rpx; + font-size: 26rpx; margin-bottom: 20rpx; margin-top:10rpx; - min-height: 144rpx; + height: 172rpx; } .btns{ font-size: 22rpx; @@ -540,7 +600,7 @@ import { data } from 'jquery'; -webkit-line-clamp: 1; line-clamp: 1; -webkit-box-orient: vertical; - font-size: 24rpx; + font-size: 26rpx; margin-bottom: 20rpx; margin-top:10rpx; }