书评主要逻辑修改

This commit is contained in:
yanwenlong
2023-10-01 21:58:12 +08:00
parent dedd92e58f
commit 9ecd033775
2 changed files with 193 additions and 50 deletions

View File

@@ -72,7 +72,7 @@
<view v-if="plList.length > 0">
<view class="pl-item" v-for="item in plList" :key="item.id">
<view class="plusername">{{item.user.name}}</view>
<view class="content" v-html="item.phtml"></view>
<view class="content" v-html="item.content"></view>
<!-- <view class="btns flexbox"> -->
<!-- <span class="time">{{formatTimeDifferenceFromT(item.createTime)}}</span> -->
<!-- <span class="flexbox opbtns">
@@ -106,6 +106,7 @@
<!-- <view style="color: #C0C4CC;" @click="pinglun(item1)">{{item1.commentsNum}}</view> -->
</span>
</view>
<view style="border-bottom:2rpx solid #e9e9e9;height:20rpx;" v-if="index<item.comments.length-1"></view>
</view>
</view>
<!-- </view> -->
@@ -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<this.plList.length;i++){
if(this.plList[i].id == comment.pid){
comment.content = this.getHtmlComment(comment.content)
console.log('this.userInfo',this.userInfo)
comment.user = this.userInfo
comment.puser = this.plList[i].user
// comment.comments = []
this.plList[i].comments.push(comment)
}
}
}
}
}).catch((e)=>{
@@ -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{