Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

118 wiersze
2.7 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. @blur="blur"
  34. :placeholder-style="placeholderStyle"
  35. :adjust-position="false"
  36. :placeholder="placeholder"
  37. :value="value"
  38. :focus="focus"
  39. confirm-type="search"
  40. type="text"
  41. ref="bannerInput"
  42. />
  43. </slot>
  44. </view>
  45. <view v-if="!noSearchButton" class="action">
  46. <slot name="searchButton">
  47. <template v-if="fill">
  48. <view @click="searchClick">搜索</view>
  49. </template>
  50. <button v-else @click="searchClick" class="cu-btn bg-green shadow-blur round">搜索</button>
  51. </slot>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. export default {
  57. name: 'l-banner',
  58. props: {
  59. type: { default: 'default' },
  60. color: { default: 'white' },
  61. hexColor: {},
  62. inputStyle: {},
  63. fill: {},
  64. title: {},
  65. value: {},
  66. placeholder: { default: '搜索图片、文章、视频' },
  67. noSearchButton: {},
  68. placeholderStyle: {},
  69. fixed: {},
  70. noshadow: {},
  71. focus: {}
  72. },
  73. methods: {
  74. searchTextChange(e) {
  75. this.$emit('input', e.detail.value)
  76. this.$emit('change', e.detail.value)
  77. },
  78. blur(e){
  79. this.$emit('blur', e.detail.value)
  80. },
  81. clickLeft(e) {
  82. this.$emit('clickLeft', e)
  83. },
  84. clickRight(e) {
  85. this.$emit('clickRight', e)
  86. },
  87. clickCenter(e) {
  88. this.$emit('clickCenter', e)
  89. },
  90. searchClick(F) {
  91. this.$emit('searchClick')
  92. },
  93. inputFocus() {
  94. this.$refs.bannerInput.focus()
  95. }
  96. }
  97. }
  98. </script>
  99. <style scoped>
  100. .banner-fixed {
  101. position: fixed;
  102. width: 100%;
  103. top: var(--window-top);
  104. z-index: 1024;
  105. }
  106. </style>