article-footer.vue 1.87 KB
<template>
  <div class="article-footer-wrapper">
    <slot name="before"></slot>
    <div class="tool-bar">
      <WidgetIconBtn ref="favIcon" class="item" type="fav" :pos-id="sceneId" :text="praiseCount" :articleId="articleId" :option="optionPraise"></WidgetIconBtn>
      <WidgetIconBtn class="item" type="star" :pos-id="sceneId" :text="favoriteCount" :articleId="articleId" :option="optionFav" ></WidgetIconBtn>
      <WidgetIconBtn class="item" type="msg" :text="commentCount" :option="optionComment" @click="onComment"></WidgetIconBtn>
    </div>
    <slot name="after">
      <div class="close ml20" @click="onClose">收起</div>
    </slot>
  </div>
</template>

<script>

import YAS from 'utils/yas-constants';

export default {
  name: 'ArticleFooter',
  props: ['favoriteCount', 'praiseCount', 'commentCount', 'hasFavor', 'hasPraise', 'articleId'],
  data() {
    return {
      optionComment: {
        emitName: 'click',
        canSelect: false
      },
      sceneId: YAS.scene.newsDetail
    };
  },
  computed: {
    optionPraise() {
      return {
        selected: this.hasPraise === 'Y'
      };
    },
    optionFav() {
      return {
        selected: this.hasFavor === 'Y'
      }
    }
  },
  methods: {
    onComment() {
      this.$emit('on-comment-click');
    },
    onClose() {
      this.$emit('on-close');
    },
    onPraise() {
      if (this.hasPraise !== 'Y') {
        this.$refs.favIcon.onClick();
      }
    },
  },
};
</script>

<style lang="scss" scoped>

.article-footer-wrapper {
  display: flex;
  height: 100px;
  border-top: 1px solid #f0f0f0;
  background-color: white;
}

.tool-bar {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.close {
  width: 200px;
  color: white;
  font-size: 32px;
  line-height: 100px;
  font-weight: 300;
  background-color: #d0021b;
  text-align: center;
}

.ml20 {
  margin-left: 20px;
}

</style>