index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view>
  3. <view class='evaluate-list'>
  4. <view class='generalComment acea-row row-between-wrapper'>
  5. <view class='acea-row row-middle font-color'>
  6. <view class='evaluate'>评分</view>
  7. <view class="star-box">
  8. <view class="star">
  9. <view class="star-active" :style="'width:'+replyData.star"></view>
  10. </view>
  11. </view>
  12. </view>
  13. <view><text class='font-color'>{{replyData.rate}}</text>好评率</view>
  14. </view>
  15. <view class='nav acea-row row-middle' v-if="replyData.stat">
  16. <view class='item' :class='type=="count" ? "bg-color":""' @click='changeType("count")'>全部({{replyData.stat.count}})</view>
  17. <view class='item' :class='type=="best" ? "bg-color":""' @click='changeType("best")'>好评({{replyData.stat.best}})</view>
  18. <view class='item' :class='type=="middle" ? "bg-color":""' @click='changeType("middle")'>中评({{replyData.stat.middle}})</view>
  19. <view class='item' :class='type=="negative" ? "bg-color":""' @click='changeType("negative")'>差评({{replyData.stat.negative}})</view>
  20. </view>
  21. <userEvaluation :reply="reply"></userEvaluation>
  22. <view class='loadingicon acea-row row-center-wrapper' v-if="reply.length > 0">
  23. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  24. </view>
  25. </view>
  26. <view class='noCommodity' v-if="reply.length == 0">
  27. <view class='pictrue'>
  28. <image src='/static/images/noEvaluate.png'></image>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. getReplyList,
  36. getReplyConfig
  37. } from '@/api/store.js';
  38. import userEvaluation from '@/components/userEvaluation';
  39. export default {
  40. components: {
  41. userEvaluation
  42. },
  43. data() {
  44. return {
  45. replyData: {},
  46. product_id: 0,
  47. reply: [],
  48. type: "count",
  49. loading: false,
  50. loadend: false,
  51. loadTitle: '加载更多',
  52. page: 1,
  53. limit: 20
  54. };
  55. },
  56. /**
  57. * 生命周期函数--监听页面加载
  58. */
  59. onLoad: function(options) {
  60. let that = this;
  61. if (!options.product_id) return that.$util.Tips({
  62. title: '缺少参数'
  63. }, {
  64. tab: 3,
  65. url: 1
  66. });
  67. that.product_id = options.product_id;
  68. },
  69. onShow: function() {
  70. // this.getProductReplyCount();
  71. this.getProductReplyList();
  72. },
  73. methods: {
  74. /**
  75. * 获取评论统计数据
  76. *
  77. */
  78. // getProductReplyCount: function() {
  79. // let that = this;
  80. // getReplyConfig(that.product_id).then(res => {
  81. // that.$set(that,'replyData',res.data);
  82. // });
  83. // },
  84. /**
  85. * 分页获取评论
  86. */
  87. getProductReplyList: function() {
  88. let that = this;
  89. if (that.loadend) return;
  90. if (that.loading) return;
  91. that.loading = true;
  92. that.loadTitle = '';
  93. getReplyList(that.product_id, {
  94. page: that.page,
  95. limit: that.limit,
  96. type: that.type,
  97. }).then(res => {
  98. let list = res.data.list,
  99. loadend = list.length < that.limit;
  100. that.reply = that.$util.SplitArray(list, that.reply);
  101. that.$set(that,'reply',that.reply);
  102. that.$set(that,'replyData',res.data)
  103. that.loading = false;
  104. that.loadend = loadend;
  105. that.loadTitle = loadend ? "😕人家是有底线的~~" : "加载更多";
  106. that.page = that.page + 1;
  107. }).catch(err => {
  108. that.loading = false,
  109. that.loadTitle = '加载更多'
  110. });
  111. },
  112. /*
  113. * 点击事件切换
  114. * */
  115. changeType: function(e) {
  116. let type = e
  117. if (type == this.type) return;
  118. this.type = type;
  119. this.page = 1;
  120. this.loadend = false;
  121. this.$set(this,'reply',[]);
  122. this.getProductReplyList();
  123. }
  124. },
  125. /**
  126. * 页面上拉触底事件的处理函数
  127. */
  128. onReachBottom: function() {
  129. this.getProductReplyList();
  130. },
  131. }
  132. </script>
  133. <style lang="scss">
  134. page{background-color:#fff;}
  135. .evaluate-list .generalComment{height:94rpx;padding:0 30rpx;margin-top:1rpx;background-color:#fff;font-size:28rpx;color:#808080;}
  136. .evaluate-list .generalComment .evaluate{margin-right:7rpx;}
  137. .evaluate-list .nav{font-size:24rpx;color:#282828;padding:0 30rpx 32rpx 30rpx;background-color:#fff;border-bottom:1rpx solid #f5f5f5;}
  138. .evaluate-list .nav .item{font-size:24rpx;color:#282828;border-radius:6rpx;height:54rpx;padding:0 20rpx;background-color:#f4f4f4;line-height:54rpx;margin-right:17rpx;}
  139. .evaluate-list .nav .item.bg-color{color:#fff;}
  140. .noCommodity .pictrue{margin: 0 auto;}
  141. .star-box {
  142. display: flex;
  143. align-items: center;
  144. margin-left: 10rpx;
  145. .star {
  146. position: relative;
  147. width: 111rpx;
  148. height: 19rpx;
  149. background: url(~pages/columnGoods/images/star.png);
  150. background-size: 111rpx 19rpx;
  151. }
  152. .star-active {
  153. position: absolute;
  154. left: 0;
  155. top: 0;
  156. width: 111rpx;
  157. height: 19rpx;
  158. overflow: hidden;
  159. background: url(~pages/columnGoods/images/star_active.png);
  160. background-size: 111rpx 19rpx;
  161. }
  162. .num {
  163. color: $theme-color;
  164. font-size: 24rpx;
  165. margin-left: 10rpx;
  166. }
  167. }
  168. </style>