commentChild3.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view class="item_child">
  3. <view class="child_box" v-for="item in list" :key="item.id" @click.stop="handleComment(item)">
  4. <view class="box_user">
  5. <img mode="aspectFill" :src="item.image" @click.stop="handleGoMyHome(item.userId)" />
  6. <view class="user_info">
  7. {{ item.userName }}
  8. </view>
  9. </view>
  10. <view class="box_content">
  11. <text class="content_key">回复{{ item.parentName }}:</text>
  12. {{ item.content }}
  13. <view class="content_bottom">
  14. {{ item.date.slice(0, 19) }}
  15. </view>
  16. </view>
  17. <view>
  18. <Child v-if="item.childrens" :list="item.childrens" :commentParentId="commentParentId"></Child>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. var dayjs = require('dayjs')
  25. // uniapp不兼容递归组件,需要重新引入注册使用
  26. import Child from '@/components/commentChild3.vue'
  27. export default {
  28. components: { Child },
  29. props: {
  30. list: Array,
  31. commentParentId: String
  32. },
  33. methods: {
  34. handleComment(item) {
  35. uni.showModal({
  36. title: '请输入评论',
  37. editable: true,
  38. success: async (res) => {
  39. if (res.confirm) {
  40. const result = res.content
  41. if (!res.content) {
  42. uni.showToast({
  43. title: '评论内容不能为空',
  44. icon: 'none',
  45. mask: true
  46. })
  47. setTimeout(() => {
  48. this.handleComment()
  49. }, 1500)
  50. } else {
  51. const res = await this.$myRequest({
  52. url: '/mhotel/articlecommentArticle.action',
  53. method: 'post',
  54. data: {
  55. articleId: this.commentParentId,
  56. parentId: item.id,
  57. userId: uni.getStorageSync('userInfo').id,
  58. content: result
  59. }
  60. })
  61. // console.log(res);
  62. if (res.code === 200) {
  63. uni.$emit('getReset')
  64. }
  65. }
  66. }
  67. }
  68. })
  69. },
  70. handleGoMyHome(userId) {
  71. uni.navigateTo({
  72. url: `/pagesSub/myHome/myHome?userId=${userId}`
  73. })
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .item_child {
  80. // margin-left: 50rpx;
  81. .child_box {
  82. margin-bottom: 10rpx;
  83. .box_user {
  84. display: flex;
  85. align-items: center;
  86. height: 70rpx;
  87. img {
  88. width: 70rpx;
  89. height: 70rpx;
  90. border-radius: 50%;
  91. }
  92. .user_info {
  93. display: flex;
  94. align-items: center;
  95. margin-left: 18rpx;
  96. height: 70rpx;
  97. font-size: 28rpx;
  98. }
  99. }
  100. .box_content {
  101. margin-left: 80rpx;
  102. font-size: 24rpx;
  103. .content_key {
  104. color: #808080;
  105. }
  106. .content_bottom {
  107. margin: 10rpx 0;
  108. color: #808080;
  109. }
  110. }
  111. }
  112. }
  113. </style>