<template>
  <div class="back">
    <div class="back-l" @click="back">
      <i class="fa fa-mail-reply-all"></i>
      <slot name="title"></slot>
    </div>
    <div class="back-r">
      <slot name="btns"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "back",
  props: {
    params: {
      type: Object,
      default: function () {
        return {}
      }
    },
    toHome: {
      type: Boolean,
      default: false
    },
  },
  methods: {
    back() {
      if (this.toHome) {
        this.$router.push({
          path: "/index",
        })
        return
      }
      this.$router.go(-1);
    },
  },
};
</script>

<style lang="scss" scoped>
.back {
  width: 100%;
  height: 56px;
  border-bottom: 1px solid #e2e2e2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;

  .back-l {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 18px;
    font-weight: 500;
  }

  .back-r {
    flex: 1;
    display: flex;
    justify-content: flex-end;
  }

  .fa-mail-reply-all {
    font-size: 28px;
    color: #b3b3b3;
    margin-right: 12px;
  }
}
</style>