index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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='../static/images/noEvaluate.png'></image>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. // +----------------------------------------------------------------------
  35. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  36. // +----------------------------------------------------------------------
  37. // | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
  38. // +----------------------------------------------------------------------
  39. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  40. // +----------------------------------------------------------------------
  41. // | Author: CRMEB Team <admin@crmeb.com>
  42. // +----------------------------------------------------------------------
  43. import { getReplyList, getReplyConfig } 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.getProductReplyCount();
  81. this.getProductReplyList();
  82. },
  83. methods: {
  84. /**
  85. * 获取评论统计数据
  86. *
  87. */
  88. // getProductReplyCount: function() {
  89. // let that = this;
  90. // getReplyConfig(that.product_id).then(res => {
  91. // that.$set(that,'replyData',res.data);
  92. // });
  93. // },
  94. /**
  95. * 分页获取评论
  96. */
  97. getProductReplyList: function() {
  98. let that = this;
  99. if (that.loadend) return;
  100. if (that.loading) return;
  101. that.loading = true;
  102. that.loadTitle = '';
  103. getReplyList(that.product_id, {
  104. page: that.page,
  105. limit: that.limit,
  106. type: that.type,
  107. }).then(res => {
  108. let list = res.data.list,
  109. loadend = list.length < that.limit;
  110. that.reply = that.$util.SplitArray(list, that.reply);
  111. that.$set(that,'reply',that.reply);
  112. that.$set(that,'replyData',res.data)
  113. that.loading = false;
  114. that.loadend = loadend;
  115. that.loadTitle = loadend ? "😕人家是有底线的~~" : "加载更多";
  116. that.page = that.page + 1;
  117. }).catch(err => {
  118. that.loading = false,
  119. that.loadTitle = '加载更多'
  120. });
  121. },
  122. /*
  123. * 点击事件切换
  124. * */
  125. changeType: function(e) {
  126. let type = e
  127. if (type == this.type) return;
  128. this.type = type;
  129. this.page = 1;
  130. this.loadend = false;
  131. this.$set(this,'reply',[]);
  132. this.getProductReplyList();
  133. }
  134. },
  135. /**
  136. * 页面上拉触底事件的处理函数
  137. */
  138. onReachBottom: function() {
  139. this.getProductReplyList();
  140. },
  141. // 滚动监听
  142. onPageScroll(e) {
  143. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  144. uni.$emit('scroll');
  145. },
  146. }
  147. </script>
  148. <style lang="scss">
  149. page{background-color:#fff;}
  150. .evaluate-list .generalComment{height:94rpx;padding:0 30rpx;margin-top:1rpx;background-color:#fff;font-size:28rpx;color:#808080;}
  151. .evaluate-list .generalComment .evaluate{margin-right:7rpx;}
  152. .evaluate-list .nav{font-size:24rpx;color:#282828;padding:0 30rpx 32rpx 30rpx;background-color:#fff;border-bottom:1rpx solid #f5f5f5;}
  153. .evaluate-list .nav .item{
  154. font-size:24rpx;color:#282828;border-radius:6rpx;height:54rpx;padding:0 20rpx;
  155. background-color:#f4f4f4;line-height:54rpx;margin-right:17rpx;
  156. &.b-color{
  157. background-color:var(--view-theme);
  158. color: #fff;
  159. }
  160. }
  161. .noCommodity .pictrue{margin: 0 auto;}
  162. .t-color{color:var(--view-theme);}
  163. .star-box {
  164. display: flex;
  165. align-items: center;
  166. margin-left: 10rpx;
  167. .star {
  168. position: relative;
  169. width: 111rpx;
  170. height: 19rpx;
  171. background: url(~pages/columnGoods/images/star.png);
  172. background-size: 111rpx 19rpx;
  173. }
  174. .star-active {
  175. position: absolute;
  176. left: 0;
  177. top: 0;
  178. width: 111rpx;
  179. height: 19rpx;
  180. overflow: hidden;
  181. background-image: url(~pages/columnGoods/images/star_active.png);
  182. background-size: 111rpx 19rpx;
  183. &.star_purple{
  184. background-image: url(~pages/columnGoods/images/star_active_purple.png);
  185. }
  186. }
  187. .num {
  188. color: $theme-color;
  189. font-size: 24rpx;
  190. margin-left: 10rpx;
  191. }
  192. }
  193. .evaluateWtapper .easy-loadimage {
  194. width: 160rpx;
  195. height: 160rpx;
  196. }
  197. </style>