<script src="../../vue.config.js"></script>
<template>
  <div class="header">
    <van-nav-bar :title="pagetitle" left-arrow @click-left="returnPage" @click-right="toHome">
      <template #right>
        <van-icon v-if="showRightIcon" name="wap-home-o" size="26" />
      </template>
    </van-nav-bar>
  </div>
</template>
<script lang="ts">
import { Component, Vue, Watch, Prop } from "vue-property-decorator";
@Component
export default class extends Vue {
  @Prop({
    type: String,
    required: true,
    default: " "
  })
  pagetitle!: string;

  @Prop({
    type: Boolean, 
    required: false,
    default: true
  })
  showRightIcon!: boolean; 

  @Watch("$route")
  routechange(to: any, from: any) {
    // if (to.path == "/home" && to.query.userId) {
    //   let baseUrl: string = "";
    //   window.location.href = baseUrl;
    // }
  }
  async created() {
  }
  async returnPage() {
    let that = this;
    if (window.history.length < 1) {
        that.$router.push({ path: "/" });
        return false;
    } else {
        this.$router.go(-1);
    }
    }
  toHome() {
    this.$router.replace('/');
  }
}
</script>
<style lang="scss">
.header {
  /*height: 50px;*/
  /*line-height: 50px;*/
  /*text-align: center;*/
  /*background: #fff;*/
  border-bottom: 1px solid #f8f8f8;

  .van-nav-bar__title {
    font-size: 20px;
    color: #333;
  }

  .van-icon {
    font-size: 20px;
    color: #333 !important;
  }
}
</style>
