小程序端工程代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.3 KiB

  1. <template>
  2. <view class="evaluate-list" ref="container">
  3. <view class="header">
  4. <view class="generalComment acea-row row-between-wrapper">
  5. <view class="acea-row row-middle font-color-red">
  6. <text class="evaluate">评分</text>
  7. <view class="start" :class="'star' + replyData.replyStar"></view>
  8. </view>
  9. <view>
  10. <text class="font-color-red">{{ replyData.replyChance || 0 }}%</text>
  11. <text>好评率</text>
  12. </view>
  13. </view>
  14. <view class="nav acea-row row-middle">
  15. <view
  16. class="acea-row row-center-wrapper"
  17. v-for="(item, navListIndex) in navList"
  18. :key="navListIndex"
  19. @click="changeType(navListIndex)"
  20. >
  21. <view
  22. class="item"
  23. :class="currentActive === navListIndex ? 'bg-color-red' : ''"
  24. v-if="item.num"
  25. >
  26. <text>{{ item.evaluate }}({{ item.num }})</text>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <UserEvaluation :reply="reply"></UserEvaluation>
  32. <Loading :loaded="loadend" :loading="loading"></Loading>
  33. </view>
  34. </template>
  35. <script>
  36. import UserEvaluation from "@/components/UserEvaluation";
  37. import { getReplyConfig, getReplyList } from "@/api/store";
  38. import Loading from "@/components/Loading";
  39. export default {
  40. name: "EvaluateList",
  41. components: {
  42. UserEvaluation,
  43. Loading
  44. },
  45. props: {},
  46. data: function() {
  47. return {
  48. product_id: 0,
  49. replyData: {},
  50. navList: [
  51. { evaluate: "全部", num: 0 },
  52. { evaluate: "好评", num: 0 },
  53. { evaluate: "中评", num: 0 },
  54. { evaluate: "差评", num: 0 }
  55. ],
  56. currentActive: 0,
  57. page: 1,
  58. limit: 8,
  59. reply: [],
  60. loadTitle: "",
  61. loading: false,
  62. loadend: false
  63. };
  64. },
  65. mounted: function() {
  66. this.product_id = this.$yroute.query.id;
  67. this.getProductReplyCount();
  68. this.getProductReplyList();
  69. },
  70. onReachBottom() {
  71. !this.loading && this.getProductReplyList();
  72. },
  73. methods: {
  74. getProductReplyCount () {
  75. getReplyConfig(this.product_id).then(res => {
  76. this.$set(that, "replyData", res.data);
  77. this.navList[0].num = res.data.sumCount;
  78. this.navList[1].num = res.data.goodCount;
  79. this.navList[2].num = res.data.inCount;
  80. this.navList[3].num = res.data.poorCount;
  81. });
  82. },
  83. getProductReplyList () {
  84. if (this.loading) return; //阻止下次请求(false可以进行请求);
  85. if (this.loadend) return; //阻止结束当前请求(false可以进行请求);
  86. this.loading = true;
  87. let q = { page: this.page, limit: this.limit, type: this.currentActive };
  88. getReplyList(this.product_id, q).then(res => {
  89. this.loading = false;
  90. //apply();js将一个数组插入另一个数组;
  91. this.reply.push.apply(this.reply, res.data);
  92. this.loadend = res.data.length < this.limit; //判断所有数据是否加载完成;
  93. this.page = this.page + 1;
  94. });
  95. },
  96. changeType (index) {
  97. this.currentActive = index;
  98. this.page = 1;
  99. this.loadend = false;
  100. this.$set(this, "reply", []);
  101. this.getProductReplyList();
  102. }
  103. }
  104. };
  105. </script>
  106. <style scoped lang="less">
  107. .noCommodity {
  108. height: 8*100rpx;
  109. background-color: #fff;
  110. }
  111. </style>