index.vue 1.4 KB

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