au-custom.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template name="headerNavbar">
  2. <!-- 自定义导航栏 -->
  3. <view class='navbar-wrap' :style="{height:CustomBar+'px',paddingTop:StatusBar+'px'}">
  4. <view class="navbar-text"
  5. :style="{color:navbarData.textColor ? navbarData.textColor:'',lineHeight:(CustomBar - StatusBar)+'px;',fontSize:fontSizeSetting+'px;',paddingLeft:navbarData.textLeft ? '' : (capsule.height+10)+'px'}" :class="platformClass">
  6. {{navbarData.title ? navbarData.title : " "}}
  7. </view>
  8. <view class="navbar-icon" v-if="navbarData.showCapsule == 1 ? true : false"
  9. :style="{color:navbarData.textColor ? navbarData.textColor:'',top:capsule.top +'px;',left:((screenWidth-capsule.right)+5)+'px;',height:capsule.height+'px;',lineHeight:capsule.height+'px;'}">
  10. <text v-if="navbarData.haveBack" @tap="BackPage" class="iconfont icon-fanhui"></text>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. var self;
  16. export default{
  17. name:'headerNavbar',
  18. props:{
  19. navbarData: { // 由父页面传递的数据
  20. type: Object
  21. }
  22. },
  23. data() {
  24. return{
  25. CustomBar:this.CustomBar,// 顶部导航栏高度
  26. StatusBar: this.StatusBar,
  27. fontSizeSetting:this.fontSizeSetting,
  28. screenWidth:this.screenWidth,
  29. capsule:this.capsule,
  30. platformClass:this.platformClass,
  31. }
  32. },
  33. created() {
  34. if (getCurrentPages().length === 1) { // 当只有一个页面时
  35. this.navbarData.haveBack = false;
  36. } else {
  37. this.navbarData.haveBack = true;
  38. }
  39. },
  40. onLoad(){
  41. },
  42. methods:{
  43. BackPage: function () {
  44. this.$emit('navigateBack')
  45. },
  46. _goSearchPath:function () {
  47. this.$emit('goSearchPath')
  48. },
  49. _goHome:function(){
  50. uni.switchTab({
  51. url: '/pages/tabBar/index/index'
  52. })
  53. }
  54. },
  55. onShow(){
  56. }
  57. }
  58. </script>
  59. <style lang="scss">
  60. .navbar-wrap {
  61. position: fixed;
  62. width: 100%;
  63. top: 0;
  64. z-index: 100000;
  65. box-sizing: border-box;
  66. }
  67. .navbar-text {
  68. font-size: 30rpx;
  69. color: #000000;
  70. font-weight: 500;
  71. }
  72. .navbar-text.center{
  73. text-align: center;
  74. }
  75. .navbar-text.left{
  76. text-align: left;
  77. padding-left: 45px;
  78. }
  79. .navbar-icon {
  80. position: fixed;
  81. display: flex;
  82. box-sizing: border-box;
  83. }
  84. .navbar-icon .iconfont {
  85. display: inline-block;
  86. overflow: hidden;
  87. font-size: 44rpx;
  88. padding-right:40rpx;
  89. margin-top: 1px;
  90. }
  91. .navbar-icon .icon-sousuo {
  92. color: #000000;
  93. }
  94. .navbar-icon view {
  95. height: 18px;
  96. border-left: 0.5px solid rgba(0,0,0, 0.3);
  97. margin-top: 6px;
  98. }
  99. .navbar-loading {
  100. background: #fff;
  101. text-align: center;
  102. }
  103. </style>