wholeEvaluation.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view>
  3. <view class="evaluation-list">
  4. <view class="evaluation-item" v-for="(item, index) in evalList" :key="index">
  5. <view class="eval-top">
  6. <image :src="item.cusHeadImg" mode="aspectFill" class="avatar"></image>
  7. <view class="name">{{ item.cusName }}</view>
  8. <view class="tag">{{ item.cusLabel }}</view>
  9. <view class="hp">{{ item.commentType }}</view>
  10. <view class="date">{{ item.date }}</view>
  11. </view>
  12. <view class="eval-content">
  13. {{ item.comment }}
  14. </view>
  15. <!-- <text>展开</text> -->
  16. <view class="item-bottom">
  17. <image
  18. :src="img"
  19. mode="aspectFill"
  20. :data-img="img"
  21. :data-imgs="item.commentImg"
  22. @tap="previewImg"
  23. v-for="(img, index1) in item.commentImg"
  24. :key="index1"
  25. ></image>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. var util = require('../../../utils/util.js');
  33. var api = require('../../../config/api.js');
  34. var app = getApp();
  35. export default {
  36. data() {
  37. return {
  38. evalList: [],
  39. page: 1,
  40. limit: 10,
  41. goodsId: '',
  42. totalPages: '',
  43. img: ''
  44. };
  45. },
  46. onLoad: function (options) {
  47. // 页面初始化 options为页面跳转所带来的参数
  48. if (options.id) {
  49. this.setData({
  50. goodsId: options.id
  51. });
  52. this.getEvalList();
  53. }
  54. },
  55. onReachBottom() {
  56. if (this.totalPages > this.page) {
  57. this.setData({
  58. page: this.page + 1
  59. });
  60. this.getEvalList();
  61. } else {
  62. uni.showToast({
  63. title: '没有更多评价了',
  64. icon: 'none',
  65. duration: 2000
  66. });
  67. return false;
  68. }
  69. },
  70. onReady: function () {
  71. // 页面渲染完成
  72. },
  73. onShow: function () {
  74. // 页面显示
  75. },
  76. onHide: function () {
  77. // 页面隐藏
  78. },
  79. onUnload: function () {
  80. // 页面关闭
  81. },
  82. methods: {
  83. getEvalList() {
  84. uni.showLoading({
  85. title: '加载中'
  86. });
  87. util.request(api.getGoodsComment, {
  88. goodsId: this.goodsId,
  89. page: this.page,
  90. limit: this.limit
  91. }).then((res) => {
  92. uni.hideLoading();
  93. if (res.errno === 0) {
  94. console.log(res.data);
  95. let list = res.data.list.map((item) => {
  96. if (item.commentImgs == null || item.commentImgs == '') {
  97. item.commentImg = [];
  98. } else {
  99. item.commentImg = item.commentImgs.split(',');
  100. }
  101. item.date = item.createTime.substr(0, 10);
  102. return item;
  103. });
  104. this.setData({
  105. evalList: this.evalList.concat(list),
  106. totalPages: res.data.pages
  107. });
  108. }
  109. });
  110. },
  111. previewImg(e) {
  112. let img = e.currentTarget.dataset.img;
  113. let imgs = e.currentTarget.dataset.imgs;
  114. uni.previewImage({
  115. current: img,
  116. urls: imgs
  117. });
  118. }
  119. }
  120. };
  121. </script>
  122. <style>
  123. page {
  124. width: 100%;
  125. background: #f4f4f4;
  126. }
  127. .evaluation-list {
  128. padding: 30rpx 24rpx;
  129. }
  130. .evaluation-item {
  131. padding: 30rpx 30rpx 36rpx 30rpx;
  132. background: #ffffff;
  133. border-radius: 24rpx;
  134. width: 702rpx;
  135. margin-bottom: 20rpx;
  136. }
  137. .evaluation-item .item-left {
  138. width: 510rpx;
  139. }
  140. .eval-top {
  141. display: flex;
  142. height: 60rpx;
  143. align-items: center;
  144. }
  145. .eval-top .avatar {
  146. width: 60rpx;
  147. height: 60rpx;
  148. border-radius: 60rpx;
  149. }
  150. .eval-top .name {
  151. margin: 0 10rpx;
  152. font-size: 28rpx;
  153. color: #000;
  154. }
  155. .eval-top .tag {
  156. height: 38rpx;
  157. line-height: 38rpx;
  158. background: #FFECDD;
  159. border-radius: 10rpx;
  160. color: #CC987E;
  161. font-size: 24rpx;
  162. padding: 0 12rpx;
  163. margin-right: 10rpx;
  164. }
  165. .eval-top .hp {
  166. height: 38rpx;
  167. line-height: 38rpx;
  168. background: rgba(255, 71, 71, 0.1);
  169. border-radius: 10rpx;
  170. color: #ff5252;
  171. font-size: 24rpx;
  172. padding: 0 12rpx;
  173. }
  174. .eval-top .date {
  175. flex: 1;
  176. text-align: right;
  177. }
  178. .eval-content {
  179. display: -webkit-box;
  180. -webkit-box-orient: vertical;
  181. -webkit-line-clamp: 2;
  182. text-overflow: ellipsis;
  183. overflow: hidden;
  184. margin-bottom: 24rpx;
  185. }
  186. .evaluation-item .item-bottom {
  187. display: flex;
  188. flex-wrap: wrap;
  189. }
  190. .evaluation-item .item-bottom image {
  191. width: 144rpx;
  192. height: 144rpx;
  193. border-radius: 10rpx;
  194. margin-right: 16rpx;
  195. margin-bottom: 8rpx;
  196. }
  197. </style>