index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="container">
  3. <JHeader title="宝贝评价" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  4. <!-- 查看全部评论 -->
  5. <view class="evaluateTag-box">
  6. <view class="evaluateTag-text">
  7. 全部({{ commentList.length }})
  8. </view>
  9. </view>
  10. <view class="flex-column-plus evaluateList-box">
  11. <view v-for="(item, index) in commentList" :key="index" class="evaluate-contentbox mar-top-20">
  12. <view class="evaluate-content flex-items flex-row flex-sp-between">
  13. <view class="flex-items">
  14. <image class="user-headSmallImg" :src="common.seamingImgUrl(item.headImage)"></image>
  15. <view class="">
  16. <text class="fs28 mar-left-20">{{ item.name }}</text>
  17. <view class="mar-left-20 fs22 font-color-999 mar-top-10">
  18. <text>{{ item.value }}</text>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="fs26 pad-topbot-20 font-color-333">{{ item.comment }}</view>
  24. <view class="evaluateImg-box">
  25. <view v-for="(commentItemImg, cindex) in item.images" :key="cindex">
  26. <image class="img-item" :src="common.seamingImgUrl(commentItemImg)" @click="previewImg(common.seamingImgUrl(commentItemImg))"></image>
  27. </view>
  28. </view>
  29. <view v-if="item.addComment !== ''" class="addEvaluate">
  30. <view class="fs26 font-color-C5AA7B">用户追加评价</view>
  31. <view class="addEvaluateText">{{ item.addComment }}</view>
  32. <view v-if="item.addImages" class="item-image-box">
  33. <view v-for="(itemAddImg, imgIndex) in item.addImages" :key="imgIndex">
  34. <image class="img-item" :src="common.seamingImgUrl(itemAddImg)" @click="previewImg(common.seamingImgUrl(itemAddImg))"></image>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="praisebig-box flex-items mar-top-30 flex-sp-between">
  39. <text class="font-color-999 fs22">{{ item.createTime }}</text>
  40. <view class="praise-box flex-items flex-row">
  41. <tui-icon v-if="item.ifLike == 1" :size="30" color="#c5aa7b" name="agree" @click="zanTap(index, item.commentId, 0)"></tui-icon>
  42. <tui-icon v-else :size="30" color="#cccccc" name="agree" @click="zanTap(index, item.commentId, 1)"></tui-icon>
  43. <text class="mar-left-10 font-color-999">{{ item.likes }}</text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import { updateLikeOrUnLikeCommentApi, getProductDetailsByIdApi } from '../../../api/anotherTFInterface'
  52. export default {
  53. name: 'EvaluateList',
  54. data() {
  55. return {
  56. commentList: []
  57. }
  58. },
  59. onLoad(options) {
  60. uni.showLoading()
  61. getProductDetailsByIdApi({
  62. shopId: options.shopId,
  63. productId: options.productId,
  64. skuId: options.skuId,
  65. terminal: 1
  66. }).then((res) => {
  67. uni.hideLoading()
  68. this.commentList = res.data.comments
  69. })
  70. .catch((res) => {
  71. uni.hideLoading()
  72. })
  73. },
  74. methods: {
  75. previewImg(img) {
  76. wx.previewImage({
  77. current: img, // 当前显示图片的http链接
  78. urls: [ img ] // 需要预览的图片http链接列表
  79. })
  80. },
  81. commentImgData(imgData) {
  82. let imgDataResult = []
  83. imgDataResult = imgData.split(',')
  84. return imgDataResult
  85. },
  86. // 点赞
  87. zanTap(index, likeId, actionType) {
  88. // uni.showLoading({
  89. // mask: true,
  90. // title: '提交中...',
  91. // })
  92. updateLikeOrUnLikeCommentApi({
  93. commentId: likeId,
  94. ifLike: actionType
  95. }).then((res) => {
  96. uni.hideLoading()
  97. this.commentList[index].ifLike = !this.commentList[index].ifLike
  98. this.commentList[index].likes = this.commentList[index].ifLike ? this.commentList[index].likes + 1
  99. : this.commentList[index].likes - 1
  100. })
  101. .catch((res) => {
  102. uni.hideLoading()
  103. })
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="less" scoped>
  109. .container {
  110. min-height: 100vh;
  111. background-color: #FFFFFF;
  112. box-sizing: border-box;
  113. .evaluateTag-box {
  114. margin-top: 10upx;
  115. margin-left: 10upx;
  116. padding-bottom: 10upx;
  117. display: flex;
  118. flex-wrap: wrap;
  119. .evaluateTag-text {
  120. background-color: #333333;
  121. padding: 16upx 14upx;
  122. color: #FFFFFF;
  123. margin-left: 20upx;
  124. margin-top: 20upx;
  125. }
  126. }
  127. .img-item {
  128. width: 223upx;
  129. height: 223upx;
  130. border-radius: 10upx;
  131. margin-right: 10upx;
  132. margin-top: 10upx;
  133. }
  134. .evaluateList-box {
  135. padding-bottom: 30upx;
  136. .evaluate-contentbox {
  137. display: flex;
  138. justify-content: center;
  139. flex-direction: column;
  140. padding: 30upx 30upx;
  141. background-color: #FFFFFF;
  142. .evaluate-content {
  143. width: 670upx;
  144. display: flex;
  145. justify-content: space-between;
  146. .user-headSmallImg {
  147. width: 60upx;
  148. height: 60upx;
  149. border-radius: 50%;
  150. }
  151. }
  152. .evaluateImg-box {
  153. display: flex;
  154. flex-direction: row;
  155. flex-wrap: wrap;
  156. margin-left: -9upx;
  157. }
  158. .addEvaluate {
  159. margin-top: 20upx;
  160. .addEvaluateText {
  161. margin: 25upx 0;
  162. }
  163. }
  164. .praisebig-box {
  165. border-top: 1upx solid #EEEEEE;
  166. padding-top: 30upx;
  167. }
  168. }
  169. }
  170. }
  171. </style>