nav-bar.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <uni-nav-bar :class="{'custom_uni_nav_bar':!onlyTitle,'custom_navbar_only_title':onlyTitle}" :height="`${height}rpx`" :backgroundColor="backgroundColor" :title="title" color="#333333" :fixed="true" :border="showHeaderborder" :statusBar="true" :leftWidth="leftWidth" :rightWidth="rightWidth" left-icon="left" @clickLeft="GoBack()">
  3. <view class="nav_head" v-if="!onlyTitle">
  4. <text class="nav_title">{{title}}</text>
  5. <view class="search_box">
  6. <image src="/static/image/overview/search.png" class="search_icon" ></image>
  7. <input type="text" class="search_input" placeholder="请输入关键字搜索" placeholder-class="search_placeholder" v-model="searchWord" @input="handleSearchInput" />
  8. </view>
  9. </view>
  10. <!-- 条件选择器 -->
  11. <view class="filter_picker">
  12. <!-- 通知类型筛选 -->
  13. <picker mode="selector" v-for="(item,index) in filterPickerData" :key="index" :range="item" :value="state.pickerIndex" @change="handleTypeChange" style="width: calc((100% - 32rpx * 2) / 3);">
  14. <view class="filter_item">
  15. <text class="filter_text">{{ item[state.pickerIndex] }}</text>
  16. <uni-icons type="down" size="16" color="#999999"></uni-icons>
  17. </view>
  18. </picker>
  19. </view>
  20. <!-- tabs -->
  21. <scroll-view class="scroll_tabs" scroll-x="true" scroll-left="0" :show-scrollbar="false">
  22. <view :class="['tab_item',{'selected':item.sortType==state.tabsSelected}]" v-for="item in tabList" :key="item.sortType" @click="SelectMenu(item.sortType)">
  23. {{item.name}}
  24. </view>
  25. </scroll-view>
  26. </uni-nav-bar>
  27. </template>
  28. <script setup>
  29. import uniNavBar from '@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue';
  30. import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue';
  31. import { reactive } from 'vue';
  32. const emit = defineEmits(['GoBack']);
  33. const props = defineProps({
  34. height: {//高度
  35. type: String,
  36. default: () => ''
  37. },
  38. leftWidth: {//导航栏左侧插槽宽度
  39. type: String,
  40. default: () => '96rpx'
  41. },
  42. rightWidth: {//导航栏右侧插槽宽度
  43. type: String,
  44. default: () => '96rpx'
  45. },
  46. title: {//标题
  47. type: String,
  48. default: () => ''
  49. },
  50. showHeaderborder:{//是否显示边框 默认不显示
  51. type:Boolean,
  52. default:false
  53. },
  54. backgroundColor: {//背景色
  55. type: String,
  56. default: () => '#FFFFFF'
  57. },
  58. backPath: {//返回路径
  59. type: String,
  60. default: () => ''
  61. },
  62. onlyTitle:{//是否只显示标题
  63. type:Boolean,
  64. default:true
  65. },
  66. filterPickerData:{//条件选择器
  67. type:Array,
  68. default:()=>[]
  69. },
  70. tabList:{//tabs
  71. type:Array,
  72. default:()=>[]
  73. }
  74. });
  75. const state = reactive({
  76. pickerIndex:0,
  77. tabsSelected:'1'
  78. })
  79. const GoBack = () => {
  80. if (props.backPath == 'myIndex') {
  81. uni.switchTab({
  82. url: '/pages/my/index'
  83. });
  84. }else if(props.backPath == 'workspace') {//跳转工作台
  85. uni.switchTab({
  86. url: '/pages/workspace/index'
  87. });
  88. } else {
  89. emit('GoBack');
  90. }
  91. }
  92. </script>
  93. <style scoped lang="scss">
  94. :deep(.uni-navbar__header) {
  95. padding: 0;
  96. position: relative;
  97. z-index: 999;
  98. }
  99. :deep(.uni-navbar__header-container) {
  100. padding: 0;
  101. }
  102. </style>