navbar-tab-search.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="navbar" :style="[{ minHeight: navBarHeight + 'px' }]">
  3. <view class="searchTabhead">
  4. <Navbar :title="title"></Navbar>
  5. <view class="searchbox" v-if="isSearch">
  6. <u-search :placeholder="placeholder" :showAction="false" bg-color="#F4F5F8"></u-search>
  7. </view>
  8. <!-- <view class="tab-slot" :style="{'height':navBarHeight+'px'}">
  9. <view class="tab" v-for="(tab, index) in tabOps" :key="index" :class="{ active: tabIndex == index }" @click="change(tab, index)">{{ tab.label }}</view>
  10. </view> -->
  11. <view class="tab-slot" >
  12. <u-tabs :is-scroll="true" :list="tabOps" :current="tabIndex" @change="change"></u-tabs>
  13. </view>
  14. </view>
  15. <view v-if="isSearch" class="siteBar" :style="[{ height: navBarHeight*2 + menuHeight+statusBarHeight+ 'px' }]"></view>
  16. <view class="siteBar" v-else :style="[{ height: navBarHeight + menuHeight+statusBarHeight+ 'px' }]"></view>
  17. </view>
  18. </template>
  19. <script>
  20. const app = getApp();
  21. export default {
  22. name: 'navbar-tab-search',
  23. props: {
  24. // 标题
  25. title: {
  26. type: String,
  27. default: '标题'
  28. },
  29. // 占位内容
  30. placeholder: {
  31. type: String,
  32. default: '请输入'
  33. },
  34. // 标题
  35. isSearch: {
  36. type: Boolean,
  37. default: false
  38. },
  39. // tab配置项
  40. tabOps: {
  41. type: Array,
  42. default: () => {
  43. return [];
  44. }
  45. }
  46. },
  47. data() {
  48. return {
  49. // 导航栏高度
  50. menuTop: app.globalData.menuTop,
  51. navBarHeight: app.globalData.navBarHeight,
  52. menuRight: app.globalData.menuRight,
  53. menuBotton: app.globalData.menuBotton,
  54. menuHeight: app.globalData.menuHeight,
  55. statusBarHeight: app.globalData.statusBarHeight,
  56. // 当前tab
  57. tabIndex: 0
  58. };
  59. },
  60. methods: {
  61. // 切换tab
  62. change(index) {
  63. console.log(index);
  64. this.tabIndex = index;
  65. this.$emit('change', index);
  66. },
  67. }
  68. };
  69. </script>
  70. <style lang="scss" scoped>
  71. .navbar {
  72. width: 100vw;
  73. overflow: hidden;
  74. }
  75. .searchTabhead {
  76. position: fixed;
  77. top: 0;
  78. left: 0;
  79. z-index: 899;
  80. width: 100%;
  81. background-color: $app-theme-bg-color;
  82. }
  83. .searchbox{
  84. width: 100%;
  85. height: 100%;
  86. padding: 0 30rpx;
  87. box-sizing: border-box;
  88. background-color: $app-theme-bg-color;
  89. }
  90. .tab-slot {
  91. width: 100%;
  92. display: flex;
  93. align-items: center;
  94. justify-content: space-between;
  95. // padding: 0 30rpx;
  96. box-sizing: border-box;
  97. // padding-top: 20rpx;
  98. .tab {
  99. font-size: 26rpx;
  100. font-weight: 400;
  101. color: $app-theme-navbar-tab-color;
  102. &.active {
  103. color: $app-theme-navbar-tab-color-active;
  104. position: relative;
  105. &::before {
  106. content: '';
  107. position: absolute;
  108. bottom: 0;
  109. left: 50%;
  110. transform: translate(-50%, -50%);
  111. width: 20rpx;
  112. height: 4rpx;
  113. background: $app-theme-navbar-tab-color-active;
  114. border-radius: 2rpx;
  115. }
  116. }
  117. }
  118. }
  119. </style>