index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <view class="container">
  3. <u-sticky>
  4. <view class="pop-top">
  5. <view class="top-box">
  6. <view class="top-black-box"></view>
  7. </view>
  8. <view class="top-title"> {{ total }}条回复 </view>
  9. </view>
  10. </u-sticky>
  11. <view class="center-box">
  12. <view class="center-item" v-for="(item, index) of init_list" :key="index">
  13. <view class="item-top">
  14. <view class="top-left">
  15. <view class="top-img">
  16. <image :src="item.userDTO.avatar" class="img" mode=""></image>
  17. </view>
  18. <view class="top-text">
  19. <view class="text-title">{{ item.userDTO.nickname }}</view>
  20. <view class="text-address"> {{ item.distanceTime }} </view>
  21. </view>
  22. </view>
  23. <view class="top-right">
  24. <u-icon
  25. :name="item.clickStatus == 0 ? 'heart' : 'heart-fill'"
  26. size="22"
  27. @click="handlerFocus(item)"
  28. ></u-icon>
  29. </view>
  30. </view>
  31. <view class="item-text"> {{ item.content }} </view>
  32. </view>
  33. </view>
  34. <empty v-if="total == 0" />
  35. <view class="bottom-box">
  36. <view class="bottom-item">
  37. <view class="item-left">
  38. <u--input
  39. placeholder="写回复"
  40. border="surround"
  41. v-model="content"
  42. shape="circle"
  43. customStyle="background-color:#F2F2F2"
  44. ></u--input>
  45. </view>
  46. <view class="item-right">
  47. <button @click="handlerPopPublishBtn" class="btn">发布</button>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import { addClientComment, clientCommentList } from '@/api/client/message.js';
  55. import { addEvaulateRecords } from '@/api/client/community.js';
  56. import empty from '@/components/empty/index.vue';
  57. import { GetDateToNewData } from "@/utils/tools.js"
  58. export default {
  59. components: { empty },
  60. data() {
  61. return {
  62. content: '',
  63. init_list: [],
  64. total: 0,
  65. };
  66. },
  67. props: ['dynamicId', 'dynamicUserId'],
  68. watch: {
  69. dynamicId(newValue) {
  70. if (newValue != null) {
  71. this.handlerInitList();
  72. }
  73. },
  74. },
  75. methods: {
  76. // 初始化评论列表
  77. handlerInitList() {
  78. let params = {
  79. dynamicId: this.dynamicId,
  80. parentId: 0,
  81. userId: this.dynamicUserId,
  82. };
  83. clientCommentList(params).then(res => {
  84. res.data.records.map(rs=>{
  85. let time = GetDateToNewData(rs.createTime)
  86. this.$set(rs,'distanceTime',time)
  87. })
  88. this.init_list = res.data.records;
  89. this.total = res.data.total;
  90. });
  91. },
  92. // 发布评论
  93. handlerPopPublishBtn() {
  94. let params = {
  95. dynamicId: this.dynamicId,
  96. targetUserId:this.dynamicUserId,
  97. parentId: 0,
  98. content: this.content,
  99. status: 0,
  100. };
  101. addClientComment(params).then(res => {
  102. if (res.code === 'OK') {
  103. uni.showToast({
  104. title: '发布成功',
  105. icon: 'none',
  106. });
  107. this.content = '';
  108. this.handlerInitList();
  109. this.$emit('uploadComment');
  110. }
  111. });
  112. },
  113. // 关注按钮
  114. handlerFocus(item) {
  115. let params = {
  116. dynamicStatusType: 'GOOD', // 操作类型:1-点赞;2-踩 允许值: GOOD, BAD
  117. recordType: 'COMMENT', // 内容类型:1-动态;2-评论/回复 允许值: DYNAMIC, COMMENT, USER
  118. actionType: item.clickStatus == 0 ? 'ADD' : 'CANCEL', // 点击类型:1-点赞/踩;2-取消赞/取消踩 允许值: ADD, CANCEL
  119. contentId: item.id,
  120. targetUserId: item.userId,
  121. };
  122. addEvaulateRecords(params).then(res => {
  123. if (res.code === 'OK') {
  124. uni.showToast({
  125. title: '关注成功',
  126. icon: 'none',
  127. });
  128. this.handlerInitList();
  129. } else {
  130. uni.showToast({
  131. title: res.msg,
  132. icon: 'none',
  133. });
  134. return;
  135. }
  136. });
  137. },
  138. },
  139. };
  140. </script>
  141. <style lang="scss" scoped>
  142. .container {
  143. height: 70vh;
  144. overflow-y: auto;
  145. box-sizing: border-box;
  146. padding-bottom: 120rpx;
  147. .pop-top {
  148. background-color: #fff;
  149. border-radius: 40rpx;
  150. padding: 20rpx 0;
  151. }
  152. .top-box {
  153. display: flex;
  154. justify-content: center;
  155. .top-black-box {
  156. width: 10%;
  157. height: 10rpx;
  158. background-color: #000;
  159. border-radius: 10%;
  160. }
  161. }
  162. .top-title {
  163. font-size: 32rpx;
  164. font-weight: bold;
  165. color: #000;
  166. text-align: center;
  167. margin-top: 20rpx;
  168. letter-spacing: 2rpx;
  169. }
  170. .center-box {
  171. margin-bottom: 20rpx;
  172. padding: 0 20rpx;
  173. .center-item {
  174. margin-bottom: 40rpx;
  175. border-radius: 20rpx;
  176. .item-top {
  177. display: flex;
  178. justify-content: space-between;
  179. align-items: center;
  180. .top-left {
  181. display: flex;
  182. align-items: center;
  183. .top-img {
  184. .img {
  185. width: 80rpx;
  186. height: 80rpx;
  187. border-radius: 50%;
  188. }
  189. }
  190. .top-text {
  191. display: flex;
  192. flex-direction: column;
  193. justify-content: space-around;
  194. margin-left: 10rpx;
  195. .text-title {
  196. font-weight: bold;
  197. font-size: 32rpx;
  198. color: #000;
  199. }
  200. .text-address {
  201. color: #8f8f8f;
  202. font-size: 24rpx;
  203. }
  204. }
  205. }
  206. }
  207. .item-text {
  208. margin-top: 20rpx;
  209. padding: 0 40rpx;
  210. }
  211. }
  212. }
  213. .bottom-box {
  214. position: absolute;
  215. bottom: 0;
  216. background-color: #fff;
  217. width: 100%;
  218. height: 150rpx;
  219. .bottom-item {
  220. display: flex;
  221. justify-content: space-around;
  222. padding: 10rpx 20rpx 0;
  223. box-sizing: border-box;
  224. align-items: center;
  225. .item-left {
  226. width: 60%;
  227. height: 70rpx;
  228. }
  229. .item-right {
  230. width: 30%;
  231. padding: 20rpx;
  232. .btn {
  233. border-radius: 20rpx;
  234. text-align: center;
  235. color: #fff;
  236. background: linear-gradient(to right, #e8cbc0, #636fa4);
  237. height: 70rpx;
  238. font-size: 28rpx;
  239. line-height: 70rpx;
  240. }
  241. }
  242. }
  243. }
  244. }
  245. </style>