headerSerch.vue 5.3 KB

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