cm-custom.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template name="headerNavbar">
  2. <!-- 自定义导航栏 -->
  3. <view class='navbar-wrap' :style="{height:(CustomBar+55)+'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+'px'}" :class="platformClass">
  6. {{navbarData.title ? navbarData.title : " "}}
  7. </view>
  8. <view class="search-input">
  9. <view class="gosearch-btn" @click="this.$api.navigateTo(clickPath)">
  10. <text class="iconfont icon-iconfonticonfontsousuo1"></text>
  11. <text>{{hotSearchText}}</text>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. var self;
  18. import btSearch from '@/components/uni-search/bt-search.vue'
  19. export default{
  20. name:'headerNavbar',
  21. components:{
  22. btSearch,
  23. },
  24. props:{
  25. navbarData: { // 由父页面传递的数据
  26. type: Object
  27. }
  28. },
  29. data() {
  30. return{
  31. clickPath:'/pages/search/search',
  32. hotSearchText:'你想要的这里都有',
  33. CustomBar:this.CustomBar,// 顶部导航栏高度
  34. StatusBar: this.StatusBar,
  35. fontSizeSetting:this.fontSizeSetting,
  36. screenWidth:this.screenWidth,
  37. capsule:this.capsule,
  38. platformClass:this.platformClass,
  39. }
  40. },
  41. created() {
  42. if (getCurrentPages().length === 1) { // 当只有一个页面时
  43. this.navbarData.haveBack = false;
  44. } else {
  45. this.navbarData.haveBack = true;
  46. }
  47. },
  48. onLoad(){
  49. },
  50. methods:{
  51. BackPage: function () {
  52. this.$emit('navigateBack')
  53. },
  54. _goSearchPath:function () {
  55. this.$emit('goSearchPath')
  56. },
  57. _goHome:function(){
  58. uni.switchTab({
  59. url: '/pages/tabBar/home/home'
  60. })
  61. }
  62. },
  63. onShow(){
  64. }
  65. }
  66. </script>
  67. <style lang="scss">
  68. .navbar-wrap {
  69. position: fixed;
  70. width: 100%;
  71. top: 0;
  72. z-index: 100000;
  73. box-sizing: border-box;
  74. background: url(https://admin-b.caimei365.com/userfiles/1/images/photo/2020/05/%E8%83%8C%E6%99%AF1%402x.png);
  75. background-size: cover;
  76. }
  77. .navbar-text {
  78. font-size: 30rpx;
  79. color: #000000;
  80. font-weight: 500;
  81. }
  82. .navbar-text.center{
  83. text-align: center;
  84. }
  85. .navbar-text.left{
  86. text-align: left;
  87. padding-left: 45px;
  88. }
  89. .navbar-icon {
  90. position: fixed;
  91. display: flex;
  92. box-sizing: border-box;
  93. }
  94. .navbar-icon .iconfont {
  95. display: inline-block;
  96. overflow: hidden;
  97. font-size: 44rpx;
  98. padding-right:40rpx;
  99. margin-top: 1px;
  100. }
  101. .navbar-icon .icon-iconfonticonfontsousuo1 {
  102. color: #000000;
  103. }
  104. .navbar-icon view {
  105. height: 18px;
  106. border-left: 0.5px solid rgba(0,0,0, 0.3);
  107. margin-top: 6px;
  108. }
  109. .navbar-loading {
  110. background: #fff;
  111. text-align: center;
  112. }
  113. .search-input{
  114. width: 100%;
  115. height: 70rpx;
  116. padding: 20rpx 0;
  117. .gosearch-btn{
  118. /* #ifndef APP-NVUE */
  119. display: flex;
  120. /* #endif */
  121. flex: 1;
  122. flex-direction: row;
  123. justify-content: center;
  124. align-items: center;
  125. width: 662rpx;
  126. height: 100%;
  127. border-radius: 40rpx;
  128. background: #F0F0F0;
  129. margin: 0 auto;
  130. padding:0 20rpx;
  131. font-size: 28rpx;
  132. line-height: 70rpx;
  133. color: #8A8A8A;
  134. background: #FFFFFF;
  135. .icon-iconfonticonfontsousuo1{
  136. margin:0 6rpx;
  137. font-size: 34rpx;
  138. color: #8A8A8A;
  139. z-index: 10;
  140. }
  141. }
  142. }
  143. </style>