use-header.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view>
  3. <view class="use-header dflex padding-lr w-full bg-main" :class="fixed ? 'fixed' : ''">
  4. <!-- 头部组件 -->
  5. <view class="use-search dflex-b border-radius-lg padding-lr w-full" @click="search">
  6. <view class="iconfont iconsousuo-01"><text class="text">{{ searchTip }}</text></view>
  7. </view>
  8. </view>
  9. <!-- 头部组件占位符 -->
  10. <view v-if="fixed && placeholder" class="use-header-placeholder"></view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. props: {
  16. fixed: {
  17. type: [Number, Boolean],
  18. default: false
  19. },
  20. placeholder: {
  21. type: [Number, Boolean],
  22. default: !0
  23. },
  24. searchAuto: {
  25. type: [Number, Boolean],
  26. default: !0
  27. },
  28. searchTip: {
  29. type: String,
  30. default: '搜索关键字'
  31. }
  32. },
  33. data() {
  34. return {};
  35. },
  36. methods: {
  37. search() {
  38. this.$emit('search', {
  39. type: 'search'
  40. });
  41. if (this.searchAuto) {
  42. // 跳转搜索页
  43. uni.navigateTo({
  44. url: '/packageShang/pages/home/search/search'
  45. })
  46. }
  47. }
  48. }
  49. };
  50. </script>
  51. <style lang="scss">
  52. .use-header-placeholder {
  53. height: 100rpx;
  54. }
  55. .use-header {
  56. // height: 100rpx;
  57. }
  58. .fixed {
  59. position: inherit;
  60. z-index: 1;
  61. }
  62. .bg-main {
  63. background: transparent!important;
  64. }
  65. .use-search {
  66. height: 72rpx;
  67. line-height: 72rpx;
  68. background-color: #f5f5f5;
  69. .text {
  70. font-size: 28rpx;
  71. color: rgba(204, 204, 204, 1);
  72. }
  73. .iconfont {
  74. font-size: $font-base + 6upx;
  75. color: rgba(153, 153, 153, 1);
  76. }
  77. }
  78. </style>