nav-bar.vue 3.3 KB

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