index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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" @replyFun="replyFun"></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. replyFun(e){
  95. this.reply = e;
  96. },
  97. changeLogin(){
  98. // #ifndef MP
  99. toLogin()
  100. // #endif
  101. // #ifdef MP
  102. this.isShowAuth = true;
  103. // #endif
  104. },
  105. onLoadFun(){
  106. this.isShowAuth = false
  107. },
  108. // 授权关闭
  109. authColse: function(e) {
  110. this.isShowAuth = e
  111. },
  112. /**
  113. * 获取评论统计数据
  114. *
  115. */
  116. getProductReplyCount: function() {
  117. let that = this;
  118. getReplyConfig(that.product_id).then(res => {
  119. that.$set(that, 'replyData', res.data);
  120. });
  121. },
  122. /**
  123. * 分页获取评论
  124. */
  125. getProductReplyList: function() {
  126. let that = this;
  127. if (that.loadend) return;
  128. if (that.loading) return;
  129. that.loading = true;
  130. that.loadTitle = '';
  131. getReplyList(that.product_id, {
  132. page: that.page,
  133. limit: that.limit,
  134. type: that.type,
  135. }).then(res => {
  136. console.log('666699')
  137. let list = res.data,
  138. loadend = list.length < that.limit;
  139. that.reply = that.$util.SplitArray(list, that.reply);
  140. that.$set(that, 'reply', that.reply);
  141. that.loading = false;
  142. that.loadend = loadend;
  143. that.loadTitle = loadend ? "没有更多内容啦~" : "加载更多";
  144. that.page = that.page + 1;
  145. }).catch(err => {
  146. that.loading = false,
  147. that.loadTitle = '加载更多'
  148. });
  149. },
  150. /*
  151. * 点击事件切换
  152. * */
  153. changeType: function(e) {
  154. let type = parseInt(e);
  155. if (type == this.type) return;
  156. this.type = type;
  157. this.page = 1;
  158. this.loadend = false;
  159. this.$set(this, 'reply', []);
  160. this.getProductReplyList();
  161. }
  162. },
  163. /**
  164. * 页面上拉触底事件的处理函数
  165. */
  166. onReachBottom: function() {
  167. this.getProductReplyList();
  168. },
  169. }
  170. </script>
  171. <style lang="scss">
  172. .emptyBox{
  173. text-align: center;
  174. margin-top: 40rpx;
  175. .tips{
  176. color: #aaa;
  177. font-size: 26rpx;
  178. }
  179. image {
  180. width: 414rpx;
  181. height: 336rpx;
  182. }
  183. }
  184. .evaluate-list .generalComment {
  185. height: 94rpx;
  186. padding: 0 30rpx;
  187. margin-top: 1rpx;
  188. //background-color: #fff;
  189. font-size: 28rpx;
  190. color: #808080;
  191. }
  192. .evaluate-list .generalComment .evaluate {
  193. margin-right: 7rpx;
  194. }
  195. .evaluate-list .nav {
  196. font-size: 24rpx;
  197. color: #282828;
  198. padding: 0 30rpx 32rpx 30rpx;
  199. //background-color: #fff;
  200. border-bottom: 1rpx solid #f5f5f5;
  201. }
  202. .evaluate-list .nav .item {
  203. font-size: 24rpx;
  204. color: #282828;
  205. border-radius: 26rpx;
  206. height: 54rpx;
  207. padding: 0 20rpx;
  208. background-color: #fff;
  209. line-height: 54rpx;
  210. margin-right: 17rpx;
  211. }
  212. .evaluate-list .nav .item.bg-color {
  213. color: #fff;
  214. }
  215. </style>