Commit 1eff28d9 authored by yuwenwen's avatar yuwenwen

移动端添加评论置顶

parent e4292439
...@@ -164,3 +164,12 @@ export function updateUserInfo(data){ ...@@ -164,3 +164,12 @@ export function updateUserInfo(data){
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 @@ ...@@ -17,17 +17,32 @@
<view class="datetime">{{item.createTime}}</view> <view class="datetime">{{item.createTime}}</view>
</view> </view>
<view class="operation-text"> <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> @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>
<view v-if="activeIndex==0&&item.isFeatured==1" style="color: #F2AC39;margin-right: 10rpx;">精选</view> <view v-if="activeIndex==0&&item.isFeatured==1" style="color: #F2AC39;margin-right: 10rpx;">精选
<view style="color: #bbb;" v-if="item.isSelf==1 || userInfo.bbsAdmin" @click.stop="handleDelete(item)">删除</view> </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> </view>
<view class="content"> <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)"> <view class="text" v-else @click.stop="handleReplayComment(item)">
回复<span style="color: #0058B6;">{{item.replyNickName}}</span>{{item.content}} 回复<span style="color: #0058B6;">{{item.replyNickName}}</span>{{item.content}}
...@@ -51,9 +66,12 @@ ...@@ -51,9 +66,12 @@
import { import {
commentFeatured, commentFeatured,
delComment, delComment,
dynamicDetailComments dynamicDetailComments,
commentIsTop
} from '@/api/api.js' } from '@/api/api.js'
import { getUserInfo } from '@/utils/auth'; import {
getUserInfo
} from '@/utils/auth';
export default { export default {
name: "Comment-Item", name: "Comment-Item",
data() { data() {
...@@ -65,8 +83,8 @@ ...@@ -65,8 +83,8 @@
pageSize: 10, pageSize: 10,
momentId: '' momentId: ''
}, },
total:0, total: 0,
userInfo:{} userInfo: {}
}; };
}, },
components: { components: {
...@@ -81,9 +99,9 @@ ...@@ -81,9 +99,9 @@
} }
}, },
watch: { watch: {
form(newVal, oldVal){ form(newVal, oldVal) {
console.log(newVal, oldVal) console.log(newVal, oldVal)
if(newVal.id){ if (newVal.id) {
this.queryParams.momentId = newVal.id; this.queryParams.momentId = newVal.id;
this.commentList = []; this.commentList = [];
this.userInfo = JSON.parse(JSON.parse(getUserInfo())) this.userInfo = JSON.parse(JSON.parse(getUserInfo()))
...@@ -105,11 +123,11 @@ ...@@ -105,11 +123,11 @@
}, },
getCommentList() { getCommentList() {
dynamicDetailComments(this.queryParams).then(res => { dynamicDetailComments(this.queryParams).then(res => {
this.commentList = [...this.commentList,...res.rows] this.commentList = [...this.commentList, ...res.rows]
this.total = res.total this.total = res.total
}) })
}, },
loadMore(){ loadMore() {
this.queryParams.pageNum += 1; this.queryParams.pageNum += 1;
this.getCommentList() this.getCommentList()
}, },
...@@ -165,6 +183,34 @@ ...@@ -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 @@ ...@@ -226,16 +272,19 @@
.user-info { .user-info {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
.username { .username {
color: black; color: black;
color: #0058B6; color: #0058B6;
} }
.datetime { .datetime {
margin-left: 16rpx; margin-left: 16rpx;
color: #999999; color: #999999;
} }
.operation-text { .operation-text {
width: 180rpx; width: 260rpx;
text-align: right; text-align: right;
display: flex; display: flex;
...@@ -256,9 +305,10 @@ ...@@ -256,9 +305,10 @@
} }
.mr10{ .mr10 {
margin-right: 12rpx; margin-right: 12rpx;
} }
.add-text { .add-text {
color: #0058B6; color: #0058B6;
} }
...@@ -267,14 +317,15 @@ ...@@ -267,14 +317,15 @@
} }
} }
.show-more-box{ .show-more-box {
height: 60rpx; height: 60rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
color: #BBBBBB; color: #BBBBBB;
font-size: 24rpx; font-size: 24rpx;
.icon{
.icon {
width: 32rpx; width: 32rpx;
height: 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