|
|
@ -1,45 +1,78 @@ |
|
|
|
<template> |
|
|
|
<view class="comment" @click="navigateToSubComment(item)"> |
|
|
|
<view class="box"> |
|
|
|
<view class="headPortraitimg"> |
|
|
|
<view class="comment"> |
|
|
|
<view class="comment-header"> |
|
|
|
<view class="avatar"> |
|
|
|
<image :src="item.userHead" |
|
|
|
@click.stop="previewImage([item.userHead])" |
|
|
|
mode="aspectFill"></image> |
|
|
|
</view> |
|
|
|
<view class="YaoduUniversalWall"> |
|
|
|
<view class="heide"> |
|
|
|
<view class="username text-ellipsis"> |
|
|
|
{{ item.userName }} |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="Times"> |
|
|
|
<view class="TimeMonth"> |
|
|
|
{{ item.createTime }}发布 |
|
|
|
</view> |
|
|
|
<view class="user-info"> |
|
|
|
<view class="username">{{ item.userName }}</view> |
|
|
|
<view class="comment-content" v-html="$utils.stringFormatHtml(item.userValue)"></view> |
|
|
|
<view class="comment-meta"> |
|
|
|
<text class="time">{{ item.createTime }}</text> |
|
|
|
<text class="location">贵州</text> |
|
|
|
<text class="reply-btn" @click.stop="handleReply">回复</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="dynamics" v-html="$utils.stringFormatHtml(item.userValue)"> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="images"> |
|
|
|
<!-- 主评论图片 --> |
|
|
|
<view class="images" v-if="images && images.length > 0"> |
|
|
|
<view class="image" |
|
|
|
@click.stop="previewImage(images, i)" |
|
|
|
:key="i" v-for="(img, i) in images"> |
|
|
|
<image :src="img" mode="aspectFill"></image> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 子评论列表 --> |
|
|
|
<view class="sub-comments-list" v-if="subComments && subComments.length > 0"> |
|
|
|
<view class="sub-comment-item" v-for="(subComment, index) in subComments" :key="subComment.id"> |
|
|
|
<view class="sub-comment-header"> |
|
|
|
<view class="sub-avatar"> |
|
|
|
<image :src="subComment.userHead" mode="aspectFill" @click.stop="previewImage([subComment.userHead])"></image> |
|
|
|
</view> |
|
|
|
<view class="sub-user-info"> |
|
|
|
<view class="sub-username"> |
|
|
|
<text>{{ subComment.userName }}</text> |
|
|
|
<!-- 显示回复信息 --> |
|
|
|
<text class="reply-to" v-if="subComment.replyToName">回复 @{{ subComment.replyToName }}:</text> |
|
|
|
</view> |
|
|
|
<view class="sub-comment-content" v-html="$utils.stringFormatHtml(subComment.userValue)"></view> |
|
|
|
<view class="sub-comment-meta"> |
|
|
|
<text class="sub-time">{{ subComment.createTime }}</text> |
|
|
|
<text class="sub-reply-btn" @click.stop="handleSubReply(subComment)">回复</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 子评论图片 --> |
|
|
|
<view class="sub-comment-images" v-if="subComment.userImage"> |
|
|
|
<view class="sub-image" |
|
|
|
@click.stop="previewImage(subComment.userImage.split(','), i)" |
|
|
|
:key="i" v-for="(img, i) in subComment.userImage.split(',')"> |
|
|
|
<image :src="img" mode="aspectFill"></image> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 加载更多子评论按钮 --> |
|
|
|
<view class="load-more-section" v-if="item.replyNum && item.replyNum > 0 && (!subComments || subComments.length === 0)"> |
|
|
|
<view class="load-more-btn" @click.stop="loadSubComments"> |
|
|
|
<text class="load-more-text">查看{{item.replyNum}}条回复</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
export default { |
|
|
|
props : ['item', 'parentId', 'sourceType', 'sourceId'], |
|
|
|
props : ['item', 'parentId', 'sourceType', 'sourceId', 'subComments'], |
|
|
|
data() { |
|
|
|
return { |
|
|
|
|
|
|
|
isLoadingSubComments: false // 添加加载状态 |
|
|
|
} |
|
|
|
}, |
|
|
|
computed : { |
|
|
@ -48,7 +81,7 @@ |
|
|
|
return [] |
|
|
|
} |
|
|
|
return this.item.userImage.split(',') |
|
|
|
}, |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 导航到子评论详情 |
|
|
@ -57,6 +90,34 @@ |
|
|
|
url: `/pages_order/comment/commentDetail?id=${comment.id}&parentId=${this.parentId}&sourceType=${this.sourceType}&sourceId=${this.sourceId}` |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 加载子评论 |
|
|
|
loadSubComments() { |
|
|
|
if (this.isLoadingSubComments) return; // 防止重复加载 |
|
|
|
|
|
|
|
this.isLoadingSubComments = true; |
|
|
|
uni.showLoading({ |
|
|
|
title: '加载中...' |
|
|
|
}); |
|
|
|
|
|
|
|
this.$emit('loadSubComments', this.item); |
|
|
|
|
|
|
|
// 模拟加载完成后的状态重置 |
|
|
|
setTimeout(() => { |
|
|
|
this.isLoadingSubComments = false; |
|
|
|
uni.hideLoading(); |
|
|
|
}, 1000); |
|
|
|
}, |
|
|
|
|
|
|
|
// 处理回复 |
|
|
|
handleReply() { |
|
|
|
this.$emit('reply', this.item); |
|
|
|
}, |
|
|
|
|
|
|
|
// 处理子评论回复 |
|
|
|
handleSubReply(subComment) { |
|
|
|
this.$emit('reply', subComment); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
@ -65,17 +126,20 @@ |
|
|
|
.comment { |
|
|
|
background-color: #fff; |
|
|
|
padding: 30rpx 40rpx; |
|
|
|
margin-top: 10rpx; |
|
|
|
margin-bottom: 2rpx; |
|
|
|
border-bottom: 2rpx solid #f5f5f5; |
|
|
|
|
|
|
|
.box { |
|
|
|
.comment-header { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
align-items: flex-start; |
|
|
|
|
|
|
|
.headPortraitimg { |
|
|
|
.avatar { |
|
|
|
width: 80rpx; |
|
|
|
height: 80rpx; |
|
|
|
border-radius: 15rpx; |
|
|
|
border-radius: 50%; |
|
|
|
overflow: hidden; |
|
|
|
margin-right: 20rpx; |
|
|
|
flex-shrink: 0; |
|
|
|
|
|
|
|
image { |
|
|
|
width: 100%; |
|
|
@ -83,23 +147,47 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.YaoduUniversalWall { |
|
|
|
padding: 0rpx 10rpx; |
|
|
|
font-size: 26rpx; |
|
|
|
line-height: 40rpx; |
|
|
|
.user-info { |
|
|
|
flex: 1; |
|
|
|
|
|
|
|
.Times { |
|
|
|
font-size: 22rpx; |
|
|
|
.username { |
|
|
|
font-size: 28rpx; |
|
|
|
font-weight: 600; |
|
|
|
color: $uni-text-color; |
|
|
|
margin-bottom: 8rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.dynamics { |
|
|
|
margin-top: 20rpx; |
|
|
|
margin-left: 100rpx; |
|
|
|
font-size: 28rpx; |
|
|
|
letter-spacing: 3rpx; |
|
|
|
word-break: break-all; |
|
|
|
.comment-content { |
|
|
|
font-size: 30rpx; |
|
|
|
line-height: 1.5; |
|
|
|
color: $uni-text-color; |
|
|
|
margin-bottom: 12rpx; |
|
|
|
word-break: break-all; |
|
|
|
} |
|
|
|
|
|
|
|
.comment-meta { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
font-size: 24rpx; |
|
|
|
color: $uni-text-color-grey; |
|
|
|
|
|
|
|
.time { |
|
|
|
margin-right: 20rpx; |
|
|
|
} |
|
|
|
|
|
|
|
.location { |
|
|
|
margin-right: 20rpx; |
|
|
|
} |
|
|
|
|
|
|
|
.reply-btn { |
|
|
|
color: $uni-text-color-grey; |
|
|
|
padding: 8rpx 16rpx; |
|
|
|
background-color: #f5f5f5; |
|
|
|
border-radius: 20rpx; |
|
|
|
font-size: 22rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.images { |
|
|
@ -107,14 +195,132 @@ |
|
|
|
flex-wrap: wrap; |
|
|
|
margin-top: 20rpx; |
|
|
|
margin-left: 100rpx; |
|
|
|
|
|
|
|
.image { |
|
|
|
margin: 10rpx; |
|
|
|
|
|
|
|
image { |
|
|
|
height: 120rpx; |
|
|
|
width: 120rpx; |
|
|
|
border-radius: 20rpx; |
|
|
|
border-radius: 12rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 子评论列表样式 |
|
|
|
.sub-comments-list { |
|
|
|
margin-top: 20rpx; |
|
|
|
margin-left: 100rpx; |
|
|
|
|
|
|
|
.sub-comment-item { |
|
|
|
margin-bottom: 30rpx; |
|
|
|
|
|
|
|
&:last-child { |
|
|
|
margin-bottom: 0; |
|
|
|
} |
|
|
|
|
|
|
|
.sub-comment-header { |
|
|
|
display: flex; |
|
|
|
align-items: flex-start; |
|
|
|
|
|
|
|
.sub-avatar { |
|
|
|
width: 60rpx; |
|
|
|
height: 60rpx; |
|
|
|
border-radius: 50%; |
|
|
|
overflow: hidden; |
|
|
|
margin-right: 16rpx; |
|
|
|
flex-shrink: 0; |
|
|
|
|
|
|
|
image { |
|
|
|
width: 100%; |
|
|
|
height: 100%; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.sub-user-info { |
|
|
|
flex: 1; |
|
|
|
|
|
|
|
.sub-username { |
|
|
|
font-size: 26rpx; |
|
|
|
font-weight: 600; |
|
|
|
color: $uni-text-color; |
|
|
|
margin-bottom: 6rpx; |
|
|
|
|
|
|
|
.reply-to { |
|
|
|
font-size: 24rpx; |
|
|
|
color: $uni-color-primary; |
|
|
|
font-weight: 500; |
|
|
|
margin-left: 10rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.sub-comment-content { |
|
|
|
font-size: 28rpx; |
|
|
|
line-height: 1.5; |
|
|
|
color: $uni-text-color; |
|
|
|
margin-bottom: 10rpx; |
|
|
|
word-break: break-all; |
|
|
|
} |
|
|
|
|
|
|
|
.sub-comment-meta { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
font-size: 22rpx; |
|
|
|
color: $uni-text-color-grey; |
|
|
|
|
|
|
|
.sub-time { |
|
|
|
margin-right: 16rpx; |
|
|
|
} |
|
|
|
|
|
|
|
.sub-location { |
|
|
|
margin-right: 16rpx; |
|
|
|
} |
|
|
|
|
|
|
|
.sub-reply-btn { |
|
|
|
color: $uni-text-color-grey; |
|
|
|
padding: 6rpx 12rpx; |
|
|
|
background-color: #f5f5f5; |
|
|
|
border-radius: 16rpx; |
|
|
|
font-size: 20rpx; |
|
|
|
margin-left: auto; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.sub-comment-images { |
|
|
|
display: flex; |
|
|
|
flex-wrap: wrap; |
|
|
|
margin-top: 12rpx; |
|
|
|
margin-left: 76rpx; |
|
|
|
|
|
|
|
.sub-image { |
|
|
|
margin-right: 8rpx; |
|
|
|
margin-bottom: 8rpx; |
|
|
|
|
|
|
|
image { |
|
|
|
width: 96rpx; |
|
|
|
height: 96rpx; |
|
|
|
border-radius: 8rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.load-more-section { |
|
|
|
margin-top: 20rpx; |
|
|
|
margin-left: 100rpx; |
|
|
|
|
|
|
|
.load-more-btn { |
|
|
|
display: inline-flex; |
|
|
|
align-items: center; |
|
|
|
padding: 8rpx 16rpx; |
|
|
|
background-color: #f5f5f5; |
|
|
|
border-radius: 20rpx; |
|
|
|
font-size: 24rpx; |
|
|
|
color: $uni-text-color-grey; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |