nav-bar.vue 3.5 KB

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