<template>
  <view>
    <u-navbar
      :title="title"
      @leftClick="goBack"
      @rightClick="chickIcon"
      :autoBack="true"
      :rightText="text"
      placeholder
    ></u-navbar>
  </view>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: ''
    },
    showBack: {
      type: Boolean,
      default: true
    },
    isBack: {
      type: Boolean,
      default: true
    },
    goTo: {
      type: String,
      default: ''
    },
    rightIcon: {
      type: String,
      default: 'plus'
    },
    showRightIcon: {
      type: Boolean,
      default: false
    },
    showRightText: {
      type: Boolean,
      default: false
    },
    text: {
      type: String,
      default: ''
    }
  },
  data() {
    return {}
  },
  methods: {
    goBack() {
      if (this.isBack) {
        uni.navigateBack()
      } else {
        if (this.goTo) {
          uni.redirectTo({
            url: this.goTo
          })
        } else {
          uni.switchTab({
            url: '/pages/index'
          })
        }
      }
    },
    chickIcon() {
      this.$emit('chickIcon')
    }
  }
}
</script>

<style lang="scss"></style>
