diff --git a/pages/comments/comments.vue b/pages/comments/comments.vue index 50eaa45..e4b2cbe 100644 --- a/pages/comments/comments.vue +++ b/pages/comments/comments.vue @@ -18,7 +18,11 @@ 作者:{{productInfo.authorName}} - 听书、读书打卡、立即购买 + + 听书 + 读书打卡 + 立即购买 + @@ -29,6 +33,16 @@ + + {{shupingNum || 0}}条书评 + + + 按时间 + + 按热度 + + {{item.title}} @@ -39,14 +53,16 @@ {{formatTimeDifferenceFromT(item.createTime)}} - - + + {{item.contlike}} - - {{item.commentNum}} + + + {{item.commentNum}} - + @@ -126,6 +142,15 @@ import { data } from 'jquery'; export default { data() { return { + orderListTab: 1, + orderTabs: [{ + name: '按时间', + value: 1 + }, { + name: '按热度', + value: 2 + }], + shupingNum: 0, loadingNow : false, playData:{}, isShowEmj: false, @@ -156,7 +181,7 @@ import { data } from 'jquery'; this.page=1, // 页码 this.shupingList = [] - this.getBookCom() + this.getBookCom(this.orderListTab) }, onReachBottom() { @@ -165,7 +190,7 @@ import { data } from 'jquery'; this.page++ console.log('加载',this.page) this.status = 0 - this.getBookCom() + this.getBookCom(this.orderListTab) }else{ this.status = 1 @@ -178,12 +203,55 @@ import { data } from 'jquery'; console.log(e,'onload') this.bookid = e.bookid this.getProDetail(e) - this.getBookCom() + this.getBookCom(this.orderListTab) }, computed:{ ...mapState(['userInfo']), }, methods: { + toOtherPage(e,productInfo) { + if(e==1){ + // 跳转到听书 + uni.navigateTo({ + url: "../listen/listen?bookid=" + productInfo.id + }); + } + if(e==2){ + // 跳转到读书打卡 + uni.navigateTo({ + url: '../clock/clock?bookid='+ productInfo.id + }) + } + if(e==3){ + // 跳转到购买 + uni.navigateTo({ + url: '../bookShop/commodityDetail?id=' + productInfo.id + }); + } + }, + // 切换tab状态 + orderTabCLi(e) { + this.orderListTab = e + this.page = 1 + this.shupingList = [] + this.getBookCom(this.orderListTab) + }, + 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') + }) + }, formatTimeDifferenceFromT(dateTimeT) { const now = new Date(); const t = new Date(dateTimeT); @@ -237,24 +305,26 @@ import { data } from 'jquery'; }) }, // 获得书评 - getBookCom(){ + getBookCom(flag){ let data = { 'page': this.page, 'limit': this.pageSize, - 'bookid' : this.bookid + 'bookId' : this.bookid, + 'order' : flag } console.log(data,'data') this.$http - .post('forum/articles/descupdatelist', data) + .post('forum/articles/getForumByBook', data) .then(res => { console.log(res,'获取成功') - this.total = res.page.totalPage - this.shupingList = this.shupingList.concat(res.page.list) + this.total = res.page.pages + this.shupingNum = res.page.total + this.shupingList = this.shupingList.concat(res.page.records) // console.log(res,'已购买') this.status = 3 }).catch((e)=>{ - console.log(e,'e') - }) + console.log(e,'e') + }) }, // 获得输入的表情数组 handleEmj(i) { @@ -462,18 +532,59 @@ import { data } from 'jquery'; margin-right: 5rpx; } }} - + .shuping-topbar{ + display: flex; + justify-content: space-between; + align-items: center; + .shuping-topbar-tiao{ + font-size: 28rpx; + color: #8b8a91; + } + .shuping-topbar-order{ + width: 280rpx; + display: flex; + justify-content: space-between; + align-items: center; + .orderdefine { + display: inline-block; + padding: 20rpx 0 20rpx 0; + // margin: 40rpx 0 15rpx 0; + width:230rpx; + text-align: center; + font-size: 30rpx; + } + + .ordStyle { + // border-bottom: 4rpx solid #54a966; + // color: #54a966; + font-weight: bold; + } + } + } .quesheng{text-align: center; margin-top: 100rpx; color: #8b8a91; padding-bottom: 20rpx; padding-top: 20rpx;} .bookInfo{ justify-content: space-between; margin-bottom: 15px; background-color: #fff; padding:10px; - border: 1px splid #999; + // border: 1px splid #999; box-sizing: border-box; padding-bottom: 20rpx; border-radius: 20rpx; margin-bottom: 20rpx; + .ting-du-mai{ + display: flex; + justify-content: space-between; + align-content: center; + font-size: 28rpx; + width: 400rpx; + .ting-du-mai-item{ + color: deepskyblue; + border: 1px solid deepskyblue; + border-radius: 6rpx; + padding: 4rpx 6rpx; + } + } .imageradius{ border-radius: 20rpx; border:1rpx solid #e9e9e9; @@ -522,8 +633,20 @@ import { data } from 'jquery'; border-radius: 20rpx; margin-bottom: 20rpx; } - .feng{margin:10rpx 0 0 0;height: 200rpx;width: 200rpx;float:right;border-radius: 20rpx;border:1rpx solid #e9e9e9;} - .title{font-size: 30rpx; font-weight: 700; color: #000; overflow: hidden;} + .feng{ + margin:10rpx 20rpx 0 0; + height: 160rpx; + width: 140rpx; + float:left; + border-radius: 20rpx; + border:1rpx solid #e9e9e9; + } + .title{ + font-size: 30rpx; + font-weight: 700; + color: #000; + overflow: hidden; + } .description{ overflow: hidden; color: #666; @@ -534,10 +657,10 @@ import { data } from 'jquery'; -webkit-line-clamp: 5; line-clamp: 5; -webkit-box-orient: vertical; - font-size: 28rpx; - margin-bottom: 15px; - margin-top:5px; - min-height: 186rpx; + font-size: 26rpx; + margin-bottom: 20rpx; + margin-top:10rpx; + height: 172rpx; } // .btns{ // font-size: 24rpx; diff --git a/pages/comments/commentsDetail.vue b/pages/comments/commentsDetail.vue index f827010..544471a 100644 --- a/pages/comments/commentsDetail.vue +++ b/pages/comments/commentsDetail.vue @@ -72,7 +72,7 @@ {{item.user.name}} - + + @@ -258,18 +259,15 @@ this.status = 3 // 评论格式化 var newarr = [] - plList1.forEach((item1)=>{ - var pjstr = '' - pjstr = this.getHtmlComment(item1.content) - item1.phtml = pjstr - if(item1.comments && item1.comments.length>0){ - item1.comments.forEach((item2)=>{ - var pjstr1 = '' - item2.content = this.getHtmlComment(item2.content) - }) - } - // console.log(pjstr) - newarr.push(item1) + plList1.forEach((item1)=>{ + item1.content = this.getHtmlComment(item1.content) + if(item1.comments && item1.comments.length>0){ + item1.comments.forEach((item2)=>{ + item2.content = this.getHtmlComment(item2.content) + }) + } + // console.log(pjstr) + newarr.push(item1) }) this.plList = this.plList.concat(newarr) @@ -508,18 +506,40 @@ .post("forum/articles/pushMsgToForum", data) .then(res => { if (res.code == 0) { - if (res.code == 0) { - uni.showToast({ - title:'评论成功!', - icon:'success' - }) - // this.getCommPL() - this.pingjiaShow = false - this.Pform.comment = '' - this.Pform.name = '' - this.Pform.pid = '' - this.Pform.puserId = '' - // this.pinglunId = null + uni.showToast({ + title:'评论成功!', + icon:'success' + }) + // this.getCommPL() + this.pingjiaShow = false + this.Pform.comment = '' + this.Pform.name = '' + this.Pform.pid = '' + this.Pform.puserId = '' + // this.pinglunId = null + + // 把回复的评论拼进this.plList回复列表中 + let comment = res.comment + // 第一种情况:1级回复 + if(comment&&comment.pid == 0){ + comment.content = this.getHtmlComment(comment.content) + console.log('this.userInfo',this.userInfo) + comment.user = this.userInfo + comment.comments = [] + this.plList.unshift(comment) + }else if(comment&&comment.pid > 0){// 第二种情况:回复第1级回复和回复第2级回复 + + for(let i=0;i{ @@ -569,7 +589,7 @@ border-bottom: 1px solid #f0f0f0; .pl-son{ margin: 14rpx 0 14rpx 60rpx; - padding: 0 0 14rpx 14rpx; + padding: 0 14rpx 14rpx 14rpx; background-color: #f0f0f0; border-radius: 10rpx; .pl-son-item{