SearchBar.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view class="search-bar" :style="{ background:`url(${bgColor})` }">
  3. <view class="status_bar" :style="{ height: statusBarHeight + 'px' }"></view>
  4. <!-- <view class="top-title">
  5. <view class="name">{{ title }}</view>
  6. </view> -->
  7. <view class="func-cont" :style="{marginTop: marginTop}">
  8. <view class="search-cont" :style="{ width: searchWidth }" @click="$emit('searchClick')">
  9. <image class="icon-search" :src="searchIcon" mode=""></image>
  10. <input type="text" :value="keyword" :placeholder="placeholder" placeholder-class="placeholder"
  11. disabled />
  12. </view>
  13. <!-- <uni-badge size="small" :text="cartCount" absolute="rightTop" type="error" v-show="cartCount > 0">
  14. <view class="img-item" @click="$emit('cartClick')">
  15. <image :src="cartIcon" mode=""></image>
  16. </view>
  17. </uni-badge>
  18. <view class="img-item" v-show="cartCount <= 0" @click="$emit('cartClick')">
  19. <image :src="cartIcon" mode=""></image>
  20. </view>
  21. <view class="img-item" style="position: relative;">
  22. <image :src="serviceIcon" mode=""></image>
  23. <button class="contact-btn" open-type="contact"></button>
  24. </view> -->
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. name: 'SearchBar',
  31. props: {
  32. title: { type: String, default: '岚财良品' },
  33. keyword: { type: String, default: '' },
  34. placeholder: { type: String, default: '请输入产品名称' },
  35. bgColor: { type: String, default: 'rgba(43,199,185, 0)' },
  36. statusBarHeight: { type: Number, default: 20 },
  37. cartCount: { type: Number, default: 0 },
  38. searchWidth: { type: String, default: '' },
  39. marginTop:{ type: String, default: '' },
  40. searchIcon: {
  41. type: String,
  42. // default: 'https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/search.png',
  43. default: '/static/images/search.png'
  44. },
  45. cartIcon: {
  46. type: String,
  47. default: 'https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/cart_wihte.png'
  48. },
  49. serviceIcon: {
  50. type: String,
  51. default: 'https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/customer.png'
  52. }
  53. }
  54. };
  55. </script>
  56. <style lang="stylus">
  57. .placeholder{
  58. color: rgba(0,0,0,0.25) !important;
  59. }
  60. </style>
  61. <style lang="scss" scoped>
  62. .search-bar {
  63. position: fixed;
  64. top: 0;
  65. left: 0;
  66. right: 0;
  67. z-index: 10000;
  68. }
  69. .top-title .name {
  70. font-size: 36rpx;
  71. font-weight: bold;
  72. color: #fff;
  73. padding: 20rpx 0;
  74. }
  75. .func-cont {
  76. display: flex;
  77. align-items: center;
  78. padding: 0 24rpx 20rpx;
  79. }
  80. .search-cont {
  81. display: flex;
  82. align-items: center;
  83. height: 64rpx;
  84. background: rgba(255,255,255,0.5);
  85. border-radius: 38rpx;
  86. padding: 0 24rpx;
  87. // flex: 1;
  88. margin-right: 20rpx;
  89. }
  90. .icon-search {
  91. width: 44rpx;
  92. height: 44rpx;
  93. margin-right: 16rpx;
  94. }
  95. .search-cont input {
  96. flex: 1;
  97. font-family: PingFangSC, PingFang SC;
  98. font-weight: 400;
  99. font-size: 32rpx;
  100. color: rgba(0,0,0,0.25);
  101. line-height: 44rpx;
  102. }
  103. .img-item {
  104. width: 48rpx;
  105. height: 48rpx;
  106. margin-left: 24rpx;
  107. }
  108. .img-item image {
  109. width: 100%;
  110. height: 100%;
  111. }
  112. .contact-btn {
  113. position: absolute;
  114. top: 0;
  115. left: 0;
  116. width: 100%;
  117. height: 100%;
  118. opacity: 0;
  119. }
  120. </style>