commentDetail.vue 2.92 KB
<!-- 评论详情 -->
<template>
  <div class="comment-detail marketing p-t-20 edit-box">
    <div class="container edit-container">
      <p class="edit-title">{{ title }}</p>
      <div class="comment-container">
        <div class="flex">
          <img class="img-100" :src="commentInfo.goodsImage" />
          <span class="good-name">{{commentInfo.goodsName}}</span>
        </div>
        <div class="flex m-t-24">
          <span class="comment-label">评分星级:</span>
          <img v-for="(item, index) in starList" :key="index" class="icon-star" src="@/assets/icon-star.png"/>
        </div>
        <div class="flex m-t-24">
          <span class="comment-label">评价内容:</span>
          <span class="comment-txt">{{commentInfo.commentContent || '-'}}</span>
        </div>
        <div v-show="commentInfo.imgUrls" class="m-t-24">
          <span class="comment-label">图片:</span>
          <div class="flex" style="flex-wrap: wrap;">
            <span v-for="(item, index) in commentInfo.imgUrls" :key="index">
              <el-image class="img-60 comment-img" :src="item" :preview-src-list="[item]"></el-image>
            </span>
          </div>
        </div>
      </div>
    </div>
    <div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
      <el-button type="default" @click="handleCancel">返回</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'commentDetail',
  data() {
    return {
      size: 'small',
      title: '评论详情',
      footerLeft: '0',
      footerWidth: '0',
      editChildRef: 'editChildRef',
      routeInfo: {
        id: ''
      },
      starList : [],
      commentInfo: {}
    }
  },

  mounted() {
    this.footerLeft = document.querySelector('.base-container-right').offsetLeft
    this.footerWidth = document.documentElement.clientWidth - this.footerLeft
    this.routeInfo = this.$route.query
    this.getInfo()
  },

  methods: {
    getInfo() {
      this.$apis.orderComment.commentDetailApi({ id: this.routeInfo.id }).then(res => {
        this.commentInfo = res || {}
        this.starList = new Array(this.commentInfo.starLevel)
      })
    },
    handleCancel() {
      this.$router.push({
        path: '/orderComment/index'
      })
    }
  }
}
</script>
<style>
.comment-detail .comment-container {
  padding: 32px 52px;
  color: #333333;
  font-size: 14px;
}
.comment-detail .comment-container .flex {
  justify-content: flex-start;
}
.comment-detail .comment-container .m-t-24 {
  margin-top: 24px;
}
.comment-detail .comment-label {
  display: inline-block;
  width: 80px;
  line-height: 20px;
  flex-shrink: 0;
}
.comment-detail .comment-txt {
  line-height: 20px;
  word-break: break-all;
}
.comment-detail .good-name {
  padding-left: 20px;
  font-size: 16px;
  font-weight: 500;
}
.comment-detail .icon-star {
  width: 20px;
  height: 20px;
}
.comment-detail .comment-img {
  margin-top: 10px;
  margin-right: 20px;
}
</style>