index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view :style="viewColor">
  3. <view class='evaluate-list'>
  4. <view class='generalComment acea-row row-between-wrapper'>
  5. <view class='acea-row row-middle t-color'>
  6. <view class='evaluate'>评分</view>
  7. <view class="star-box">
  8. <view class="star">
  9. <view class="star-active" :class="'star'+keyColor" :style="'width:'+replyData.star+';background-image: url('+domain+'/static/diy/score1'+keyColor+'.png)'"></view>
  10. </view>
  11. </view>
  12. </view>
  13. <view><text class='t-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" ? "b-color":""' @click='changeType("count")'>全部({{replyData.stat.count}})</view>
  17. <view class='item' :class='type=="best" ? "b-color":""' @click='changeType("best")'>好评({{replyData.stat.best}})</view>
  18. <view class='item' :class='type=="middle" ? "b-color":""' @click='changeType("middle")'>中评({{replyData.stat.middle}})</view>
  19. <view class='item' :class='type=="negative" ? "b-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="`${domain}/static/images/no_commen.png`"></image>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. // +----------------------------------------------------------------------
  35. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  36. // +----------------------------------------------------------------------
  37. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  38. // +----------------------------------------------------------------------
  39. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  40. // +----------------------------------------------------------------------
  41. // | Author: CRMEB Team <admin@crmeb.com>
  42. // +----------------------------------------------------------------------
  43. import { getReplyList } from '@/api/store.js';
  44. import userEvaluation from '@/components/userEvaluation';
  45. import { mapGetters } from "vuex";
  46. import { HTTP_REQUEST_URL } from '@/config/app';
  47. export default {
  48. components: {
  49. userEvaluation
  50. },
  51. computed: mapGetters(['viewColor','keyColor']),
  52. data() {
  53. return {
  54. domain: HTTP_REQUEST_URL,
  55. replyData: {},
  56. product_id: 0,
  57. reply: [],
  58. type: "count",
  59. loading: false,
  60. loadend: false,
  61. loadTitle: '加载更多',
  62. page: 1,
  63. limit: 20
  64. };
  65. },
  66. /**
  67. * 生命周期函数--监听页面加载
  68. */
  69. onLoad: function(options) {
  70. let that = this;
  71. if (!options.product_id) return that.$util.Tips({
  72. title: '缺少参数'
  73. }, {
  74. tab: 3,
  75. url: 1
  76. });
  77. that.product_id = options.product_id;
  78. },
  79. onShow: function() {
  80. this.getProductReplyList();
  81. },
  82. methods: {
  83. /**
  84. * 分页获取评论
  85. */
  86. getProductReplyList: function() {
  87. let that = this;
  88. if (that.loadend) return;
  89. if (that.loading) return;
  90. that.loading = true;
  91. that.loadTitle = '';
  92. getReplyList(that.product_id, {
  93. page: that.page,
  94. limit: that.limit,
  95. type: that.type,
  96. }).then(res => {
  97. let list = res.data.list,
  98. loadend = list.length < that.limit;
  99. that.reply = that.$util.SplitArray(list, that.reply);
  100. that.$set(that,'reply',that.reply);
  101. that.$set(that,'replyData',res.data)
  102. that.loading = false;
  103. that.loadend = loadend;
  104. that.loadTitle = loadend ? "😕人家是有底线的~~" : "加载更多";
  105. that.page = that.page + 1;
  106. }).catch(err => {
  107. that.loading = false,
  108. that.loadTitle = '加载更多'
  109. });
  110. },
  111. /*
  112. * 点击事件切换
  113. * */
  114. changeType: function(e) {
  115. let type = e
  116. if (type == this.type) return;
  117. this.type = type;
  118. this.page = 1;
  119. this.loadend = false;
  120. this.$set(this,'reply',[]);
  121. this.getProductReplyList();
  122. }
  123. },
  124. /**
  125. * 页面上拉触底事件的处理函数
  126. */
  127. onReachBottom: function() {
  128. this.getProductReplyList();
  129. },
  130. // 滚动监听
  131. onPageScroll(e) {
  132. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  133. uni.$emit('scroll');
  134. },
  135. }
  136. </script>
  137. <style lang="scss">
  138. page{background-color:#fff;}
  139. .evaluate-list .generalComment{height:94rpx;padding:0 30rpx;margin-top:1rpx;background-color:#fff;font-size:28rpx;color:#808080;}
  140. .evaluate-list .generalComment .evaluate{margin-right:7rpx;}
  141. .evaluate-list .nav{font-size:24rpx;color:#282828;padding:0 30rpx 32rpx 30rpx;background-color:#fff;border-bottom:1rpx solid #f5f5f5;}
  142. .evaluate-list .nav .item{
  143. font-size:24rpx;color:#282828;border-radius:6rpx;height:54rpx;padding:0 20rpx;
  144. background-color:#f4f4f4;line-height:54rpx;margin-right:17rpx;
  145. &.b-color{
  146. background-color:var(--view-theme);
  147. color: #fff;
  148. }
  149. }
  150. .noCommodity .pictrue{margin: 0 auto;}
  151. .t-color{color:var(--view-theme);}
  152. .star-box {
  153. display: flex;
  154. align-items: center;
  155. margin-left: 10rpx;
  156. .star {
  157. position: relative;
  158. width: 111rpx;
  159. height: 19rpx;
  160. background: url(~pages/columnGoods/images/star.png);
  161. background-size: 111rpx 19rpx;
  162. }
  163. .star-active {
  164. position: absolute;
  165. left: 0;
  166. top: 0;
  167. width: 111rpx;
  168. height: 19rpx;
  169. overflow: hidden;
  170. background-image: url(~pages/columnGoods/images/star_active.png);
  171. background-size: 111rpx 19rpx;
  172. &.star_purple{
  173. background-image: url(~pages/columnGoods/images/star_active_purple.png);
  174. }
  175. }
  176. .num {
  177. color: $theme-color;
  178. font-size: 24rpx;
  179. margin-left: 10rpx;
  180. }
  181. }
  182. .evaluateWtapper .easy-loadimage {
  183. width: 160rpx;
  184. height: 160rpx;
  185. }
  186. </style>