index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view :style="colorStyle">
  3. <view class='evaluate-list'>
  4. <view class='generalComment acea-row row-between-wrapper'>
  5. <view class='acea-row row-middle'>
  6. <view class='evaluate'>评分</view>
  7. <view class='start' :class="'star'+replyData.reply_star"></view>
  8. </view>
  9. <view><text class='font-num'>{{replyData.reply_chance}}%</text>好评率</view>
  10. </view>
  11. <view class='nav acea-row row-middle'>
  12. <view class='item' :class='type==0 ? "bg-color":""' @click='changeType(0)'>全部({{replyData.sum_count}})
  13. </view>
  14. <view class='item' :class='type==1 ? "bg-color":""' @click='changeType(1)'>好评({{replyData.good_count}})
  15. </view>
  16. <view class='item' :class='type==2 ? "bg-color":""' @click='changeType(2)'>中评({{replyData.in_count}})
  17. </view>
  18. <view class='item' :class='type==3 ? "bg-color":""' @click='changeType(3)'>差评({{replyData.poor_count}})
  19. </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 class='noCommodity' v-if="reply.length==0">
  26. <view class='emptyBox'>
  27. <image :src="imgHost + '/statics/images/noMessage.png'"></image>
  28. <view class="tips">暂无商品,去看点别的吧</view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. getReplyList,
  37. getReplyConfig
  38. } from '@/api/store.js';
  39. import userEvaluation from '@/components/userEvaluation';
  40. import colors from '@/mixins/color.js';
  41. import {
  42. toLogin
  43. } from '@/libs/login.js';
  44. import {
  45. mapGetters
  46. } from "vuex";
  47. import {HTTP_REQUEST_URL} from '@/config/app';
  48. export default {
  49. components: {
  50. userEvaluation
  51. },
  52. mixins: [colors],
  53. computed: mapGetters(['isLogin']),
  54. data() {
  55. return {
  56. replyData: {},
  57. product_id: 0,
  58. reply: [],
  59. type: 0,
  60. loading: false,
  61. loadend: false,
  62. loadTitle: '加载更多',
  63. page: 1,
  64. limit: 20,
  65. imgHost:HTTP_REQUEST_URL
  66. };
  67. },
  68. /**
  69. * 生命周期函数--监听页面加载
  70. */
  71. onLoad: function(options) {
  72. let that = this;
  73. if (!options.product_id) return that.$util.Tips({
  74. title: '缺少参数'
  75. }, {
  76. tab: 3,
  77. url: 1
  78. });
  79. that.product_id = options.product_id;
  80. },
  81. onShow() {
  82. uni.removeStorageSync('form_type_cart');
  83. this.getProductReplyCount();
  84. this.loadend = false;
  85. this.page = 1;
  86. this.reply = [];
  87. this.getProductReplyList();
  88. },
  89. methods: {
  90. /**
  91. * 获取评论统计数据
  92. *
  93. */
  94. getProductReplyCount: function() {
  95. let that = this;
  96. getReplyConfig(that.product_id).then(res => {
  97. that.$set(that, 'replyData', res.data);
  98. });
  99. },
  100. /**
  101. * 分页获取评论
  102. */
  103. getProductReplyList: function() {
  104. let that = this;
  105. if (that.loadend) return;
  106. if (that.loading) return;
  107. that.loading = true;
  108. that.loadTitle = '';
  109. getReplyList(that.product_id, {
  110. page: that.page,
  111. limit: that.limit,
  112. type: that.type,
  113. }).then(res => {
  114. console.log('666699')
  115. let list = res.data,
  116. loadend = list.length < that.limit;
  117. that.reply = that.$util.SplitArray(list, that.reply);
  118. that.$set(that, 'reply', that.reply);
  119. that.loading = false;
  120. that.loadend = loadend;
  121. that.loadTitle = loadend ? "没有更多内容啦~" : "加载更多";
  122. that.page = that.page + 1;
  123. }).catch(err => {
  124. that.loading = false,
  125. that.loadTitle = '加载更多'
  126. });
  127. },
  128. /*
  129. * 点击事件切换
  130. * */
  131. changeType: function(e) {
  132. let type = parseInt(e);
  133. if (type == this.type) return;
  134. this.type = type;
  135. this.page = 1;
  136. this.loadend = false;
  137. this.$set(this, 'reply', []);
  138. this.getProductReplyList();
  139. }
  140. },
  141. /**
  142. * 页面上拉触底事件的处理函数
  143. */
  144. onReachBottom: function() {
  145. this.getProductReplyList();
  146. },
  147. }
  148. </script>
  149. <style lang="scss">
  150. .emptyBox{
  151. text-align: center;
  152. margin-top: 40rpx;
  153. .tips{
  154. color: #aaa;
  155. font-size: 26rpx;
  156. }
  157. image {
  158. width: 414rpx;
  159. height: 336rpx;
  160. }
  161. }
  162. .evaluate-list .generalComment {
  163. height: 94rpx;
  164. padding: 0 30rpx;
  165. margin-top: 1rpx;
  166. //background-color: #fff;
  167. font-size: 28rpx;
  168. color: #808080;
  169. }
  170. .evaluate-list .generalComment .evaluate {
  171. margin-right: 7rpx;
  172. }
  173. .evaluate-list .nav {
  174. font-size: 24rpx;
  175. color: #282828;
  176. padding: 0 30rpx 32rpx 30rpx;
  177. //background-color: #fff;
  178. border-bottom: 1rpx solid #f5f5f5;
  179. }
  180. .evaluate-list .nav .item {
  181. font-size: 24rpx;
  182. color: #282828;
  183. border-radius: 26rpx;
  184. height: 54rpx;
  185. padding: 0 20rpx;
  186. background-color: #fff;
  187. line-height: 54rpx;
  188. margin-right: 17rpx;
  189. }
  190. .evaluate-list .nav .item.bg-color {
  191. color: #fff;
  192. }
  193. </style>