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

<script>
import { navigateBack } from "@/utils/bridgeToAppFun";
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', 'Instructions', 'Settings', 'Grade',
        'AirDrop', 'Invite', 'AboutUs', 'customerService'
      ]
      if (whiteList.indexOf(currentPage) > -1) {
        try {
          navigateBack();
        } catch {
          console.log('不能交互');
        } 
      } else {
        this.$router.go(-1);
      }
      // 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>