wholeEvaluation.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 + '?w=300'" 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 + '?w=100'"
  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. // {
  40. // cusHeadImg:'https://mall.zhaijieshi.cc/file/wx-dy/icon-tag3.png',
  41. // cusName:'鲸致生活',
  42. // cusLabel:'>回头客/已消费',
  43. // commentType:'好评',
  44. // comment:'阿姨非常认真,专业的就是专业。六大区域清洁的都很干净,后期会继续囤订单,回到阿姨打扫干净的家,好幸福!'
  45. // }
  46. // ],
  47. evalList: [],
  48. page: 1,
  49. limit: 10,
  50. goodsId: '',
  51. totalPages: '',
  52. img: ''
  53. };
  54. },
  55. onLoad: function (options) {
  56. // 页面初始化 options为页面跳转所带来的参数
  57. if (options.id) {
  58. this.setData({
  59. goodsId: options.id
  60. });
  61. this.getEvalList();
  62. }
  63. },
  64. onReachBottom() {
  65. if (this.totalPages > this.page) {
  66. this.setData({
  67. page: this.page + 1
  68. });
  69. this.getEvalList();
  70. } else {
  71. uni.showToast({
  72. title: '没有更多评价了',
  73. icon: 'none',
  74. duration: 2000
  75. });
  76. return false;
  77. }
  78. },
  79. onReady: function () {
  80. // 页面渲染完成
  81. },
  82. onShow: function () {
  83. // 页面显示
  84. },
  85. onHide: function () {
  86. // 页面隐藏
  87. },
  88. onUnload: function () {
  89. // 页面关闭
  90. },
  91. methods: {
  92. getEvalList() {
  93. uni.showLoading({
  94. title: '加载中'
  95. });
  96. util.request(api.getGoodsComment, {
  97. goodsId: this.goodsId,
  98. page: this.page,
  99. limit: this.limit
  100. }).then((res) => {
  101. uni.hideLoading();
  102. if (res.errno === 0) {
  103. console.log(res.data);
  104. let list = res.data.list.map((item) => {
  105. if (item.commentImgs == null || item.commentImgs == '') {
  106. item.commentImg = [];
  107. } else {
  108. item.commentImg = item.commentImgs.split(',');
  109. }
  110. item.date = item.createTime.substr(0, 10);
  111. return item;
  112. });
  113. this.setData({
  114. evalList: this.evalList.concat(list),
  115. totalPages: res.data.pages
  116. });
  117. }
  118. });
  119. },
  120. previewImg(e) {
  121. let img = e.currentTarget.dataset.img;
  122. let imgs = e.currentTarget.dataset.imgs;
  123. uni.previewImage({
  124. current: img,
  125. urls: imgs
  126. });
  127. }
  128. }
  129. };
  130. </script>
  131. <style>
  132. page {
  133. width: 100%;
  134. background: #f4f4f4;
  135. }
  136. .evaluation-list {
  137. padding: 30rpx 24rpx;
  138. }
  139. .evaluation-item {
  140. padding: 30rpx 30rpx 36rpx 30rpx;
  141. background: #ffffff;
  142. border-radius: 24rpx;
  143. width: 702rpx;
  144. margin-bottom: 20rpx;
  145. }
  146. .evaluation-item .item-left {
  147. width: 510rpx;
  148. }
  149. .eval-top {
  150. display: flex;
  151. height: 60rpx;
  152. align-items: center;
  153. }
  154. .eval-top .avatar {
  155. width: 60rpx;
  156. height: 60rpx;
  157. border-radius: 60rpx;
  158. }
  159. .eval-top .name {
  160. margin: 0 10rpx;
  161. font-size: 28rpx;
  162. color: #000;
  163. }
  164. .eval-top .tag {
  165. height: 38rpx;
  166. line-height: 38rpx;
  167. background: rgba(1, 187, 243, 0.1);
  168. border-radius: 10rpx;
  169. color: #01bbf3;
  170. font-size: 24rpx;
  171. padding: 0 12rpx;
  172. margin-right: 10rpx;
  173. }
  174. .eval-top .hp {
  175. height: 38rpx;
  176. line-height: 38rpx;
  177. background: rgba(255, 71, 71, 0.1);
  178. border-radius: 10rpx;
  179. color: #ff5252;
  180. font-size: 24rpx;
  181. padding: 0 12rpx;
  182. }
  183. .eval-top .date {
  184. flex: 1;
  185. text-align: right;
  186. }
  187. .eval-content {
  188. display: -webkit-box;
  189. -webkit-box-orient: vertical;
  190. -webkit-line-clamp: 2;
  191. text-overflow: ellipsis;
  192. overflow: hidden;
  193. margin-bottom: 24rpx;
  194. }
  195. .evaluation-item .item-bottom {
  196. display: flex;
  197. flex-wrap: wrap;
  198. }
  199. .evaluation-item .item-bottom image {
  200. width: 144rpx;
  201. height: 144rpx;
  202. border-radius: 10rpx;
  203. margin-right: 16rpx;
  204. margin-bottom: 8rpx;
  205. }
  206. </style>