headerSerch.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <!-- #ifdef H5 -->
  3. <view class="header" :style="'background: '+ bgColor +' ;margin-top:'+ mbConfig +'rpx;'">
  4. <view class="serch-wrapper acea-row row-between-wrapper" :style="'padding-left:'+prConfig+'rpx;'">
  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 box" 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" 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" :style="'padding-left:'+prConfig+'rpx;'">
  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 box" :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. // +----------------------------------------------------------------------
  41. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  42. // +----------------------------------------------------------------------
  43. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  44. // +----------------------------------------------------------------------
  45. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  46. // +----------------------------------------------------------------------
  47. // | Author: CRMEB Team <admin@crmeb.com>
  48. // +----------------------------------------------------------------------
  49. let statusBarHeight = uni.getSystemInfoSync().statusBarHeight*2 + 'rpx';
  50. export default {
  51. name: 'headerSerch',
  52. props: {
  53. dataConfig: {
  54. type: Object,
  55. default: () => {}
  56. },
  57. userInfo: {
  58. type: Object,
  59. default: () => {}
  60. },
  61. merId: {
  62. type: String || Number,
  63. default: ''
  64. }
  65. },
  66. data() {
  67. return {
  68. statusBarHeight: statusBarHeight,
  69. marTop:0,
  70. searchH: 0,
  71. bgColor: this.dataConfig.bgColor && this.dataConfig.bgColor.color[0].item,
  72. iconColor: this.dataConfig.iconColor && this.dataConfig.iconColor.color[0].item,
  73. boxStyle: this.dataConfig.boxStyle.type ? '0' : '32',
  74. logoConfig: this.dataConfig.logoConfig.url,
  75. mbConfig: this.dataConfig.mbConfig.val*2,
  76. prConfig: this.dataConfig.prConfig.val*2,
  77. txtStyle: this.dataConfig.txtStyle.type ? 'center' : 'xleft',
  78. };
  79. },
  80. mounted(){
  81. let that = this;
  82. // #ifdef H5
  83. // 获取H5 搜索框高度
  84. setTimeout(() => {
  85. let appSearchH = uni.createSelectorQuery().select('.serch-wrapper');
  86. appSearchH
  87. .boundingClientRect(function(data) {
  88. that.searchH = data.height;
  89. })
  90. .exec();
  91. }, 800);
  92. // #endif
  93. // #ifdef MP || APP-PLUS
  94. setTimeout(() => {
  95. // 获取小程序头部高度
  96. let info = uni.createSelectorQuery().in(this).select(".mp-header");
  97. info.boundingClientRect(function(data) {
  98. that.marTop = data.height
  99. }).exec()
  100. }, 300)
  101. // #endif
  102. },
  103. methods: {}
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. .header {
  108. width: 100%;
  109. background: #ffffff;
  110. .btn {
  111. position: relative;
  112. margin-left: 30rpx;
  113. .iconfont {
  114. font-size: 45rpx;
  115. }
  116. }
  117. .iconnum {
  118. min-width: 6px;
  119. color: #fff;
  120. background: #e93323;
  121. border-radius: 15rpx;
  122. position: absolute;
  123. right: -10rpx;
  124. top: -10rpx;
  125. font-size: 10px;
  126. padding: 0 4px;
  127. }
  128. .serch-wrapper {
  129. display: flex;
  130. align-items: center;
  131. padding: 20rpx 30rpx 20rpx 30rpx;
  132. .box{
  133. flex: 1;
  134. }
  135. .logo {
  136. width: 127rpx;
  137. height: 46rpx;
  138. margin-right: 20rpx;
  139. }
  140. image {
  141. width: 118rpx;
  142. height: 42rpx;
  143. }
  144. .input,.uninput {
  145. line-height: 64rpx;
  146. padding: 0 0 0 30rpx;
  147. background: rgba(237, 237, 237, 1);
  148. border: 1px solid rgba(241, 241, 241, 1);
  149. color: #bbbbbb;
  150. font-size: 28rpx;
  151. .iconfont {
  152. margin-right: 20rpx;
  153. }
  154. }
  155. }
  156. }
  157. /* #ifdef MP || APP-PLUS */
  158. .mp-header {
  159. z-index: 999;
  160. position: fixed;
  161. left: 0;
  162. top: 0;
  163. width: 100%;
  164. /* #ifdef H5 */
  165. padding-bottom: 20rpx;
  166. /* #endif */
  167. background-color: #fff;
  168. .serch-wrapper {
  169. height: 100%;
  170. align-items: center;
  171. padding: 0 50rpx 0 53rpx;
  172. image {
  173. width: 118rpx;
  174. height: 42rpx;
  175. margin-right: 30rpx;
  176. }
  177. .input,.uninput {
  178. display: flex;
  179. align-items: center;
  180. /* #ifndef APP-PLUS */
  181. width: 305rpx;
  182. /* #endif */
  183. /* #ifdef APP-PLUS */
  184. flex: 1;
  185. width: 500rpx;
  186. /* #endif */
  187. height: 58rpx;
  188. padding: 0 0 0 30rpx;
  189. background: rgba(247, 247, 247, 1);
  190. border: 1px solid rgba(241, 241, 241, 1);
  191. border-radius: 29rpx;
  192. color: #bbbbbb;
  193. font-size: 28rpx;
  194. .iconfont {
  195. margin-right: 20rpx;
  196. }
  197. }
  198. .uninput {
  199. /* #ifdef MP */
  200. min-width: 450rpx;
  201. max-width: 480rpx;
  202. /* #endif*/
  203. }
  204. }
  205. }
  206. /* #endif */
  207. </style>