Commit 1eff28d9 authored by yuwenwen's avatar yuwenwen

移动端添加评论置顶

parent e4292439
......@@ -164,3 +164,12 @@ export function updateUserInfo(data){
data
})
}
// 置顶评论,取消置顶
export function commentIsTop(data){
return request({
url:'moment/comment/top',
method:'post',
data
})
}
\ No newline at end of file
......@@ -17,17 +17,32 @@
<view class="datetime">{{item.createTime}}</view>
</view>
<view class="operation-text">
<view class="add-text mr10" v-if="form.isSelf==1&&activeIndex==1 &&item.isFeatured==0 &&form.isEnableFeaturedComment==1"
<view class="add-text mr10"
v-if="form.isSelf==1&&activeIndex==1 &&item.isFeatured==0 &&form.isEnableFeaturedComment==1"
@click="handleFeatured(item)">加入精选</view>
<view class="mr10" v-if="form.isSelf==1&&activeIndex==1 &&item.isFeatured==1&&form.isEnableFeaturedComment==1" @click="handleFeatured(item)">
<view class="mr10"
v-if="form.isSelf==1&&activeIndex==1 &&item.isFeatured==1&&form.isEnableFeaturedComment==1"
@click="handleFeatured(item)">
取消精选</view>
<view v-if="activeIndex==0&&item.isFeatured==1" style="color: #F2AC39;margin-right: 10rpx;">精选</view>
<view style="color: #bbb;" v-if="item.isSelf==1 || userInfo.bbsAdmin" @click.stop="handleDelete(item)">删除</view>
<view v-if="activeIndex==0&&item.isFeatured==1" style="color: #F2AC39;margin-right: 10rpx;">精选
</view>
<view v-if="activeIndex==0&&form.isSelf==1 && item.isTop==0" class="add-text mr10"
@click="handleIsTop(item,1)">置顶</view>
<view class="add-text mr10" v-if="form.isSelf==1&&activeIndex==0 && item.isTop==1"
@click="handleIsTop(item,0)">
取消置顶</view>
<view style="color: #bbb;margin-left: 10rpx;" v-if="item.isSelf==1 || userInfo.bbsAdmin"
@click.stop="handleDelete(item)">删除</view>
</view>
</view>
<view class="content">
<view class="text" v-if="!item.replyNickName" @click.stop="handleReplayComment(item)">{{item.content}}</view>
<view class="text" v-if="!item.replyNickName" @click.stop="handleReplayComment(item)">
{{item.content}}
</view>
<view class="text" v-else @click.stop="handleReplayComment(item)">
回复<span style="color: #0058B6;">{{item.replyNickName}}</span>{{item.content}}
......@@ -51,9 +66,12 @@
import {
commentFeatured,
delComment,
dynamicDetailComments
dynamicDetailComments,
commentIsTop
} from '@/api/api.js'
import { getUserInfo } from '@/utils/auth';
import {
getUserInfo
} from '@/utils/auth';
export default {
name: "Comment-Item",
data() {
......@@ -65,8 +83,8 @@
pageSize: 10,
momentId: ''
},
total:0,
userInfo:{}
total: 0,
userInfo: {}
};
},
components: {
......@@ -81,9 +99,9 @@
}
},
watch: {
form(newVal, oldVal){
form(newVal, oldVal) {
console.log(newVal, oldVal)
if(newVal.id){
if (newVal.id) {
this.queryParams.momentId = newVal.id;
this.commentList = [];
this.userInfo = JSON.parse(JSON.parse(getUserInfo()))
......@@ -105,11 +123,11 @@
},
getCommentList() {
dynamicDetailComments(this.queryParams).then(res => {
this.commentList = [...this.commentList,...res.rows]
this.commentList = [...this.commentList, ...res.rows]
this.total = res.total
})
},
loadMore(){
loadMore() {
this.queryParams.pageNum += 1;
this.getCommentList()
},
......@@ -165,6 +183,34 @@
}
}
});
},
handleIsTop(item, isTop) {
let _this = this;
let text = isTop == '0' ? '取消置顶' : '置顶'
let data = {
isTop,
commentId: item.id,
momentId:this.form.id,
}
let msg = `确认要${text}评论内容为:${item.content}的数据吗?`
uni.showModal({
title: '提示',
content: msg,
success: function(res) {
if (res.confirm) {
commentIsTop(data).then(res => {
if (res.code == 200) {
uni.showToast({
title: `${text}成功`
})
_this.handleRefresh()
}
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
}
}
......@@ -226,16 +272,19 @@
.user-info {
display: flex;
justify-content: space-between;
.username {
color: black;
color: #0058B6;
}
.datetime {
margin-left: 16rpx;
color: #999999;
}
.operation-text {
width: 180rpx;
width: 260rpx;
text-align: right;
display: flex;
......@@ -256,9 +305,10 @@
}
.mr10{
.mr10 {
margin-right: 12rpx;
}
.add-text {
color: #0058B6;
}
......@@ -267,14 +317,15 @@
}
}
.show-more-box{
.show-more-box {
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
color: #BBBBBB;
font-size: 24rpx;
.icon{
.icon {
width: 32rpx;
height: 32rpx;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment