goods_comment_list.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view class="pageBg">
  3. <!-- <view class="tab-h">
  4. <view class="tab-item" :class="currentTab == 0 ? 'active' : ''" @tap="currentTab=0">全部</view>
  5. <view class="tab-item" :class="currentTab == 1 ? 'active' : ''" @tap="currentTab=1">有图</view>
  6. <view></view>
  7. </view> -->
  8. <!-- <swiper :current="currentTab" duration="300" @change="switchTab" :style="{height:swiper_height}">
  9. <swiper-item> -->
  10. <!-- <view id="start0"></view> -->
  11. <block v-if="reviewDatas.length>0">
  12. <!-- <view class="tab_height"></view> -->
  13. <DtGoodsComment :dataList="reviewDatas" @tapImage="roopImageClick" />
  14. <DtNoMore v-if="isNoMore" />
  15. </block>
  16. <view v-else class="no_data_wrap">
  17. <DtNoData msg="暂无数据" image="http://139.9.103.171:1888/img/image/noData.png" />
  18. </view>
  19. <!-- <view id="end0"></view> -->
  20. <!-- </swiper-item> -->
  21. <!-- <swiper-item>
  22. <view id="start1"></view>
  23. <block v-if="hasPicRewiewDatas.length>0">
  24. <view class="tab_height"></view>
  25. <DtGoodsComment :dataList="hasPicRewiewDatas" @tapImage="roopImageClick" />
  26. <DtNoMore v-if="noMore" />
  27. </block>
  28. <view class="no_data_wrap" v-else>
  29. <DtNoData msg="暂无数据" image="http://139.9.103.171:1888/img/image/noData.png" />
  30. </view>
  31. <view id="end1"></view>
  32. </swiper-item>
  33. </swiper> -->
  34. </view>
  35. </template>
  36. <script>
  37. import DtGoodsComment from '../comps/dt_goods_comment'
  38. import DtNoData from '../comps/dt_no_data.vue'
  39. import DtNoMore from '../comps/dt_no_more.vue'
  40. export default {
  41. components: {
  42. DtGoodsComment,
  43. DtNoData,
  44. DtNoMore
  45. },
  46. data() {
  47. return {
  48. currentTab: 0,
  49. swiper_height: 0,
  50. productId: 0,
  51. reviewDatas: [],
  52. hasPicRewiewDatas: [],
  53. pageNo: 1,
  54. noMore: false,
  55. srcs: [],
  56. };
  57. },
  58. methods: {
  59. //获取评论
  60. async getReviewList() {
  61. let data = {}
  62. data.pageNo = this.pageNo;
  63. data.pageSize = 10;
  64. data.productId = this.productId;
  65. data.type = '';
  66. let res = await this.$api.getReviewList(data);
  67. let hasPicRewiewDatas = [];
  68. if (res.datas.length > 0) {
  69. for (let i in res.datas) {
  70. res.datas[i].imageUrls = JSON.parse(res.datas[i].imageUrls)
  71. if (res.datas[i].imageUrls.length > 0) {
  72. hasPicRewiewDatas.push(res.datas[i]);
  73. }
  74. this.srcs = this.srcs.concat(res.datas[i].imageUrls)
  75. }
  76. this.reviewDatas = this.reviewDatas.concat(res.datas);
  77. this.hasPicRewiewDatas = this.hasPicRewiewDatas.concat(hasPicRewiewDatas);
  78. } else {
  79. if (this.reviewDatas.length > 0) {
  80. this.isNoMore = true;
  81. } else {
  82. this.isNoMore = false
  83. }
  84. }
  85. this.isFrefresh = false
  86. this.pageNo++;
  87. },
  88. roopImageClick(img) {
  89. console.log(img);
  90. uni.previewImage({
  91. current: img, // 当前显示图片的http链接
  92. urls: this.srcs // 需要预览的图片http链接列表
  93. });
  94. },
  95. onLoadPage(options) {
  96. wx.hideShareMenu();
  97. console.log(this);
  98. console.log(options);
  99. this.productId = options.productId;
  100. this.getReviewList();
  101. },
  102. },
  103. onReachBottom() {
  104. this.onReachBottomPage()
  105. }
  106. };
  107. </script>
  108. <style lang="scss" scoped>
  109. .goods-fix {
  110. height: 60upx;
  111. }
  112. .tab-h {
  113. height: 90upx;
  114. line-height: 90upx;
  115. display: flex;
  116. flex-direction: row;
  117. align-items: center;
  118. background: #fff;
  119. justify-content: center;
  120. border-bottom: 1upx solid #e5e5e5;
  121. box-sizing: border-box;
  122. position: fixed;
  123. top: 0;
  124. width: 100%;
  125. z-index: 100;
  126. .tab-item {
  127. width: 200upx;
  128. text-align: center;
  129. padding: 0 40upx;
  130. font-size: 30upx;
  131. color: #333333;
  132. letter-spacing: 1upx;
  133. }
  134. .active {
  135. color: $dt-color-primary;
  136. position: relative;
  137. &::after {
  138. content: "";
  139. position: absolute;
  140. width: 120upx;
  141. height: 2upx;
  142. background: $dt-color-primary;
  143. top: 89upx;
  144. left: 80upx;
  145. }
  146. }
  147. }
  148. .tab_height {
  149. height: 90rpx;
  150. }
  151. .no_data_wrap {
  152. display: flex;
  153. flex-direction: column;
  154. align-items: center;
  155. justify-content: center;
  156. height: 100vh;
  157. }
  158. </style>