<template>
  <section class="comp-title-container">
    <span>
      <span
        class="comp-title"
        :style="{
        'color': fontColor,
        'font-weight': fontWeight,
        'font-size': cTextFontSize,
        'padding-top': cPaddingTop,
        'padding-bottom': cPaddingBottom
      }"
      >{{title | shortName(16)}}</span>
      <!-- <img
        v-show="isShowCert"
        :style="{
        'padding-top': cImgPaddingTop,
      }"
        class="banner-img"
        :src="hocImg"
      >-->
      <img v-show="isShowCert" class="banner-img" :src="hocImg">
    </span>
    <span v-show="isShowMore" @click.stop.prevent="showMove" class="comp-title-more">
      <span>更多</span>
      <img :src="rightIcon">
    </span>
    <span v-show="isShowExplain" @click="showDialog" class="comp-title-explain">
      <span>查看说明</span>
      <img :src="rightNew">
    </span>
  </section>
</template>
<script>
export default {
  name: "common-title",
  data() {
    return {
      fontSize: 37.5,
      cImgPaddingTop: "1rem",
      hocImg: require("../../images/has-cert-new.png"),
      rightIcon: require("../../images/right-icon.png"),
      rightNew: require("../../images/right-new.png"),
    };
  },
  props: {
    title: {
      type: String,
      default: ""
    },
    fontColor: {
      type: String,
      default: "#333"
    },
    fontWeight: {
      type: Number,
      default: 700
    },
    textFontSize: {
      type: Number,
      default: 18
    },
    paddingTop: {
      type: Number,
      default: 20
    },
    paddingBottom: {
      type: Number,
      default: 15
    },
    isShowCert: {
      type: Boolean,
      default: true
    },
    isShowMore: {
      type: Boolean,
      default: false
    },
    isShowExplain: {
      type: Boolean,
      default: false
    }
  },
  created() {},
  mounted() {
    let htmlDom = document.getElementsByTagName("html")[0].style.fontSize;
    this.fontSize = htmlDom;
    console.log(htmlDom);
  },
  computed: {
    cTextFontSize() {
      return this.textFontSize / this.fontSize + "rem";
    },
    cPaddingTop() {
      this.cImgPaddingTop = (this.paddingTop + 3) / this.fontSize + "rem";
      return this.paddingTop / this.fontSize + "rem";
    },
    cPaddingBottom() {
      return this.paddingBottom / this.fontSize + "rem";
    }
  },
  methods: {
    showMove() {
      this.$emit("showMore");
    },
    showDialog() {
      this.$emit("showDialog");
    }
  }
};
</script>
<style lang="less" scoped>
.comp-title-container {
  padding-left: 15px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  span {
    display: flex;
    align-items: center;
  }
}
.comp-title {
  // font-family: "PingFangSC-Medium", "PingFangSC", "Microsoft Yahei";
  &-more {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-right: 15px;
    span {
      font-size: 14px;
      font-weight: 400;
      color: rgba(40, 52, 76, 0.4);
    }
    img {
      width: 15px;
      height: 16px;
    }
  }
  &-explain {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-right: 15px;
    span {
      font-size: 14px;
      font-weight: 400;
      color: rgba(40, 52, 76, 0.4);
      margin-right: 3px;
      line-height: 14px;
    }
    img {
      width: 8px;
      height: 14px;
    }
  }
}

.banner-img {
  width: 70px;
  height: 20px;
  padding-top: 2px;
}
</style>
