headerSerch.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <!-- #ifdef H5 -->
  3. <view class="header" :style="'background: '+ bgColor +' ;margin-top:'+ mbConfig +'rpx;'">
  4. <view class="serch-wrapper flex acea-row row-between-wrapper">
  5. <view v-if="logoConfig" class="logo skeleton-rect">
  6. <image :src="logoConfig" mode=""></image>
  7. </view>
  8. <navigator :url="merId ? '/pages/store/list/index?mer_id='+merId : '/pages/columnGoods/goods_search/index'" :class="logoConfig ? 'input' : 'uninput'" class="skeleton-rect" hover-class="none"
  9. :style="'border-radius:'+boxStyle+'rpx;text-align:'+txtStyle">
  10. <text class="iconfont icon-xiazai5"></text>
  11. 搜索商品
  12. </navigator>
  13. <navigator class="btn skeleton-rect" url="/pages/chat/customer_list/index?type=0" hover-class="none">
  14. <view class="iconfont icon-xiaoxi" :style="'color:'+iconColor"></view>
  15. <text class="iconnum bg-color-red" v-if="userInfo.total_unread">{{ userInfo.total_unread }}</text>
  16. </navigator>
  17. </view>
  18. </view>
  19. <!-- #endif -->
  20. <!-- #ifdef MP || APP-PLUS -->
  21. <view>
  22. <view class="mp-header" :style="'background: '+ bgColor +' ;margin-top:'+ mbConfig +'rpx;'">
  23. <view class="sys-head skeleton-rect" :style="{ height: statusBarHeight }"></view>
  24. <view class="serch-box skeleton-rect" style="height: 43px;">
  25. <view class="serch-wrapper flex">
  26. <view v-if="logoConfig" class="logo skeleton-rect"><image :src="logoConfig" mode=""></image></view>
  27. <navigator :url="merId ? '/pages/store/list/index?mer_id='+merId : '/pages/columnGoods/goods_search/index'" :class="logoConfig ? 'input' : 'uninput'"
  28. hover-class="none" class="skeleton-rect" :style="'border-radius:'+boxStyle+'rpx;text-align:'+txtStyle">
  29. <text class="iconfont icon-xiazai5"></text>
  30. 搜索商品
  31. </navigator>
  32. </view>
  33. </view>
  34. </view>
  35. <view :style="'height:'+marTop+'px;'"></view>
  36. </view>
  37. <!-- #endif -->
  38. </template>
  39. <script>
  40. let statusBarHeight = uni.getSystemInfoSync().statusBarHeight*2 + 'rpx';
  41. export default {
  42. name: 'headerSerch',
  43. props: {
  44. dataConfig: {
  45. type: Object,
  46. default: () => {}
  47. },
  48. userInfo: {
  49. type: Object,
  50. default: () => {}
  51. },
  52. merId: {
  53. type: String || Number,
  54. default: ''
  55. }
  56. },
  57. data() {
  58. return {
  59. statusBarHeight: statusBarHeight,
  60. marTop:0,
  61. searchH: 0,
  62. bgColor: this.dataConfig.bgColor && this.dataConfig.bgColor.color[0].item,
  63. iconColor: this.dataConfig.iconColor && this.dataConfig.iconColor.color[0].item,
  64. boxStyle: this.dataConfig.boxStyle.type ? '0' : '32',
  65. logoConfig: this.dataConfig.logoConfig.url,
  66. mbConfig: this.dataConfig.mbConfig.val*2,
  67. txtStyle: this.dataConfig.txtStyle.type ? 'center' : 'xleft',
  68. };
  69. },
  70. mounted(){
  71. let that = this;
  72. // #ifdef H5
  73. // 获取H5 搜索框高度
  74. setTimeout(() => {
  75. let appSearchH = uni.createSelectorQuery().select('.serch-wrapper');
  76. appSearchH
  77. .boundingClientRect(function(data) {
  78. that.searchH = data.height;
  79. })
  80. .exec();
  81. }, 800);
  82. // #endif
  83. // #ifdef MP || APP-PLUS
  84. setTimeout(() => {
  85. // 获取小程序头部高度
  86. let info = uni.createSelectorQuery().in(this).select(".mp-header");
  87. info.boundingClientRect(function(data) {
  88. that.marTop = data.height
  89. }).exec()
  90. }, 100)
  91. // #endif
  92. },
  93. methods: {
  94. }
  95. }
  96. </script>
  97. <style lang="scss">
  98. .header {
  99. width: 100%;
  100. background: #ffffff;
  101. .btn {
  102. position: relative;
  103. .iconfont {
  104. font-size: 45rpx;
  105. }
  106. }
  107. .iconnum {
  108. min-width: 6px;
  109. color: #fff;
  110. border-radius: 15rpx;
  111. position: absolute;
  112. right: -10rpx;
  113. top: -10rpx;
  114. font-size: 10px;
  115. padding: 0 4px;
  116. }
  117. .serch-wrapper {
  118. align-items: center;
  119. padding: 20rpx 30rpx 20rpx 30rpx;
  120. .logo {
  121. width: 127rpx;
  122. height: 46rpx;
  123. }
  124. image {
  125. width: 118rpx;
  126. height: 42rpx;
  127. }
  128. .input,.uninput {
  129. max-width: 490rpx;
  130. min-width: 460rpx;
  131. line-height: 64rpx;
  132. padding: 0 0 0 30rpx;
  133. background: rgba(237, 237, 237, 1);
  134. border: 1px solid rgba(241, 241, 241, 1);
  135. color: #bbbbbb;
  136. font-size: 28rpx;
  137. .iconfont {
  138. margin-right: 20rpx;
  139. }
  140. }
  141. .uninput {
  142. min-width: 610rpx;
  143. max-width: 620rpx;
  144. }
  145. }
  146. }
  147. /* #ifdef MP || APP-PLUS */
  148. .mp-header {
  149. z-index: 999;
  150. position: fixed;
  151. left: 0;
  152. top: 0;
  153. width: 100%;
  154. /* #ifdef H5 */
  155. padding-bottom: 20rpx;
  156. /* #endif */
  157. background-color: #fff;
  158. .serch-wrapper {
  159. height: 100%;
  160. align-items: center;
  161. padding: 0 50rpx 0 53rpx;
  162. image {
  163. width: 118rpx;
  164. height: 42rpx;
  165. margin-right: 30rpx;
  166. }
  167. .input,.uninput {
  168. display: flex;
  169. align-items: center;
  170. /* #ifndef APP-PLUS */
  171. width: 305rpx;
  172. /* #endif */
  173. /* #ifdef APP-PLUS */
  174. flex: 1;
  175. /* #endif */
  176. height: 58rpx;
  177. padding: 0 0 0 30rpx;
  178. background: rgba(247, 247, 247, 1);
  179. border: 1px solid rgba(241, 241, 241, 1);
  180. border-radius: 29rpx;
  181. color: #bbbbbb;
  182. font-size: 28rpx;
  183. .iconfont {
  184. margin-right: 20rpx;
  185. }
  186. }
  187. .uninput {
  188. min-width: 460rpx;
  189. max-width: 480rpx;
  190. }
  191. }
  192. }
  193. /* #endif */
  194. </style>