<template>
  <div class="base-nav-bar">
    <van-nav-bar
      :title="navBarTitle"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
  </div>
</template>

<script>
export default {
  name: "BaseNavBar",
  props: {
    navBarTitle: {
      type: String,
      default: "标题"
    }
  },
  methods: {
    onClickLeft() {
      const currentPage = this.$router.currentRoute.name;
      console.log("router", currentPage);
      const whiteList = [
        "MyStatus",
        "Publish",
        "FastestProgress",
        "MonthAward",
        "Settings",
        "Grade",
        "AirDrop",
        "Invite",
        "AboutUs",
        "Wallet"
      ];
      if (whiteList.indexOf(currentPage) > -1) {
        try {
          this.$bridgeToAppFun.navigateBack();
        } catch {
          console.log("不能交互");
        }
      } else {
        this.$router.go(-1);
      }
    },
    onClickRight() {
      console.log("right");
    }
  }
};
</script>

<style>
.van-nav-bar__content .van-nav-bar__title {
  font-family: PingFang-SC-Bold;
  font-size: 20px;
  font-weight: normal;
  font-stretch: normal;
  line-height: 20px;
  color: #333333;
}
.van-nav-bar__content .van-nav-bar__left .van-icon {
  color: #333333;
  font-size: 20px;
}
</style>

<style lang="scss" scoped>
::v-deep .van-nav-bar .van-icon {
  color: #000000;
}
</style>