<template>
  <section class="comp-title-container">
    <div class="comp-text">
      <p
        class="comp-title"
        :style="{
        'color': fontColor,
        'font-weight': fontWeight,
        'font-size': cTextFontSize,
      }"
      >{{title }}</p>
      <p v-show="isShowExplain" @click="showDialog" class="comp-title-explain">
        <span>查看说明</span>
        <img :src="rightNew">
      </p>
    </div>
    <div v-show="isShowCert === 2" class="cert-img">
      <img class="banner-img" :src="hocImg">
    </div>
  </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: Number,
      default: 1
    },
    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 {
  margin-top: 17px;
  padding-left: 15px;
  // display: flex;
  // flex-direction: row;
  // justify-content: space-between;
  .comp-text {
    position: relative;
    // width: 345px;
    width: 100%;
    overflow: hidden;
  }
}
.comp-title {
  position: relative;
  width: 238px;
  float: left;
  line-height: 30px;
}
.comp-title-explain {
  position: relative;
  float: right;
  // margin-right: 15px;
  margin-top: 3px;
  span {
    font-size: 14px;
    font-weight: 400;
    color: rgba(12, 21, 39, 0.4);
    // margin-right: 3px;
    line-height: 18px;
    height: 18px;
    vertical-align: middle;
  }
  img {
    width: 8px;
    height: 12px;
    vertical-align: middle;
  }
}
.cert-img {
  margin-top: 1px;
  .banner-img {
    width: 70px;
    height: 20px;
    padding-top: 2px;
  }
}
</style>
