<template>
  <div class="article-info-tools">
    <div v-if="isAvater" class="article-info-tools-auth">
      <el-avatar size="small" :src="data.avater||'/temp/index/male.jpg'"></el-avatar>
      {{ data.name}}
    </div>
    <div class="article-info-tools-btns" style="cursor: pointer;">
      <div v-if="iconFilter.isAnswer" @click="jumpRouter('answer')" style="display:inline-block;margin-left:20px">
        <el-tooltip  effect="light" content="回答" placement="left">
          <svg-icon  icon-class="comment"></svg-icon>
        </el-tooltip>
        <span>{{data.answers}}</span>
      </div>

      <div v-if="!iconFilter.isRemark" @click="jumpRouter()" style="display:inline-block;margin-left:20px">
        <el-tooltip  effect="light" content="评论" placement="left">
          <svg-icon  icon-class="comment"></svg-icon>
        </el-tooltip>
        <span>{{ data.comments }}</span>
      </div>
      <!-- <a v-if="!iconFilter.isRemark" @mouseover="showText('showRemark')" @mouseout="hideText('showRemark')" :href="`${webBaseUrl}/article/detail`" >
        <svg-icon icon-class="comment"></svg-icon>
        {{ article[fieldsList.comments] }}
        <span v-show="showList.showRemark">评论</span>
      </a> -->
      <div v-if="!iconFilter.isShare" @click="addShare()" style="display:inline-block;margin-left:20px">
        <el-tooltip effect="light" content="分享" placement="top">
          <svg-icon  icon-class="share"></svg-icon>
        </el-tooltip>
        {{ data.shares }}
      </div>
      <div v-if="!iconFilter.isPraise" @click="addPraise()" style="display:inline-block;margin-left:20px">
        <el-tooltip effect="light" content="点赞" placement="top">
          <svg-icon @click="emit('praise')" :icon-class="data.isPraise?'praised':'like'"></svg-icon>
        </el-tooltip>
        {{ data.praises }}
      </div>

      <!-- <a v-if="!iconFilter.isShare" @mouseover="showText('showShare')" @mouseout="hideText('showShare')" :href="`${webBaseUrl}/article/detail`" >
        <svg-icon icon-class="share"></svg-icon>
        {{ article[fieldsList.shares] }}
        <span v-show="showList.showShare">分享</span>
      </a> -->
      <div v-if="!iconFilter.isCollect"  @click="addCollect()" style="display:inline-block;margin-left:20px">
        <el-tooltip effect="light" content="收藏" placement="top">
          <svg-icon @click="emit('collect')" :icon-class="data.isCollect?'collected':'collection'"></svg-icon>
        </el-tooltip>
        {{ data.favorites }}
      </div>
      <!-- <a v-if="!iconFilter.isCollect" @mouseover="showText('showCollect')" @mouseout="hideText('showCollect')" :href="`${webBaseUrl}/article/detail`" >
        <svg-icon icon-class="collection"></svg-icon>
        {{ article[fieldsList.collects] }}
        <span v-show="showList.showCollect">收藏</span>
      </a> -->


      <!-- <a v-if="!iconFilter.isPraise" @mouseover="showText('showPraise')" @mouseout="hideText('showPraise')" :href="`${webBaseUrl}/article/detail`" >
        <svg-icon icon-class="like"></svg-icon>
        {{ article[fieldsList.praises] }}
        <span v-show="showList.showPraise">点赞</span>
      </a> -->
      <div v-if="!iconFilter.isBrowse" style="display:inline-block;margin-left:20px;cursor: default;">
        <el-tooltip effect="light" content="浏览量" placement="top">
          <svg-icon icon-class="views"></svg-icon>
        </el-tooltip>
        {{ data.views}}
      </div>

      <!-- <a v-if="!iconFilter.isBrowse" @mouseover="showText('showBrowse')" @mouseout="hideText('showBrowse')" :href="`${webBaseUrl}/article/detail`" >
        <svg-icon icon-class="views"></svg-icon>
        {{ article[fieldsList.browses] }}
        <span v-show="showList.showBrowse">浏览量</span>
      </a> -->
      <!-- <el-tooltip class="article-info-tools-btn" effect="dark" content="Top Left 提示文字" placement="top-start">
        <svg-icon icon-class="comment"></svg-icon>{{ article[fieldsList.comments] }}
      </el-tooltip> -->
      <!-- <el-link v-if="!iconFilter.isRemark" :href="`${webBaseUrl}/article/detail`" >
        <svg-icon icon-class="comment"></svg-icon>
        评论
      </el-link> -->
  <!--    {{ article[fieldsList.comments] }} -->
      <!-- <a  @mouseover="showText(1)" @mouseout="hideText(1)"  v-if="!iconFilter.isShare" :href="`${webBaseUrl}/article/detail`" class="article-info-tools-btn">
        <svg-icon icon-class="share"></svg-icon>
        <span v-if="shareText">分享</span>{{ article[fieldsList.shares] }}
      </a> -->
      <!-- <el-link v-if="!iconFilter.isCollect" class="article-info-tools-btn">
        <svg-icon icon-class="collection"></svg-icon>
        收藏{{ article[fieldsList.collects] }}
      </el-link>
      <el-link v-if="!iconFilter.isPraise" class="article-info-tools-btn">
        <svg-icon icon-class="like"></svg-icon>
        点赞{{ article[fieldsList.praises] }}
      </el-link>
      <el-link v-if="!iconFilter.isBrowse" class="article-info-tools-btn">
        <svg-icon icon-class="views"></svg-icon>
        浏览量{{ article[fieldsList.browses] }}
      </el-link> -->
    </div>
    <el-dialog title="分享" :visible.sync="shareShow" :close-on-click-modal="false" width="500px" custom-class="g-dialog">
        <div style="height: 200px;padding-right: 30px;">

            <el-form  label-width="80px">
              <el-form-item label="工号">
                <el-input v-model="shareInfo.code" placeholder="您要分享的人的工号">
                  <el-button slot="append" icon="el-icon-search">搜索</el-button>
                </el-input>
              </el-form-item>
            </el-form>
            <div>

            </div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="shareShow= false">取 消</el-button>
          <el-button type="primary" >提交分享</el-button>
        </span>
    </el-dialog>
  </div>
</template>

<script>
  import apiPraise from "@/api/modules/praises.js"
export default {
  props: {
    data: {
      type:Object,
      default:function(){
        return {
          avater: '',
          name: '',
          comments: 0,
          shares: 0,
          collects: 0,
          praises: 0,
          browses: 0,
          answers:0
        }
      }
    },
    iconFilter: {
      type: Object,
      default: function() {
        return {};
      }
    },
    isAvater:{
      type:Boolean,
      default:function(){
        return true
      }
    }
  },
  data(){
    return {
      shareShow:false,
      shareInfo:{
        code:''
      },
    }
  },
  mounted(){
  },
  methods:{
    addShare(){
      //分享
      this.shareShow=true;
    },
    addPraise(){
      //需要判断是否已点赞，已点赞的不再加
      this.$message({message:'点赞成功',type:'success'})
    },
    addCollect(){
      //需要判断是否已点赞，已点赞的不再加
      this.$message({message:'已加入收藏',type:'success'});
    },
    jumpRouter(type){
      if(type=='answer'){
        this.$router.push({path:'/qa/answer',query:{id:this.article.id}})
      }
      else{
      }
      // this.$router.push({path:'/article/detail'})
    },
    emit(type){
      this.$emit('enSure',type)
    }
  },
};
</script>

<style lang="scss" scoped>
.article-info-tools {
  height: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .article-info-tools-auth {
    font-size: 13px;
    color: #999999;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    .el-avatar {
      margin-right: 10px;
    }
  }
  .article-info-tools-btns {
    line-height: 30px;
    .article-info-tools-btn {
      margin: 0 0 0 15px;
    }
  }
}
</style>
