nav-bar.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="cu-custom" :style="[{ height: CustomBar + 'px' }]">
  3. <view class="cu-bar fixed" :style="style" :class="[bgImage != '' ? 'none-bg text-white bg-img' : '', bgColor]">
  4. <view class="action" v-if="isBack">
  5. <text class="cuIcon-back cu-back text-white" @tap="BackPage" v-if="showBackIcon"></text>
  6. <slot name="backText"></slot>
  7. </view>
  8. <view class="content text-white" :style="[{ top: StatusBar + 'px' }]">
  9. <text>个人中心</text>
  10. </view>
  11. <view style="margin-left: auto;margin-right: 15rpx;color: #fff;font-size: 14px;font-weight: 500;">
  12. <slot name="right"></slot>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. StatusBar: this.StatusBar,
  22. CustomBar: this.CustomBar
  23. };
  24. },
  25. name: 'cu-custom',
  26. computed: {
  27. style() {
  28. var StatusBar = this.StatusBar;
  29. var CustomBar = this.CustomBar;
  30. var bgImage = this.bgImage;
  31. var style = `height:${CustomBar}px;padding-top:${StatusBar}px;background-color: rgba(255,255,255,${this.navOpacity}) `;
  32. if (this.bgImage) {
  33. style = `${style}background-image:url(${bgImage});`;
  34. }
  35. return style;
  36. }
  37. },
  38. props: {
  39. bgColor: {
  40. type: String,
  41. default: ''
  42. },
  43. linear: {
  44. type: Boolean,
  45. default: false
  46. },
  47. isBack: {
  48. type: [Boolean, String],
  49. default: false
  50. },
  51. showBackIcon: {
  52. type: Boolean,
  53. default: true
  54. },
  55. bgImage: {
  56. type: String,
  57. default: ''
  58. },
  59. navOpacity: {
  60. type: Number,
  61. default: 0
  62. }
  63. },
  64. methods: {
  65. BackPage() {
  66. uni.navigateBack({
  67. delta: 1
  68. });
  69. }
  70. }
  71. };
  72. </script>
  73. <style lang="scss" scoped>
  74. .liner-height{
  75. height: 20vh;
  76. }
  77. .text-white{
  78. color: #212121;
  79. font-size: 30rpx !important;
  80. font-family: PingFang SC;
  81. font-weight: bold;
  82. }
  83. .cu-custom .content{
  84. padding-left: 49rpx;
  85. left: 0;
  86. text-align: left;
  87. margin-right: auto;
  88. margin-left: 0;
  89. font-weight: unset;
  90. }
  91. </style>