navbar-search.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <!-- 分类列表中的搜索 -->
  2. <template>
  3. <view class="slot">
  4. <view class="navbar" :style="[{ minHeight: navBarHeight + 'px' }]">
  5. <view
  6. class="inner"
  7. :style="[
  8. { minHeight: menuHeight + 'px' },
  9. { lineHeight: menuHeight + 'px' },
  10. { paddingLeft: menuRight * 2 + 'px' },
  11. { paddingRight: menuRight * 2 + 'px' },
  12. { paddingTop: navBarHeight - menuHeight - menuTop + 'px' },
  13. { paddingBottom: '20rpx' }
  14. ]"
  15. >
  16. <view class="title-slot">
  17. <u-icon size="32" name="arrow-leftward" @click="$u.route({ type: 'navigateBack', delta: 1 })"></u-icon>
  18. <view class="title shu-elip-1">{{ title }}</view>
  19. <view></view>
  20. </view>
  21. <view class="search-slot" :style="{ paddingTop: menuTop + 'px' }">
  22. <u-search @click="goSearchPage" disabled :placeholder="placeholder" :showAction="false" bg-color="#F4F5F8"></u-search>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="slot-height" :style="[{ height: navBarHeight + menuHeight + menuTop + 11 + 'px' }]"></view>
  27. </view>
  28. </template>
  29. <script>
  30. const app = getApp();
  31. export default {
  32. name: 'navbar-search',
  33. props: {
  34. // 标题
  35. title: {
  36. type: String,
  37. default: '标题'
  38. },
  39. // 占位内容
  40. placeholder: {
  41. type: String,
  42. default: '请输入'
  43. }
  44. },
  45. data() {
  46. return {
  47. // 导航栏高度
  48. menuTop: app.globalData.menuTop,
  49. navBarHeight: app.globalData.navBarHeight,
  50. menuRight: app.globalData.menuRight,
  51. menuBotton: app.globalData.menuBotton,
  52. menuHeight: app.globalData.menuHeight,
  53. statusBarHeight: app.globalData.statusBarHeight
  54. };
  55. },
  56. methods: {
  57. // 去搜索页面
  58. goSearchPage() {
  59. uni.navigateTo({
  60. url: '/pages/search'
  61. });
  62. }
  63. }
  64. };
  65. </script>
  66. <style lang="scss" scoped>
  67. .slot {
  68. width: 100vw;
  69. }
  70. .navbar {
  71. width: 100%;
  72. position: fixed;
  73. top: 0;
  74. left: 0;
  75. z-index: 899;
  76. overflow: hidden;
  77. }
  78. .inner {
  79. width: 100%;
  80. height: 100%;
  81. background-color: $app-theme-bg-color;
  82. }
  83. .title-slot {
  84. display: flex;
  85. justify-content: space-between;
  86. align-items: center;
  87. .back {
  88. }
  89. .title {
  90. font-size: 36rpx;
  91. font-family: PingFangSC-Regular, PingFang SC;
  92. color: $app-theme-text-black-color;
  93. max-width: 350rpx;
  94. }
  95. }
  96. .search-slot {
  97. }
  98. </style>