完善书评第二次提交

This commit is contained in:
yanwenlong
2023-09-26 11:10:35 +08:00
parent f397de5462
commit 6d10bf598b
2 changed files with 203 additions and 47 deletions

View File

@@ -47,8 +47,8 @@
<view class="btns flexbox" style="margin-top:10rpx;">
<span class="left" style="color: #C0C4CC;"></span>
<span class="right flexbox opbtns">
<image class="gzicon" v-if="commentInfo.ilike" src="../../static/icon/gz2.png" mode="aspectFill"></image>
<image class="gzicon" v-else src="../../static/icon/gz.png" mode="aspectFill"></image>
<image class="gzicon" v-if="commentInfo.ilike" src="../../static/icon/gz2.png" mode="aspectFill" @click.stop="clickLikeshuping(commentInfo)"></image>
<image class="gzicon" v-else src="../../static/icon/gz.png" mode="aspectFill" @click.stop="clickLikeshuping(commentInfo)"></image>
<view style="color: #C0C4CC;">{{commentInfo.contlike}}</view>
<image class="gzicon" v-if="1" src="../../static/icon/pinglun.png" mode="aspectFill" @click="pinglun()"></image>
<view style="color: #C0C4CC;" @click="pinglun()">{{commentInfo.commentNum}}</view>
@@ -73,14 +73,24 @@
<view class="item mb30" v-for="item in plList" :key="item.id">
user
<view class="content" v-html="item.phtml"></view>
<view class="btns flexbox">
<span class="time">{{item.createTime}}</span>
<!-- <view class="btns flexbox"> -->
<!-- <span class="time">{{formatTimeDifferenceFromT(item.createTime)}}</span> -->
<!-- <span class="flexbox opbtns">
<span class="flexbox pingjia" @click="pinglun(item.id)">
<u-icon name="chat" color="#888" size="26"></u-icon>
</span>
</span> -->
</view>
<view class="btns flexbox" style="margin-top:10rpx;">
<span class="left" style="color: #C0C4CC;">{{formatTimeDifferenceFromT(item.createTime)}}</span>
<span class="right flexbox opbtns">
<image class="gzicon" v-if="item.ilike" src="../../static/icon/gz2.png" mode="aspectFill" @click.stop="clickLikehuifu(item)"></image>
<image class="gzicon" v-else src="../../static/icon/gz.png" mode="aspectFill" @click.stop="clickLikehuifu(item)"></image>
<view style="color: #C0C4CC;">{{item.contlike}}</view>
<image class="gzicon" v-if="1" src="../../static/icon/pinglun.png" mode="aspectFill" @click="pinglun()"></image>
<view style="color: #C0C4CC;" @click="pinglun()">{{item.commentNum}}</view>
</span>
</view>
<!-- </view> -->
</view>
</view>
<view class="quesheng" v-else>
@@ -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;}