pinglunList.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <view>
  3. <view style="margin: 20upx 15upx;border-radius: 15upx;background-color: #FFFFFF;">
  4. <view style="padding: 20rpx 0 0 30rpx;color: #666666;font-size: 24rpx;display: flex;">
  5. <view style="margin-top: 7rpx;">商品好评率</view>
  6. <!-- #ifdef MP-WEIXIN -->
  7. <view style="margin-left: 10rpx;margin-top: 8rpx;">{{count1 > 0 ? count1 : '无'}}</view>
  8. <uni-rate style="margin-left: 15rpx;margin-top: 30rpx;" :size='14' :value="count1" />
  9. <!-- #endif -->
  10. <!-- #ifndef MP-WEIXIN -->
  11. <view style="margin-left: 10rpx;margin-top: 10rpx;">{{count1 > 0 ? count1 : '无'}}</view>
  12. <uni-rate style="margin-left: 15rpx;margin-top: 12rpx;" :size='14' :value="count1" />
  13. <!-- #endif -->
  14. </view>
  15. <view class="tui-tabs" style="margin-left: 10rpx;">
  16. <view style="display: flex;flex-wrap: wrap;">
  17. <view v-for="(tab, index) in scoreTypeList" :id="index" :data-current="index" @tap='tabSlect(tab)'>
  18. <view v-if="CountTypeList.length > 0 && CountTypeList[index].count != 0" class="tui-tab-item-title" style="margin:15rpx;"
  19. :class="{ 'tui-tab-item-title-active': tabIndex == index }">{{ tab.name }}({{CountTypeList[index].count}})
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view style="width: 100%;padding:20upx 0upx 20upx 20upx;" v-for="(ping,index) in pinglunList" v-if="pinglunList.length > 0">
  25. <view style="display: flex;padding: 20rpx;">
  26. <image :src="ping.userHeader ? ping.userHeader : '/static/logo.png'" style="width: 80rpx;height: 80rpx;border-radius: 50rpx;"></image>
  27. <view style="margin-top: 5rpx;margin-left: 10rpx;width: 42%;">
  28. <view style="margin-left: 15rpx;text-overflow: ellipsis;overflow: hidden;white-space: nowrap;">{{ping.userName}}</view>
  29. <uni-rate style="margin-left: 15rpx;margin-top: 10rpx;" :size='15' :value="ping.score" />
  30. </view>
  31. <view style="margin-left: 20rpx;margin-top: 20rpx;color: #666666;">{{ping.createTime}}</view>
  32. </view>
  33. <view style="padding: 0rpx 20rpx 0 20rpx;">{{ping.content}}</view>
  34. <view style="display: flex;padding: 10rpx 0 0 10rpx;flex-wrap: wrap;" v-if="ping.img && ping.img.length > 0">
  35. <view style="margin: 5rpx;" v-for="(item,index) in ping.img">
  36. <image :src="item" style="width: 210rpx;height: 210rpx;border-radius: 10rpx;" @tap='selectPhoto(item)'></image>
  37. </view>
  38. </view>
  39. <view v-if="ping.reply">
  40. <view style="margin-left: 20rpx;font-size: 26rpx;color: #666666;">商家回复:{{ping.reply}}</view>
  41. </view>
  42. </view>
  43. <!-- 悬浮上拉 -->
  44. <view class="scroll_top" @tap="topScrollTap" v-bind:class="[scrollTop ? 'active' : '', '']" style="bottom: 56px;"><text
  45. class="iconfont icon-shangla"></text></view>
  46. <!-- 加载更多提示 -->
  47. <view class="s-col is-col-24" v-if="pinglunList.length > 0">
  48. <load-more :loadingType="loadingType" :contentText="contentText"></load-more>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. page: 0,
  58. size: 10,
  59. loadingType: 0,
  60. scrollTop: false,
  61. tabIndex: 0,
  62. count1: 0,
  63. CountTypeList: [],
  64. scoreTypeList: [{
  65. index: '0',
  66. name: '全部'
  67. },
  68. {
  69. index: '1',
  70. name: '好评'
  71. },
  72. {
  73. index: '2',
  74. name: '中评'
  75. },
  76. {
  77. index: '3',
  78. name: '差评'
  79. }
  80. ],
  81. contentText: {
  82. contentdown: '上拉显示更多',
  83. contentrefresh: '正在加载...',
  84. contentnomore: '没有更多数据了'
  85. },
  86. pinglunList: []
  87. };
  88. },
  89. onLoad(d) {
  90. if (d.id) {
  91. this.ordersId = d.id;
  92. this.getPingLunList('');
  93. this.getCount(d.id);
  94. }
  95. },
  96. methods: {
  97. tabSlect(item) {
  98. this.tabIndex = item.index;
  99. this.page = 0;
  100. this.getPingLunList('');
  101. },
  102. selectPhoto(item) {
  103. let imgsArray = [];
  104. imgsArray[0] = item;
  105. uni.previewImage({
  106. current: 0,
  107. urls: imgsArray
  108. });
  109. },
  110. getCount(id) {
  111. this.$Request.getT('/app/selfGoodsComment/count?goodsId=' + id).then(res => {
  112. if (res.status === 0) {
  113. this.count1 = res.data.count1;
  114. let data = {};
  115. data.count = res.data.count;
  116. this.CountTypeList.push(data);
  117. let data1 = {};
  118. data1.count = res.data.count2;
  119. this.CountTypeList.push(data1);
  120. let data2 = {};
  121. data2.count = res.data.count3;
  122. this.CountTypeList.push(data2);
  123. let data3 = {};
  124. data3.count = res.data.count4;
  125. this.CountTypeList.push(data3);
  126. }
  127. });
  128. },
  129. getPingLunList(type) {
  130. this.loadingType = 1;
  131. uni.showLoading({
  132. title: '加载中...'
  133. });
  134. this.$Request.getT('/app/selfGoodsComment/list?scoreType=' + this.tabIndex + '&page=' + this.page + '&size=' + this.size +
  135. '&goodsId=' +
  136. this.ordersId)
  137. .then(res => {
  138. if (res.status === 0) {
  139. if (this.page === 0 || res.status) {
  140. this.pinglunList = [];
  141. }
  142. res.data.content.forEach(d => {
  143. if (d.img) {
  144. let img = d.img.split(',');
  145. d.img = img;
  146. }
  147. this.pinglunList = res.data.content;
  148. });
  149. if (res.data.content.length === this.size) {
  150. this.loadingType = 0;
  151. } else {
  152. this.loadingType = 3;
  153. }
  154. } else {
  155. this.loadingType = 2;
  156. }
  157. uni.hideLoading();
  158. if (type === 'Refresh') {
  159. uni.stopPullDownRefresh(); // 停止刷新
  160. }
  161. });
  162. },
  163. topScrollTap: function() {
  164. uni.pageScrollTo({
  165. scrollTop: 0,
  166. duration: 300
  167. });
  168. }
  169. },
  170. onPageScroll: function(e) {
  171. this.scrollTop = e.scrollTop > 200;
  172. },
  173. onReachBottom: function() {
  174. this.page = this.page + 1;
  175. this.getPingLunList('');
  176. },
  177. onPullDownRefresh: function() {
  178. this.page = 0;
  179. this.getPingLunList('Refresh');
  180. }
  181. };
  182. </script>
  183. <style>
  184. @import '../../../../static/css/index.css';
  185. page {
  186. background: #F2F2F2;
  187. }
  188. .tui-tabs {
  189. flex: 1;
  190. flex-direction: column;
  191. overflow: hidden;
  192. background-color: #FFFFFF;
  193. /* #ifdef MP-ALIPAY || MP-BAIDU */
  194. height: 100vh;
  195. /* #endif */
  196. }
  197. .tui-tab-item {
  198. /* #ifndef APP-PLUS */
  199. display: flex;
  200. /* #endif */
  201. // flex-wrap: nowrap;
  202. // padding-left: 34rpx;
  203. // padding-right: 34rpx;
  204. }
  205. .tui-tab-item-title {
  206. color: #333333;
  207. font-size: 28rpx;
  208. line-height: 48rpx;
  209. border-radius: 50rpx;
  210. background: #F2F2F2;
  211. width: max-content;
  212. padding: 0 20rpx 0 20rpx;
  213. text-align: center;
  214. height: 50rpx;
  215. }
  216. .tui-tab-item-title-active {
  217. color: #FFFFFF;
  218. background: #FF440C;
  219. font-size: 28upx;
  220. border-bottom-width: 6upx;
  221. text-align: center;
  222. }
  223. </style>