index.vue 5.1 KB

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