<template>
  <view class="nav-bar" :style="{ paddingTop: statusBarHeight + 'px' }">
    <view class="nav-content">
      <image class="back-btn" src="/static/back.png" mode="aspectFit" @click="onBack" />
      <text class="nav-title">{{ title }}</text>
      <view class="right-slot">
        <slot name="right"></slot>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      statusBarHeight: 0
    }
  },
  mounted() {
    this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0;
  },
  methods: {
    onBack() {
      console.log('onBack');
      uni.navigateBack();
    }
  }
}
</script>

<style scoped>
.nav-bar {
  background: transparent;
}
.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 16px;
}
.back-btn {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-title {
  font-size: 16px;
  font-weight: normal;
  color: #222;
  flex: 1;
  text-align: center;
}
.right-slot {
  min-width: 24px;
}
</style> 