You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

115 lines
2.6 KiB

  1. <template>
  2. <view
  3. v-if="type === 'default'"
  4. :class="[hexColor ? '' : 'bg-' + color, fixed ? 'banner-fixed' : '']"
  5. :style="{
  6. backgroundColor: hexColor,
  7. boxShadow: noshadow ? 'none' : '0 1rpx 6rpx rgba(0, 0, 0, 0.1)'
  8. }"
  9. class="cu-bar cu-banner"
  10. >
  11. <view @click="clickLeft" class="action"><slot name="left"></slot></view>
  12. <view @click="clickCenter" class="content">
  13. <slot>{{ title }}</slot>
  14. </view>
  15. <view @click="clickRight" class="action"><slot name="right"></slot></view>
  16. </view>
  17. <view
  18. v-else-if="type === 'search'"
  19. :class="[hexColor ? '' : 'bg-' + color, fixed ? 'banner-fixed' : '']"
  20. :style="{
  21. backgroundColor: hexColor,
  22. boxShadow: noshadow ? 'none' : '0 1rpx 6rpx rgba(0, 0, 0, 0.1)'
  23. }"
  24. class="cu-bar search cu-banner"
  25. >
  26. <slot name="left"></slot>
  27. <view class="search-form" :class="[fill ? 'radius' : 'round']" :style="inputStyle">
  28. <slot name="searchInput">
  29. <text class="cuIcon-search"></text>
  30. <input
  31. @input="searchTextChange"
  32. @focus="$emit('inputFocus', $event)"
  33. :placeholder-style="placeholderStyle"
  34. :adjust-position="false"
  35. :placeholder="placeholder"
  36. :value="value"
  37. :focus="focus"
  38. confirm-type="search"
  39. type="text"
  40. ref="bannerInput"
  41. />
  42. </slot>
  43. </view>
  44. <view v-if="!noSearchButton" class="action">
  45. <slot name="searchButton">
  46. <template v-if="fill">
  47. <view @click="searchClick">搜索</view>
  48. </template>
  49. <button v-else @click="searchClick" class="cu-btn bg-green shadow-blur round">搜索</button>
  50. </slot>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. name: 'l-banner',
  57. props: {
  58. type: { default: 'default' },
  59. color: { default: 'white' },
  60. hexColor: {},
  61. inputStyle: {},
  62. fill: {},
  63. title: {},
  64. value: {},
  65. placeholder: { default: '搜索图片、文章、视频' },
  66. noSearchButton: {},
  67. placeholderStyle: {},
  68. fixed: {},
  69. noshadow: {},
  70. focus: {}
  71. },
  72. methods: {
  73. searchTextChange(e) {
  74. this.$emit('input', e.detail.value)
  75. this.$emit('change', e.detail.value)
  76. },
  77. clickLeft(e) {
  78. this.$emit('clickLeft', e)
  79. },
  80. clickRight(e) {
  81. this.$emit('clickRight', e)
  82. },
  83. clickCenter(e) {
  84. this.$emit('clickCenter', e)
  85. },
  86. searchClick(F) {
  87. this.$emit('searchClick')
  88. },
  89. inputFocus() {
  90. this.$refs.bannerInput.focus()
  91. }
  92. }
  93. }
  94. </script>
  95. <style scoped>
  96. .banner-fixed {
  97. position: fixed;
  98. width: 100%;
  99. top: var(--window-top);
  100. z-index: 1024;
  101. }
  102. </style>