|
@@ -0,0 +1,101 @@
|
|
|
+<!-- 商品评论的卡片 -->
|
|
|
+<template>
|
|
|
+ <div class="detail-comment-card ">
|
|
|
+ <div class="card-header d-flex align-center justify-space-between pb-6">
|
|
|
+ <div class="resume-header">
|
|
|
+ <div class="resume-title">
|
|
|
+ 评价<span class="des ml-1">({{ state.total }})</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- @tap="sheep.$router.go('/pages/goods/comment/list', { id: goodsId })" -->
|
|
|
+ <div
|
|
|
+ class="ss-flex ss-col-center"
|
|
|
+ @click="null"
|
|
|
+ v-if="state.commentList.length > 0"
|
|
|
+ >
|
|
|
+ <v-btn variant="text" class="ss-reset-button more-btn">查看全部</v-btn>
|
|
|
+ <span class="cicon-forward" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- 评论列表 -->
|
|
|
+ <div class="card-content">
|
|
|
+ <div class="comment-box ss-p-y-30" v-for="item in state.commentList" :key="item.id">
|
|
|
+ <comment-item :item="item" />
|
|
|
+ </div>
|
|
|
+ <div v-if="state.commentList.length === 0" style="margin: 30px auto; color: #777;">期待您的第一个评价</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+ import { reactive, onBeforeMount } from 'vue';
|
|
|
+ import { getCommentPage } from '@/api/mall/product'
|
|
|
+ import commentItem from './comment-item.vue';
|
|
|
+
|
|
|
+ const props = defineProps({
|
|
|
+ goodsId: {
|
|
|
+ type: [Number, String],
|
|
|
+ default: 0,
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ const state = reactive({
|
|
|
+ commentList: [], // 评论列表,只展示最近的 3 条
|
|
|
+ total: 0, // 总评论数
|
|
|
+ });
|
|
|
+
|
|
|
+ async function getComment(id) {
|
|
|
+ const res = await getCommentPage(id, 1, 3, 0);
|
|
|
+ state.commentList = res.list;
|
|
|
+ state.total = res.total;
|
|
|
+ }
|
|
|
+
|
|
|
+ onBeforeMount(() => {
|
|
|
+ getComment(props.goodsId);
|
|
|
+ });
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .detail-comment-card {
|
|
|
+ margin: 0 20rpx 20rpx 20rpx;
|
|
|
+ padding: 20rpx 20rpx 0 20rpx;
|
|
|
+ .card-header {
|
|
|
+ .line {
|
|
|
+ width: 6rpx;
|
|
|
+ height: 30rpx;
|
|
|
+ background: linear-gradient(180deg, var(--v-primary-base) 0%, var(--v-primary-lighten1) 100%);
|
|
|
+ border-radius: 3rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .title {
|
|
|
+ font-size: 30rpx;
|
|
|
+ font-weight: bold;
|
|
|
+ line-height: normal;
|
|
|
+ }
|
|
|
+
|
|
|
+ .des {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: #999999;
|
|
|
+ }
|
|
|
+
|
|
|
+ .more-btn {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: var(--v-primary-base);
|
|
|
+ line-height: normal;
|
|
|
+ }
|
|
|
+
|
|
|
+ .cicon-forward {
|
|
|
+ font-size: 24rpx;
|
|
|
+ line-height: normal;
|
|
|
+ color: var(--v-primary-base);
|
|
|
+ margin-top: 4rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .comment-box {
|
|
|
+ border-bottom: 2rpx solid #eeeeee;
|
|
|
+ &:last-child {
|
|
|
+ border: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|