<template>
  <div class="title_container">
    <img class="back" :src="arrowSrc" @click="goBack" v-if="show_back">
    <div class="title_text" :style="'color:'+thisTitleColor">{{title_text}}</div>
    <div class="my_data" v-if="show_my_data">
      <router-link to="/MyData" replace>个人信息</router-link>
    </div>
    <div class="my_data" v-if="show_blame">
      <router-link to="/Blame" replace>投诉</router-link>
    </div>
  </div>
</template>

<script>
  export default {
    name: "Title",
    data() {
      return {
        blackArrow: require('../images/components/Title/ic_back_black.png'),
        whiteArrow: require('../images/components/Title/ic_back_white.png'),
      };
    },
    props: ["title", "show_back", "show_my_data", "show_blame", "arrowColor", "titleColor"],
    methods: {
      goBack() {
        this.$emit("goback", true);
      }
    },
    computed: {
      title_text() {
        return this.title;
      },
      thisTitleColor() {
        let titleColor = '#fff';
        if (this.titleColor) {
          titleColor = this.titleColor;
        }
        return titleColor;
      },
      arrowSrc() {
        let arrowSrc = this.whiteArrow;
        if (this.arrowColor === 'black') {
          arrowSrc = this.blackArrow;
        } else if (this.arrowColor === 'white') {
          arrowSrc = this.whiteArrow;
        }
        return arrowSrc;
      }
    }
  };
</script>

<style>
  .title_container {
    font-size: 0.36rem;
    color: #ffffff;
    z-index: 999;
  }

  .title_container > div {
    font-size: 0.36rem;
  }

  .title_container > div > a {
    font-size: 0.32rem;
    color: #ffffff;
    text-decoration: none;
  }

  .back {
    width: 0.24rem;
    height: 0.42rem;
    left: 0.2rem;
    top: 0.26rem;
    position: absolute;
  }

  .my_data {
    position: absolute;
    top: 0.32rem;
    right: 0.2rem;
    font-size: 0.32rem;
  }

  .big .title_container {
    padding-top: 0.3rem;
  }

  .big .my_data {
    top: 0.32rem;
    font-size: 0.32rem;
  }

  .title_text {
    height: .36rem;
    font-size: 0.36rem;
    line-height: 1;
    text-align: center;
    padding: .3rem 0;
  }
</style>