commentChild.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. <view class="info_top">{{ item.userName }}</view>
  8. <view class="info_bottom">{{ item.dateTime }}</view>
  9. </view>
  10. </view>
  11. <view class="box_content">
  12. <text class="content_key">回复{{ item.commentName }}:</text>
  13. {{ item.content }}
  14. </view>
  15. <view>
  16. <Child v-if="item.commentVoList" :list="item.commentVoList" :commentParentId="commentParentId"></Child>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. var dayjs = require('dayjs')
  23. // uniapp不兼容递归组件,需要重新引入注册使用
  24. import Child from '@/components/commentChild.vue'
  25. export default {
  26. components: { Child },
  27. props: {
  28. list: Array,
  29. commentParentId: String
  30. },
  31. methods: {
  32. handleComment(item) {
  33. uni.showModal({
  34. title: '请输入评论',
  35. editable: true,
  36. success: async (res) => {
  37. if (res.confirm) {
  38. const result = res.content
  39. if (!res.content) {
  40. uni.showToast({
  41. title: '评论内容不能为空',
  42. icon: 'none',
  43. mask: true
  44. })
  45. setTimeout(() => {
  46. this.handleComment()
  47. }, 1500)
  48. } else {
  49. let time = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')
  50. const res = await this.$myRequest({
  51. url: '/mhotel/abcareplyComment.action',
  52. data: {
  53. commentId: item.id,
  54. commentParentId: this.commentParentId,
  55. commentName: item.userName,
  56. content: result,
  57. commentStatus: 1,
  58. createId: uni.getStorageSync('userInfo').id,
  59. createUsername: uni.getStorageSync('userInfo').user_name,
  60. createDate: time,
  61. modifyDate: time
  62. }
  63. })
  64. // console.log(res);
  65. if (res.code === 200) {
  66. uni.showToast({
  67. title: res.message,
  68. icon: 'success',
  69. mask: true
  70. })
  71. setTimeout(() => {
  72. uni.$emit('getData')
  73. }, 1500)
  74. }
  75. }
  76. }
  77. }
  78. })
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .item_child {
  85. // margin-left: 50rpx;
  86. .child_box {
  87. margin-bottom: 10rpx;
  88. .box_user {
  89. display: flex;
  90. align-items: center;
  91. height: 120rpx;
  92. img {
  93. width: 70rpx;
  94. height: 70rpx;
  95. border-radius: 50%;
  96. }
  97. .user_info {
  98. display: flex;
  99. flex-direction: column;
  100. justify-content: space-between;
  101. margin-left: 18rpx;
  102. height: 70rpx;
  103. .info_top {
  104. font-size: 28rpx;
  105. }
  106. .info_bottom {
  107. color: #a6a6a6;
  108. font-size: 24rpx;
  109. }
  110. }
  111. }
  112. .box_content {
  113. font-size: 24rpx;
  114. .content_key {
  115. color: #808080;
  116. }
  117. }
  118. }
  119. }
  120. </style>