index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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" @changeLogin="changeLogin"></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. <!-- #ifdef MP -->
  33. <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize>
  34. <!-- #endif -->
  35. </view>
  36. </template>
  37. <script>
  38. import {
  39. getReplyList,
  40. getReplyConfig
  41. } from '@/api/store.js';
  42. import userEvaluation from '@/components/userEvaluation';
  43. import colors from '@/mixins/color.js';
  44. import {
  45. toLogin
  46. } from '@/libs/login.js';
  47. import {
  48. mapGetters
  49. } from "vuex";
  50. import {HTTP_REQUEST_URL} from '@/config/app';
  51. export default {
  52. components: {
  53. userEvaluation
  54. },
  55. mixins: [colors],
  56. computed: mapGetters(['isLogin']),
  57. data() {
  58. return {
  59. replyData: {},
  60. product_id: 0,
  61. reply: [],
  62. type: 0,
  63. loading: false,
  64. loadend: false,
  65. loadTitle: '加载更多',
  66. page: 1,
  67. limit: 20,
  68. imgHost:HTTP_REQUEST_URL,
  69. isShowAuth:false
  70. };
  71. },
  72. /**
  73. * 生命周期函数--监听页面加载
  74. */
  75. onLoad: function(options) {
  76. let that = this;
  77. if (!options.product_id) return that.$util.Tips({
  78. title: '缺少参数'
  79. }, {
  80. tab: 3,
  81. url: 1
  82. });
  83. that.product_id = options.product_id;
  84. },
  85. onShow() {
  86. uni.removeStorageSync('form_type_cart');
  87. this.getProductReplyCount();
  88. this.loadend = false;
  89. this.page = 1;
  90. this.reply = [];
  91. this.getProductReplyList();
  92. },
  93. methods: {
  94. changeLogin(){
  95. // #ifndef MP
  96. toLogin()
  97. // #endif
  98. // #ifdef MP
  99. this.isShowAuth = true;
  100. // #endif
  101. },
  102. onLoadFun(){
  103. this.isShowAuth = false
  104. },
  105. // 授权关闭
  106. authColse: function(e) {
  107. this.isShowAuth = e
  108. },
  109. /**
  110. * 获取评论统计数据
  111. *
  112. */
  113. getProductReplyCount: function() {
  114. let that = this;
  115. getReplyConfig(that.product_id).then(res => {
  116. that.$set(that, 'replyData', res.data);
  117. });
  118. },
  119. /**
  120. * 分页获取评论
  121. */
  122. getProductReplyList: function() {
  123. let that = this;
  124. if (that.loadend) return;
  125. if (that.loading) return;
  126. that.loading = true;
  127. that.loadTitle = '';
  128. getReplyList(that.product_id, {
  129. page: that.page,
  130. limit: that.limit,
  131. type: that.type,
  132. }).then(res => {
  133. console.log('666699')
  134. let list = res.data,
  135. loadend = list.length < that.limit;
  136. that.reply = that.$util.SplitArray(list, that.reply);
  137. that.$set(that, 'reply', that.reply);
  138. that.loading = false;
  139. that.loadend = loadend;
  140. that.loadTitle = loadend ? "没有更多内容啦~" : "加载更多";
  141. that.page = that.page + 1;
  142. }).catch(err => {
  143. that.loading = false,
  144. that.loadTitle = '加载更多'
  145. });
  146. },
  147. /*
  148. * 点击事件切换
  149. * */
  150. changeType: function(e) {
  151. let type = parseInt(e);
  152. if (type == this.type) return;
  153. this.type = type;
  154. this.page = 1;
  155. this.loadend = false;
  156. this.$set(this, 'reply', []);
  157. this.getProductReplyList();
  158. }
  159. },
  160. /**
  161. * 页面上拉触底事件的处理函数
  162. */
  163. onReachBottom: function() {
  164. this.getProductReplyList();
  165. },
  166. }
  167. </script>
  168. <style lang="scss">
  169. .emptyBox{
  170. text-align: center;
  171. margin-top: 40rpx;
  172. .tips{
  173. color: #aaa;
  174. font-size: 26rpx;
  175. }
  176. image {
  177. width: 414rpx;
  178. height: 336rpx;
  179. }
  180. }
  181. .evaluate-list .generalComment {
  182. height: 94rpx;
  183. padding: 0 30rpx;
  184. margin-top: 1rpx;
  185. //background-color: #fff;
  186. font-size: 28rpx;
  187. color: #808080;
  188. }
  189. .evaluate-list .generalComment .evaluate {
  190. margin-right: 7rpx;
  191. }
  192. .evaluate-list .nav {
  193. font-size: 24rpx;
  194. color: #282828;
  195. padding: 0 30rpx 32rpx 30rpx;
  196. //background-color: #fff;
  197. border-bottom: 1rpx solid #f5f5f5;
  198. }
  199. .evaluate-list .nav .item {
  200. font-size: 24rpx;
  201. color: #282828;
  202. border-radius: 26rpx;
  203. height: 54rpx;
  204. padding: 0 20rpx;
  205. background-color: #fff;
  206. line-height: 54rpx;
  207. margin-right: 17rpx;
  208. }
  209. .evaluate-list .nav .item.bg-color {
  210. color: #fff;
  211. }
  212. </style>