commentChild2.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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.headPhoto" />
  6. <view class="user_info">
  7. {{ item.userName }}
  8. </view>
  9. </view>
  10. <view class="box_content">
  11. <text class="content_key">回复{{ item.commentName }}:</text>
  12. {{ item.content }}
  13. <view class="content_bottom">
  14. {{ item.dateTime }}
  15. </view>
  16. </view>
  17. <view>
  18. <Child v-if="item.commentVoList" :list="item.commentVoList" :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/commentChild2.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. let time = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')
  52. const res = await this.$myRequest({
  53. url: '/mhotel/abcareplyComment.action',
  54. data: {
  55. commentId: item.id,
  56. commentParentId: this.commentParentId,
  57. commentName: item.userName,
  58. content: result,
  59. commentStatus: 1,
  60. createId: uni.getStorageSync('userInfo').id,
  61. createUsername: uni.getStorageSync('userInfo').user_name,
  62. createDate: time,
  63. modifyDate: time
  64. }
  65. })
  66. // console.log(res);
  67. if (res.code === 200) {
  68. uni.showToast({
  69. title: res.message,
  70. icon: 'success',
  71. mask: true
  72. })
  73. setTimeout(() => {
  74. uni.$emit('getData')
  75. }, 1500)
  76. }
  77. }
  78. }
  79. }
  80. })
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. .item_child {
  87. // margin-left: 50rpx;
  88. .child_box {
  89. margin-bottom: 10rpx;
  90. .box_user {
  91. display: flex;
  92. align-items: center;
  93. height: 70rpx;
  94. img {
  95. width: 70rpx;
  96. height: 70rpx;
  97. border-radius: 50%;
  98. }
  99. .user_info {
  100. display: flex;
  101. align-items: center;
  102. margin-left: 18rpx;
  103. height: 70rpx;
  104. font-size: 28rpx;
  105. }
  106. }
  107. .box_content {
  108. margin-left: 80rpx;
  109. font-size: 24rpx;
  110. .content_key {
  111. color: #808080;
  112. }
  113. .content_bottom {
  114. margin: 10rpx 0;
  115. color: #808080;
  116. }
  117. }
  118. }
  119. }
  120. </style>