SearchBar.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view class="search-bar" :style="{ background:`url(${bgColor})`}">
  3. <view class="status_bar" :style="{ height: statusBarHeight}"></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 }" @tap.stop="goPage">
  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: String, default: ''},
  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. methods:{
  55. goPage(){
  56. uni.navigateTo({ url: '/pages_mall/productList' })
  57. }
  58. }
  59. };
  60. </script>
  61. <style lang="stylus">
  62. .placeholder{
  63. color: rgba(0,0,0,0.25) !important;
  64. }
  65. </style>
  66. <style lang="scss" scoped>
  67. .search-bar {
  68. position: fixed;
  69. top: 0;
  70. left: 0;
  71. right: 0;
  72. z-index: 10000;
  73. background-size: 100% !important;
  74. }
  75. .top-title .name {
  76. font-size: 36rpx;
  77. font-weight: bold;
  78. color: #fff;
  79. padding: 20rpx 0;
  80. }
  81. .func-cont {
  82. display: flex;
  83. align-items: center;
  84. padding: 0 24rpx 24rpx;
  85. }
  86. .search-cont {
  87. display: flex;
  88. align-items: center;
  89. height: 64rpx;
  90. background: rgba(255,255,255,0.5);
  91. border-radius: 38rpx;
  92. // padding: 0 24rpx;
  93. // flex: 1;
  94. // margin-right: 20rpx;
  95. }
  96. .icon-search {
  97. width: 44rpx;
  98. height: 44rpx;
  99. margin-right: 16rpx;
  100. }
  101. .search-cont input {
  102. flex: 1;
  103. pointer-events: none;
  104. font-family: PingFangSC, PingFang SC;
  105. font-weight: 400;
  106. font-size: 32rpx;
  107. color: rgba(0,0,0,0.25);
  108. line-height: 44rpx;
  109. }
  110. .img-item {
  111. width: 48rpx;
  112. height: 48rpx;
  113. margin-left: 24rpx;
  114. }
  115. .img-item image {
  116. width: 100%;
  117. height: 100%;
  118. }
  119. .contact-btn {
  120. position: absolute;
  121. top: 0;
  122. left: 0;
  123. width: 100%;
  124. height: 100%;
  125. opacity: 0;
  126. }
  127. </style>