rf-search-bar.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view class="rf-search-bar bg-rf" :class="'bg-' + themeColor.name">
  3. <view class="header"
  4. :style="{width:merchantShow ? '100vw' : width+'px', marginTop: merchantShow ? 0 : inputTop+'px'}">
  5. <text class="header-text">{{title}}</text>
  6. <!-- 搜索框 -->
  7. <view class="input-box" @tap="toSearch">
  8. <!-- <input disabled class="input" /> -->
  9. <view class="wrapper">
  10. <uni-icons class="searchIcon" type="search" color="#666666" size="16" />
  11. <text class="keyword">{{ placeholder }}</text>
  12. </view>
  13. </view>
  14. <view class="addr">
  15. <!-- <text class="fa fa-bell-o" aria-hidden="true" style="color:#fff;font-size: 38upx;" ></text> -->
  16. </view>
  17. </view>
  18. <scroll-view scroll-x class="index-cate" v-if="isOpenIndexCate && categoryList.length > 0">
  19. <view v-for="(item, index) in categoryList" :key="index" class="index-cate-item"
  20. :class="tabCurrentIndex === index ? `text-${themeColor.name} active` : ''"
  21. @tap.stop="tabClick(index, item.id)">
  22. {{ item.title }}
  23. </view>
  24. </scroll-view>
  25. </view>
  26. </template>
  27. <script>
  28. // #ifdef H5
  29. import jweixin from '@/common/jweixin';
  30. // #endif
  31. import {
  32. productVirtualVerificationVerify
  33. } from '@/api/userInfo';
  34. export default {
  35. props: {
  36. headerShow: {
  37. type: Boolean,
  38. default: true
  39. },
  40. merchantData: {
  41. type: Object,
  42. default () {
  43. return {};
  44. }
  45. },
  46. merchantShow: {
  47. type: Boolean,
  48. default: false
  49. },
  50. categoryList: {
  51. type: Array,
  52. default () {
  53. return [];
  54. }
  55. },
  56. inputDisabled: {
  57. type: Boolean,
  58. default: false
  59. },
  60. placeholder: {
  61. type: String,
  62. default: null
  63. },
  64. icon: {
  65. type: String,
  66. default: null
  67. },
  68. title: {
  69. type: String,
  70. default: null
  71. }
  72. },
  73. computed: {
  74. themeColor() {
  75. return getApp().themeColor;
  76. }
  77. },
  78. data() {
  79. return {
  80. // placeholder: getApp().$i18n.locale == 'zh'?'请输入关键字': 'Please keywords',
  81. CustomBar: this.CustomBar,
  82. searchValue: this.placeholder,
  83. appLogo: getApp().$mSettingConfig.appLogo,
  84. isOpenScan: getApp().$mSettingConfig.isOpenScan,
  85. isOpenIndexCate: getApp().$mSettingConfig.isOpenIndexCate,
  86. height: 0,
  87. width: 0,
  88. inputTop: 0,
  89. tabCurrentIndex: 0
  90. };
  91. },
  92. created() {
  93. let obj = {};
  94. // #ifdef MP-WEIXIN
  95. obj = wx.getMenuButtonBoundingClientRect();
  96. // #endif
  97. uni.getSystemInfo({
  98. success: (res) => {
  99. this.width = obj.left || res.windowWidth;
  100. this.height = obj.top ? (obj.top + obj.height + 8) : (res.statusBarHeight + 44);
  101. this.inputTop = obj.top ? (obj.top + (obj.height - 30) / 2) : (res.statusBarHeight + 7);
  102. }
  103. });
  104. },
  105. watch: {
  106. },
  107. methods: {
  108. tabClick(index, id) {
  109. this.tabCurrentIndex = index;
  110. this.$emit('tab', {
  111. id
  112. });
  113. },
  114. async toSearch() {
  115. await this.$emit('search', {
  116. searchValue: this.searchValue
  117. });
  118. }
  119. }
  120. };
  121. </script>
  122. <style scoped>
  123. .rf-search-bar {
  124. width: 750upx;
  125. background-image: linear-gradient(to left, #4BC0E2, #538BE7);
  126. }
  127. .header-text {
  128. color: #fff;
  129. font-size: 32upx;
  130. }
  131. .header {
  132. align-items: center;
  133. justify-content: center;
  134. z-index: 12;
  135. padding-bottom: 10upx;
  136. flex-direction: row;
  137. padding-left: 30upx;
  138. }
  139. .bg {
  140. position: absolute;
  141. left: 0;
  142. top: 0;
  143. width: 100vw;
  144. height: 60vw;
  145. opacity: 0.9;
  146. }
  147. .merchant {
  148. line-height: 1;
  149. width: 100%;
  150. align-items: center;
  151. z-index: 12;
  152. font-weight: 500;
  153. font-size: 32upx;
  154. padding: 10upx 30upx 14upx;
  155. }
  156. .iconshouhuodizhi {
  157. font-size: 40upx;
  158. font-weight: 600;
  159. margin-right: 10upx;
  160. }
  161. .iconxiajiantou1 {
  162. margin-left: 4upx;
  163. font-size: 28upx;
  164. }
  165. .addr {
  166. margin: 0 20upx;
  167. height: 60upx;
  168. line-height: 60upx;
  169. padding-top: 16upx;
  170. }
  171. .iconfont {
  172. font-weight: 500;
  173. font-size: 56upx;
  174. }
  175. .logo {
  176. width: 45upx;
  177. height: 45upx;
  178. border-radius: 8upx;
  179. margin-left: 10upx;
  180. }
  181. .input-box {
  182. flex: 1;
  183. height: 60upx;
  184. line-height: 60upx;
  185. background-color: #fff;
  186. border-radius: 30upx;
  187. position: relative;
  188. align-items: center;
  189. margin: 6upx 0 0 20upx;
  190. }
  191. .input {
  192. flex: 1;
  193. padding-left: 28upx;
  194. height: 28upx;
  195. color: #888;
  196. font-size: 28upx;
  197. }
  198. .wrapper {
  199. flex: 1;
  200. align-items: center;
  201. font-size: 26upx;
  202. color: #909399;
  203. flex-direction: row;
  204. }
  205. .iconsousuo2 {
  206. font-size: 34upx;
  207. margin-right: 20upx;
  208. }
  209. .searchIcon {
  210. color: #999999;
  211. }
  212. .keyword {
  213. color: #999999;
  214. font-size: 26upx;
  215. margin-left: 20upx;
  216. }
  217. </style>