detail-comment-card.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="detail-comment-card bg-white">
  3. <view class="card-header ss-flex ss-col-center ss-row-between ss-p-b-30">
  4. <view class="ss-flex ss-col-center">
  5. <view class="line"></view>
  6. <view class="title ss-m-l-20 ss-m-r-10">评价</view>
  7. <view class="des">({{ state.total }})</view>
  8. </view>
  9. <view
  10. class="ss-flex ss-col-center"
  11. @tap="sheep.$router.go('/pages/goods/comment/list', { id: goodsId })"
  12. v-if="state.commentList.length > 0"
  13. >
  14. <button class="ss-reset-button more-btn">查看全部</button>
  15. <text class="cicon-forward"></text>
  16. </view>
  17. </view>
  18. <view class="card-content">
  19. <view class="comment-box ss-p-y-30" v-for="item in state.commentList" :key="item.id">
  20. <comment-item :item="item"></comment-item>
  21. </view>
  22. <s-empty
  23. v-if="state.commentList.length === 0"
  24. paddingTop="0"
  25. icon="/static/comment-empty.png"
  26. text="期待您的第一个评价"
  27. ></s-empty>
  28. </view>
  29. </view>
  30. </template>
  31. <script setup>
  32. import { reactive, onBeforeMount } from 'vue';
  33. import sheep from '@/sheep';
  34. import commentItem from './comment-item.vue';
  35. const props = defineProps({
  36. goodsId: {
  37. type: [Number, String],
  38. default: 0,
  39. },
  40. });
  41. const state = reactive({
  42. commentList: [],
  43. total: 0,
  44. });
  45. async function getComment(id) {
  46. const { data } = await sheep.$api.goods.comment(id, {
  47. list_rows: 3,
  48. });
  49. const {data:datas} = await sheep.$api.goods.comment2(id);
  50. state.commentList = data;
  51. state.total = datas.total;
  52. }
  53. onBeforeMount(() => {
  54. getComment(props.goodsId);
  55. });
  56. </script>
  57. <style lang="scss" scoped>
  58. .detail-comment-card {
  59. margin: 0 20rpx 20rpx 20rpx;
  60. padding: 20rpx 20rpx 0 20rpx;
  61. .card-header {
  62. .line {
  63. width: 6rpx;
  64. height: 30rpx;
  65. background: linear-gradient(180deg, var(--ui-BG-Main) 0%, var(--ui-BG-Main-gradient) 100%);
  66. border-radius: 3rpx;
  67. }
  68. .title {
  69. font-size: 30rpx;
  70. font-weight: bold;
  71. line-height: normal;
  72. }
  73. .des {
  74. font-size: 24rpx;
  75. color: $dark-9;
  76. }
  77. .more-btn {
  78. font-size: 24rpx;
  79. color: var(--ui-BG-Main);
  80. line-height: normal;
  81. }
  82. .cicon-forward {
  83. font-size: 24rpx;
  84. line-height: normal;
  85. color: var(--ui-BG-Main);
  86. margin-top: 4rpx;
  87. }
  88. }
  89. }
  90. .comment-box {
  91. border-bottom: 2rpx solid #eeeeee;
  92. &:last-child {
  93. border: none;
  94. }
  95. }
  96. </style>