cu-custom.vue 3.0 KB

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