erp-nav-bar.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. const winInfo = uni.getWindowInfo ? uni.getWindowInfo() : uni.getSystemInfoSync();
  28. this.statusBarHeight = winInfo.statusBarHeight || 20;
  29. },
  30. methods: {
  31. handleBack() {
  32. if (this.showBack) {
  33. this.$emit('back');
  34. uni.navigateBack();
  35. }
  36. }
  37. }
  38. }
  39. </script>
  40. <style scoped>
  41. .erp-nav-bar {
  42. width: 100%;
  43. flex-shrink: 0;
  44. }
  45. .erp-nav-content {
  46. height: 44px;
  47. display: flex;
  48. align-items: center;
  49. justify-content: space-between;
  50. padding: 0 30rpx;
  51. }
  52. .erp-nav-left {
  53. width: 60rpx;
  54. height: 44px;
  55. display: flex;
  56. align-items: center;
  57. }
  58. .erp-back-arrow {
  59. width: 20rpx;
  60. height: 20rpx;
  61. border-left: 4rpx solid #333;
  62. border-bottom: 4rpx solid #333;
  63. transform: rotate(45deg);
  64. margin-left: 8rpx;
  65. }
  66. .erp-nav-title {
  67. flex: 1;
  68. text-align: center;
  69. font-size: 34rpx;
  70. font-weight: bold;
  71. color: #333333;
  72. }
  73. .erp-nav-right {
  74. width: 60rpx;
  75. height: 44px;
  76. display: flex;
  77. align-items: center;
  78. justify-content: flex-end;
  79. }
  80. </style>