navbar-top-search.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="slot">
  3. <view class="searchbox">
  4. <u-search
  5. class="search-components"
  6. @click="goSearchPage(url)"
  7. disabled
  8. height="70"
  9. :placeholder="placeholder"
  10. :showAction="false"
  11. :bg-color="searchBgColor"
  12. :class="showSlot ? 'active' : ''"
  13. ></u-search>
  14. <slot showSlot></slot>
  15. </view>
  16. <view class="siteBar"></view>
  17. </view>
  18. </template>
  19. <script>
  20. const app = getApp();
  21. export default {
  22. name: 'navbar-tab-search',
  23. props: {
  24. pageTitle:{
  25. type: String,
  26. default: '书嗨',
  27. },
  28. // 占位内容
  29. placeholder: {
  30. type: String,
  31. default: '请输入'
  32. },
  33. // 是否显示插槽,用于输入框右侧内容的显示
  34. showSlot: {
  35. type: Boolean,
  36. default: false
  37. },
  38. // 跳转的url
  39. url: {
  40. type: String,
  41. default: ''
  42. },
  43. // 是否显示返回按钮
  44. showBack: {
  45. type: Boolean,
  46. default: false
  47. }
  48. },
  49. data() {
  50. return {
  51. // 导航栏高度
  52. navBarHeight: app.globalData.navBarHeight,
  53. statusBarHeight: app.globalData.statusBarHeight,
  54. menuRight: app.globalData.menuRight,
  55. menuBotton: app.globalData.menuBotton,
  56. menuHeight: app.globalData.menuHeight,
  57. menuTop: app.globalData.menuTop,
  58. // 当前tab
  59. current: 0,
  60. // 背景色
  61. searchBgColor: this.$appTheme.appThemeSearchBgColor
  62. };
  63. },
  64. methods: {
  65. // 切换tab
  66. change(index) {
  67. this.current = index;
  68. this.$emit('change', index);
  69. },
  70. // 去搜索页面
  71. goSearchPage(url) {
  72. uni.navigateTo({
  73. url
  74. });
  75. }
  76. }
  77. };
  78. </script>
  79. <style lang="scss" scoped>
  80. .siteBar {
  81. height: 90rpx;
  82. }
  83. .slot-inner {
  84. width: 100%;
  85. position: fixed;
  86. top: 0;
  87. left: 0;
  88. z-index: 899;
  89. overflow: hidden;
  90. background-color: #fff;
  91. }
  92. /* .tabList {
  93. display: flex;
  94. align-items: center;
  95. .tab {
  96. font-size: 36rpx;
  97. font-weight: 400;
  98. margin-right: 48rpx;
  99. color: $app-theme-navbar-tab-color;
  100. &.active {
  101. font-weight: 500;
  102. color: $app-theme-navbar-tab-color-active;
  103. font-size: 40rpx;
  104. position: relative;
  105. &::before {
  106. content: '';
  107. width: 16rpx;
  108. height: 6rpx;
  109. background: $app-theme-navbar-tab-color-active;
  110. border-radius: 1px;
  111. position: absolute;
  112. bottom: -10rpx;
  113. left: 50%;
  114. transform: translate(-50%, 0);
  115. }
  116. }
  117. }
  118. }
  119. */
  120. .inner {
  121. width: 100%;
  122. position: relative;
  123. height: 100%;
  124. background-color: $app-theme-bg-color;
  125. .left {
  126. position: absolute;
  127. z-index: 999;
  128. display: flex;
  129. align-items: center;
  130. // 防误触
  131. width: 30x;
  132. margin-right: 10px;
  133. }
  134. /* .tabList {
  135. width: 50%;
  136. position: absolute;
  137. z-index: 999;
  138. display: flex;
  139. align-items: center;
  140. } */
  141. }
  142. .inner-showSearch {
  143. width: 100%;
  144. height: 100%;
  145. background-color: $app-theme-bg-color;
  146. .tabList {
  147. display: flex;
  148. align-items: center;
  149. }
  150. }
  151. .searchbox {
  152. width: 100%;
  153. padding: 0 30rpx 20rpx;
  154. box-sizing: border-box;
  155. display: flex;
  156. justify-content: space-between;
  157. align-items: center;
  158. position: fixed;
  159. top: 0;
  160. left: 0;
  161. z-index: 899;
  162. overflow: hidden;
  163. background-color: #fff;
  164. .search-components {
  165. width: 100%;
  166. &.active {
  167. // width: 86%;
  168. margin-right: 30rpx;
  169. }
  170. }
  171. }
  172. </style>