index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <!-- 搜索框 -->
  3. <view class="diy-search" :class="{ sticky: params.sticky }"
  4. :style="{ background: itemStyle.background, padding: `${itemStyle.paddingY * 2}rpx ${itemStyle.paddingX * 2}rpx` }">
  5. <view class="inner" :class="itemStyle.searchStyle" @click="onTargetSearch">
  6. <view class="search-input"
  7. :style="{ textAlign: itemStyle.textAlign, background: itemStyle.searchBg, color: itemStyle.searchFontColor }">
  8. <text class="search-icon iconfont icon-search"></text>
  9. <text> {{ params.placeholder }}</text>
  10. </view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. /**
  17. * 组件的属性列表
  18. * 用于组件自定义设置
  19. */
  20. props: {
  21. itemIndex: String,
  22. itemStyle: Object,
  23. params: Object
  24. },
  25. /**
  26. * 组件的方法列表
  27. * 更新属性和数据的方法与更新页面数据的方法类似
  28. */
  29. methods: {
  30. /**
  31. * 跳转到搜索页面
  32. */
  33. onTargetSearch() {
  34. this.$navTo('pages/search/index')
  35. }
  36. }
  37. }
  38. </script>
  39. <style lang="scss" scoped>
  40. .diy-search {
  41. background: #f1f1f2;
  42. padding: 20rpx 20rpx;
  43. &.sticky {
  44. position: sticky;
  45. top: var(--window-top);
  46. z-index: 100;
  47. }
  48. }
  49. .inner {
  50. height: 60rpx;
  51. background: #fff;
  52. overflow: hidden;
  53. &.radius {
  54. border-radius: 10rpx;
  55. }
  56. &.round {
  57. border-radius: 60rpx;
  58. }
  59. .search-input {
  60. height: 60rpx;
  61. //width: 100%;
  62. line-height: 60rpx;
  63. color: #999999;
  64. padding: 0 24rpx;
  65. font-size: 26rpx;
  66. .search-icon {
  67. margin-right: 12rpx;
  68. }
  69. }
  70. }
  71. </style>