detail-comment-card.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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">{{$t('goods.detail.comment')}}</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">{{$t('goods.detail.viewAll')}}</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="$t('goods.detail.msg1')"
  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. state.commentList = data.data;
  50. state.total = data.total;
  51. }
  52. onBeforeMount(() => {
  53. getComment(props.goodsId);
  54. });
  55. </script>
  56. <style lang="scss" scoped>
  57. .detail-comment-card {
  58. margin: 0 20rpx 20rpx 20rpx;
  59. padding: 20rpx 20rpx 0 20rpx;
  60. .card-header {
  61. .line {
  62. width: 6rpx;
  63. height: 30rpx;
  64. background: linear-gradient(180deg, var(--ui-BG-Main) 0%, var(--ui-BG-Main-gradient) 100%);
  65. border-radius: 3rpx;
  66. }
  67. .title {
  68. font-size: 30rpx;
  69. font-weight: bold;
  70. line-height: normal;
  71. }
  72. .des {
  73. font-size: 24rpx;
  74. color: $dark-9;
  75. }
  76. .more-btn {
  77. font-size: 24rpx;
  78. color: var(--ui-BG-Main);
  79. line-height: normal;
  80. }
  81. .cicon-forward {
  82. font-size: 24rpx;
  83. line-height: normal;
  84. color: var(--ui-BG-Main);
  85. margin-top: 4rpx;
  86. }
  87. }
  88. }
  89. .comment-box {
  90. border-bottom: 2rpx solid #eeeeee;
  91. &:last-child {
  92. border: none;
  93. }
  94. }
  95. </style>