erp-nav-bar.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <view class="erp-nav-bar" :style="{ paddingTop: statusBarHeight + 'px', backgroundColor: bgColor }">
  3. <view class="erp-nav-content">
  4. <view class="erp-nav-left" @click="handleBack">
  5. <view v-if="showBack" class="erp-back-arrow" :style="{ borderColor: titleColor }"></view>
  6. </view>
  7. <text class="erp-nav-title" :style="{ color: titleColor }">{{ title }}</text>
  8. <view class="erp-nav-right">
  9. <slot name="right"></slot>
  10. </view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'ErpNavBar',
  17. props: {
  18. title: { type: String, default: '' },
  19. showBack: { type: Boolean, default: true },
  20. bgColor: { type: String, default: '#ffffff' },
  21. titleColor: { type: String, default: '#333333' }
  22. },
  23. data() {
  24. return { statusBarHeight: 20 }
  25. },
  26. mounted() {
  27. this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 20;
  28. },
  29. methods: {
  30. handleBack() {
  31. if (this.showBack) {
  32. this.$emit('back');
  33. uni.navigateBack();
  34. }
  35. }
  36. }
  37. }
  38. </script>
  39. <style scoped>
  40. .erp-nav-bar {
  41. width: 100%;
  42. flex-shrink: 0;
  43. }
  44. .erp-nav-content {
  45. height: 44px;
  46. display: flex;
  47. align-items: center;
  48. justify-content: space-between;
  49. padding: 0 30rpx;
  50. }
  51. .erp-nav-left {
  52. width: 60rpx;
  53. height: 44px;
  54. display: flex;
  55. align-items: center;
  56. }
  57. .erp-back-arrow {
  58. width: 20rpx;
  59. height: 20rpx;
  60. border-left: 4rpx solid #333;
  61. border-bottom: 4rpx solid #333;
  62. transform: rotate(45deg);
  63. margin-left: 8rpx;
  64. }
  65. .erp-nav-title {
  66. flex: 1;
  67. text-align: center;
  68. font-size: 34rpx;
  69. font-weight: bold;
  70. color: #333333;
  71. }
  72. .erp-nav-right {
  73. width: 60rpx;
  74. height: 44px;
  75. display: flex;
  76. align-items: center;
  77. justify-content: flex-end;
  78. }
  79. </style>