瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

332 lines
7.5 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. <template>
  2. <view class="comment">
  3. <view class="comment-header">
  4. <view class="avatar">
  5. <image :src="item.userHead"
  6. @click.stop="previewImage([item.userHead])"
  7. mode="aspectFill"></image>
  8. </view>
  9. <view class="user-info">
  10. <view class="username">{{ item.userName }}</view>
  11. <view class="comment-content" v-html="$utils.stringFormatHtml(item.userValue)"></view>
  12. <view class="comment-meta">
  13. <text class="time">{{ $timeUtils.formatTime(item.createTime) }}</text>
  14. <!-- <text class="location">贵州</text> -->
  15. <text class="reply-btn" @click.stop="handleReply(0)">回复</text>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 主评论图片 -->
  20. <view class="images" v-if="images && images.length > 0">
  21. <view class="image"
  22. @click.stop="previewImage(images, i)"
  23. :key="i" v-for="(img, i) in images">
  24. <image :src="img" mode="aspectFill"></image>
  25. </view>
  26. </view>
  27. <!-- 子评论列表 -->
  28. <view class="sub-comments-list" v-if="subComments && subComments.length > 0">
  29. <view class="sub-comment-item" v-for="(subComment, index) in subComments" :key="subComment.id">
  30. <view class="sub-comment-header">
  31. <view class="sub-avatar">
  32. <image :src="subComment.userHead" mode="aspectFill" @click.stop="previewImage([subComment.userHead])"></image>
  33. </view>
  34. <view class="sub-user-info">
  35. <view class="sub-username">
  36. <text>{{ subComment.userName }}</text>
  37. <!-- 显示回复信息 -->
  38. <text class="reply-to" v-if="subComment.replyToName">回复 @{{ subComment.replyToName }}:</text>
  39. </view>
  40. <view class="sub-comment-content" v-html="$utils.stringFormatHtml(subComment.userValue)"></view>
  41. <view class="sub-comment-meta">
  42. <text class="sub-time">{{ $timeUtils.formatTime(subComment.createTime) }}</text>
  43. <!-- <text class="location">贵州</text> -->
  44. <text class="sub-reply-btn" @click.stop="handleSubReply(subComment)">回复</text>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 子评论图片 -->
  49. <view class="sub-comment-images" v-if="subComment.userImage">
  50. <view class="sub-image"
  51. @click.stop="previewImage(subComment.userImage.split(','), i)"
  52. :key="i" v-for="(img, i) in subComment.userImage.split(',')">
  53. <image :src="img" mode="aspectFill"></image>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 加载更多子评论按钮 -->
  59. <view class="load-more-section" v-if="item.replyNum && item.replyNum > 0 && (!subComments || subComments.length === 0)">
  60. <view class="load-more-btn" @click.stop="loadSubComments">
  61. <text class="load-more-text">查看{{item.replyNum}}条回复</text>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. export default {
  68. props : ['item', 'parentId', 'sourceType', 'sourceId', 'subComments'],
  69. data() {
  70. return {
  71. isLoadingSubComments: false // 添加加载状态
  72. }
  73. },
  74. computed : {
  75. images(){
  76. if(!this.item.userImage){
  77. return []
  78. }
  79. return this.item.userImage.split(',')
  80. }
  81. },
  82. methods: {
  83. // 导航到子评论详情
  84. navigateToSubComment(comment) {
  85. uni.navigateTo({
  86. url: `/pages_order/comment/commentDetail?id=${comment.id}&parentId=${this.parentId}&sourceType=${this.sourceType}&sourceId=${this.sourceId}`
  87. });
  88. },
  89. // 加载子评论
  90. loadSubComments() {
  91. if (this.isLoadingSubComments) return; // 防止重复加载
  92. this.isLoadingSubComments = true;
  93. uni.showLoading({
  94. title: '加载中...'
  95. });
  96. this.$emit('loadSubComments', this.item);
  97. // 模拟加载完成后的状态重置
  98. setTimeout(() => {
  99. this.isLoadingSubComments = false;
  100. uni.hideLoading();
  101. }, 1000);
  102. },
  103. // 处理回复
  104. handleReply() {
  105. this.$emit('reply', {
  106. item : this.item,
  107. level : 0,
  108. });
  109. },
  110. // 处理子评论回复
  111. handleSubReply(subComment) {
  112. this.$emit('reply', {
  113. item : subComment,
  114. level : 1,
  115. });
  116. }
  117. }
  118. }
  119. </script>
  120. <style scoped lang="scss">
  121. .comment {
  122. background-color: #fff;
  123. padding: 26.25rpx 35rpx;
  124. margin-bottom: 1.75rpx;
  125. border-bottom: 1.75rpx solid #f5f5f5;
  126. .comment-header {
  127. display: flex;
  128. align-items: flex-start;
  129. .avatar {
  130. width: 70rpx;
  131. height: 70rpx;
  132. border-radius: 50%;
  133. overflow: hidden;
  134. margin-right: 17.5rpx;
  135. flex-shrink: 0;
  136. image {
  137. width: 100%;
  138. height: 100%;
  139. }
  140. }
  141. .user-info {
  142. flex: 1;
  143. .username {
  144. font-size: 24.5rpx;
  145. font-weight: 600;
  146. color: $uni-text-color;
  147. margin-bottom: 7rpx;
  148. }
  149. .comment-content {
  150. font-size: 26.25rpx;
  151. line-height: 1.5;
  152. color: $uni-text-color;
  153. margin-bottom: 10.5rpx;
  154. word-break: break-all;
  155. }
  156. .comment-meta {
  157. display: flex;
  158. align-items: center;
  159. font-size: 21rpx;
  160. color: $uni-text-color-grey;
  161. .time {
  162. margin-right: 17.5rpx;
  163. }
  164. .location {
  165. margin-right: 17.5rpx;
  166. }
  167. .reply-btn {
  168. color: $uni-text-color-grey;
  169. padding: 7rpx 14rpx;
  170. background-color: #f5f5f5;
  171. border-radius: 17.5rpx;
  172. font-size: 19.25rpx;
  173. margin-left: auto;
  174. }
  175. }
  176. }
  177. }
  178. .images {
  179. display: flex;
  180. flex-wrap: wrap;
  181. margin-top: 17.5rpx;
  182. margin-left: 87.5rpx;
  183. .image {
  184. margin: 8.75rpx;
  185. image {
  186. height: 105rpx;
  187. width: 105rpx;
  188. border-radius: 10.5rpx;
  189. }
  190. }
  191. }
  192. // 子评论列表样式
  193. .sub-comments-list {
  194. margin-top: 17.5rpx;
  195. margin-left: 87.5rpx;
  196. .sub-comment-item {
  197. margin-bottom: 26.25rpx;
  198. &:last-child {
  199. margin-bottom: 0;
  200. }
  201. .sub-comment-header {
  202. display: flex;
  203. align-items: flex-start;
  204. .sub-avatar {
  205. width: 52.5rpx;
  206. height: 52.5rpx;
  207. border-radius: 50%;
  208. overflow: hidden;
  209. margin-right: 14rpx;
  210. flex-shrink: 0;
  211. image {
  212. width: 100%;
  213. height: 100%;
  214. }
  215. }
  216. .sub-user-info {
  217. flex: 1;
  218. .sub-username {
  219. font-size: 22.75rpx;
  220. font-weight: 600;
  221. color: $uni-text-color;
  222. margin-bottom: 5.25rpx;
  223. .reply-to {
  224. font-size: 21rpx;
  225. color: $uni-color-primary;
  226. font-weight: 500;
  227. margin-left: 8.75rpx;
  228. }
  229. }
  230. .sub-comment-content {
  231. font-size: 24.5rpx;
  232. line-height: 1.5;
  233. color: $uni-text-color;
  234. margin-bottom: 8.75rpx;
  235. word-break: break-all;
  236. }
  237. .sub-comment-meta {
  238. display: flex;
  239. align-items: center;
  240. font-size: 19.25rpx;
  241. color: $uni-text-color-grey;
  242. .sub-time {
  243. margin-right: 14rpx;
  244. }
  245. .sub-location {
  246. margin-right: 14rpx;
  247. }
  248. .sub-reply-btn {
  249. color: $uni-text-color-grey;
  250. padding: 5.25rpx 10.5rpx;
  251. background-color: #f5f5f5;
  252. border-radius: 14rpx;
  253. font-size: 17.5rpx;
  254. margin-left: auto;
  255. }
  256. }
  257. }
  258. }
  259. .sub-comment-images {
  260. display: flex;
  261. flex-wrap: wrap;
  262. margin-top: 10.5rpx;
  263. margin-left: 66.5rpx;
  264. .sub-image {
  265. margin-right: 7rpx;
  266. margin-bottom: 7rpx;
  267. image {
  268. width: 84rpx;
  269. height: 84rpx;
  270. border-radius: 7rpx;
  271. }
  272. }
  273. }
  274. }
  275. }
  276. .load-more-section {
  277. margin-left: 87.5rpx;
  278. .load-more-btn {
  279. display: inline-flex;
  280. align-items: center;
  281. padding: 7rpx 14rpx;
  282. background-color: #f5f5f5;
  283. border-radius: 17.5rpx;
  284. font-size: 21rpx;
  285. color: $uni-text-color-grey;
  286. }
  287. }
  288. }
  289. </style>