headerSerch.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <!-- #ifdef H5 -->
  3. <view v-if="isShow" class="header">
  4. <view class="serch-wrapper row-middle">
  5. <view class="logo">
  6. <image class="skeleton-rect" :src="logoConfig" mode="heightFix"></image>
  7. <text class="swiger">好物尽享 任你选择</text>
  8. </view>
  9. <view class="input acea-row row-middle fillet skeleton-rect" hover-class="none" @click="goPage"><text
  10. class="iconfont icon-sousuo"></text>
  11. 搜索商品</view>
  12. </view>
  13. </view>
  14. <view v-else-if="isIframe" class="header">
  15. <view class="serch-wrapper acea-row row-middle">
  16. <view class="logo">
  17. <image :src="logoConfig" mode="heightFix"></image>
  18. <text class="swiger">好物尽享 任你选择</text>
  19. </view>
  20. <view class="input acea-row row-middle fillet" hover-class="none" @click="goPage"><text
  21. class="iconfont icon-sousuo"></text>
  22. 搜索商品</view>
  23. </view>
  24. </view>
  25. <!-- #endif -->
  26. <!-- #ifdef MP || APP-PLUS -->
  27. <view v-if="isShow">
  28. <view class="mp-header skeleton-rect" :style="{height:headH}">
  29. <view class="sys-head" :style="{height:sysHeight}"></view>
  30. <view class="serch-box" style="height: 48px;">
  31. <view class="serch-wrapper row-middle">
  32. <view class="logo">
  33. <image class="skeleton-rect" :src="logoConfig" mode="heightFix"></image>
  34. <text class="swiger">好物尽享 任你选择</text>
  35. </view>
  36. <navigator url="/pages/goods_search/index" class="input acea-row row-middle fillet"
  37. hover-class="none"><text class="iconfont icon-sousuo"></text>
  38. 搜索商品</navigator>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <!-- #endif -->
  44. </template>
  45. <script>
  46. let app = getApp();
  47. let statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  48. let headHeight = uni.getSystemInfoSync().statusBarHeight + 100 + 'px';
  49. import {
  50. goPage
  51. } from '@/libs/order.js'
  52. export default {
  53. name: 'headerSerch',
  54. props: {
  55. dataConfig: {
  56. type: Object,
  57. default: () => {}
  58. }
  59. },
  60. data() {
  61. return {
  62. logoConfig: '',
  63. hotWords: [],
  64. sysHeight: statusBarHeight,
  65. headH: headHeight,
  66. name: this.$options.name,
  67. isShow: true,
  68. isIframe: app.globalData.isIframe
  69. };
  70. },
  71. watch: {
  72. dataConfig: {
  73. immediate: true,
  74. handler(nVal, oVal) {
  75. if (nVal) {
  76. this.logoConfig = nVal ? nVal.imgUrl.url : '';
  77. this.hotWords = nVal.hotList.list
  78. this.isShow = nVal.isShow.val
  79. uni.setStorageSync('hotList', this.hotWords);
  80. }
  81. }
  82. }
  83. },
  84. mounted() {
  85. let that = this;
  86. // #ifdef MP
  87. this.$nextTick(function() {
  88. // 获取小程序头部高度
  89. let info = uni.createSelectorQuery().in(this).select(".mp-header");
  90. info.boundingClientRect(function(data) {
  91. that.marTop = data.height
  92. }).exec()
  93. })
  94. // #endif
  95. },
  96. methods: {
  97. goPage() {
  98. goPage().then(res => {
  99. uni.navigateTo({
  100. url: '/pages/goods_search/index'
  101. })
  102. })
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss">
  108. /* #ifdef H5 */
  109. .header {
  110. width: 100%;
  111. height: 280rpx;
  112. background: #fff;
  113. background: linear-gradient(90deg, var(--view-main-start) 0%, var(--view-main-over) 100%);
  114. border-bottom-left-radius: 60rpx;
  115. border-bottom-right-radius: 60rpx;
  116. .serch-wrapper {
  117. padding: 20rpx 30rpx 0 30rpx;
  118. .logo {
  119. margin-right: 30rpx;
  120. display: flex;
  121. align-items: flex-end;
  122. image {
  123. width: 144rpx;
  124. height: 50rpx;
  125. }
  126. .swiger {
  127. color: #fff;
  128. font-size: 24rpx;
  129. margin-left: 20rpx;
  130. }
  131. }
  132. .input {
  133. display: flex;
  134. height: 60rpx;
  135. padding: 0 0 0 30rpx;
  136. background: rgba(247, 247, 247, 1);
  137. border: 1px solid rgba(241, 241, 241, 1);
  138. color: #999;
  139. font-size: 28rpx;
  140. flex: 1;
  141. z-index: 99;
  142. margin: 14rpx 0;
  143. .iconfont {
  144. margin-right: 20rpx;
  145. color: #555555;
  146. }
  147. // 没有logo,直接搜索框
  148. &.on {
  149. width: 100%;
  150. }
  151. // 设置圆角
  152. &.fillet {
  153. border-radius: 40rpx;
  154. }
  155. // 文本框文字居中
  156. &.row-center {
  157. padding: 0;
  158. }
  159. }
  160. }
  161. }
  162. /* #endif */
  163. /* #ifdef MP || APP-PLUS */
  164. .mp-header {
  165. position: fixed;
  166. left: 0;
  167. top: 0;
  168. width: 100%;
  169. background: linear-gradient(90deg, var(--view-main-start) 0%, var(--view-main-over) 100%);
  170. z-index: 999;
  171. // height: 250rpx;
  172. .serch-box {
  173. padding-bottom: 10rpx;
  174. }
  175. .serch-wrapper {
  176. height: 100%;
  177. padding: 20rpx 30rpx 20rpx 30rpx;
  178. .logo {
  179. margin-right: 30rpx;
  180. display: flex;
  181. align-items: flex-end;
  182. image {
  183. width: 144rpx;
  184. height: 50rpx;
  185. }
  186. .swiger {
  187. color: #fff;
  188. font-size: 24rpx;
  189. margin-left: 20rpx;
  190. margin-bottom: 2rpx;
  191. }
  192. }
  193. .input {
  194. height: 60rpx;
  195. padding: 0 0 0 30rpx;
  196. background: rgba(247, 247, 247, 1);
  197. border: 1px solid rgba(241, 241, 241, 1);
  198. color: #999;
  199. font-size: 28rpx;
  200. // margin: 14rpx 0;
  201. margin-top: 34rpx;
  202. margin-bottom: 20rpx;
  203. flex: 1;
  204. .iconfont {
  205. margin-right: 20rpx;
  206. color: #555555;
  207. }
  208. // 没有logo,直接搜索框
  209. &.on {
  210. width: 70%;
  211. }
  212. // 设置圆角
  213. &.fillet {
  214. border-radius: 40rpx;
  215. }
  216. // 文本框文字居中
  217. &.row-center {
  218. padding: 0;
  219. }
  220. }
  221. }
  222. }
  223. /* #endif */
  224. </style>