headerSerch.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. <view class="swiger">{{titleInfo.length ? $t(titleInfo[0].val) : ''}}</view>
  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. {{$t('搜索商品')}}</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. <view class="swiger">{{titleInfo.length ? titleInfo[0].val : ''}}</view>
  19. </view>
  20. <view class="input acea-row row-middle fillet" hover-class="none" @click="goPage"><text
  21. class="iconfont icon-sousuo"></text>
  22. {{$t('搜索商品')}}</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. <view class="swiger">{{titleInfo.length ? titleInfo[0].val : ''}}</view>
  35. </view>
  36. <navigator url="/pages/goods/goods_search/index" class="input acea-row row-middle fillet"
  37. hover-class="none"><text class="iconfont icon-sousuo"></text>
  38. {{$t('搜索商品')}}</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 * 2 + 'rpx';
  48. let headHeight = uni.getSystemInfoSync().statusBarHeight * 2 + 170 + 'rpx';
  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. titleInfo: []
  70. };
  71. },
  72. watch: {
  73. dataConfig: {
  74. immediate: true,
  75. handler(nVal, oVal) {
  76. if (nVal) {
  77. this.logoConfig = nVal ? nVal.imgUrl.url : '';
  78. this.hotWords = nVal.hotList.list || []
  79. this.isShow = nVal.isShow.val
  80. this.titleInfo = nVal.titleInfo && nVal.titleInfo.list.length ? nVal.titleInfo.list : [];
  81. uni.setStorageSync('hotList', this.hotWords || []);
  82. }
  83. }
  84. }
  85. },
  86. mounted() {
  87. let that = this;
  88. // #ifdef MP
  89. this.$nextTick(function() {
  90. // 获取小程序头部高度
  91. let info = uni.createSelectorQuery().in(this).select(".mp-header");
  92. info.boundingClientRect(function(data) {
  93. that.marTop = data.height
  94. }).exec()
  95. })
  96. // #endif
  97. },
  98. methods: {
  99. goPage() {
  100. goPage().then(res => {
  101. uni.navigateTo({
  102. url: '/pages/goods/goods_search/index'
  103. })
  104. })
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss">
  110. /* #ifdef H5 */
  111. .header {
  112. width: 100%;
  113. height: 210rpx;
  114. background: #fff;
  115. background: linear-gradient(90deg, var(--view-main-start) 0%, var(--view-main-over) 100%);
  116. border-bottom-left-radius: 60rpx;
  117. border-bottom-right-radius: 60rpx;
  118. .serch-wrapper {
  119. padding: 20rpx 30rpx 0 30rpx;
  120. .logo {
  121. margin-right: 30rpx;
  122. display: flex;
  123. align-items: flex-end;
  124. image {
  125. width: 144rpx;
  126. height: 50rpx;
  127. }
  128. .swiger {
  129. color: #fff;
  130. font-size: 24rpx;
  131. margin-left: 20rpx;
  132. margin-bottom: -2rpx;
  133. }
  134. }
  135. .input {
  136. display: flex;
  137. height: 60rpx;
  138. padding: 0 0 0 30rpx;
  139. background: rgba(247, 247, 247, 1);
  140. border: 1px solid rgba(241, 241, 241, 1);
  141. color: #999;
  142. font-size: 28rpx;
  143. flex: 1;
  144. z-index: 99;
  145. margin: 14rpx 0;
  146. .iconfont {
  147. margin-right: 20rpx;
  148. color: #555555;
  149. }
  150. // 没有logo,直接搜索框
  151. &.on {
  152. width: 100%;
  153. }
  154. // 设置圆角
  155. &.fillet {
  156. border-radius: 40rpx;
  157. }
  158. // 文本框文字居中
  159. &.row-center {
  160. padding: 0;
  161. }
  162. }
  163. }
  164. }
  165. /* #endif */
  166. /* #ifdef MP || APP-PLUS */
  167. .mp-header {
  168. position: fixed;
  169. left: 0;
  170. top: 0;
  171. width: 100%;
  172. background: linear-gradient(90deg, var(--view-main-start) 0%, var(--view-main-over) 100%);
  173. z-index: 999;
  174. // height: 250rpx;
  175. .serch-box {
  176. padding-bottom: 10rpx;
  177. }
  178. .serch-wrapper {
  179. height: 100%;
  180. padding: 15rpx 30rpx 20rpx 30rpx;
  181. .logo {
  182. margin-right: 30rpx;
  183. display: flex;
  184. align-items: flex-end;
  185. image {
  186. width: 144rpx;
  187. height: 50rpx;
  188. }
  189. .swiger {
  190. color: #fff;
  191. font-size: 24rpx;
  192. margin-left: 20rpx;
  193. margin-bottom: -2rpx;
  194. }
  195. }
  196. .input {
  197. height: 60rpx;
  198. padding: 0 0 0 30rpx;
  199. background: rgba(247, 247, 247, 1);
  200. border: 1px solid rgba(241, 241, 241, 1);
  201. color: #999;
  202. font-size: 28rpx;
  203. // margin: 14rpx 0;
  204. margin-top: 20rpx;
  205. margin-bottom: 20rpx;
  206. flex: 1;
  207. .iconfont {
  208. margin-right: 20rpx;
  209. color: #555555;
  210. }
  211. // 没有logo,直接搜索框
  212. &.on {
  213. width: 70%;
  214. }
  215. // 设置圆角
  216. &.fillet {
  217. border-radius: 40rpx;
  218. }
  219. // 文本框文字居中
  220. &.row-center {
  221. padding: 0;
  222. }
  223. }
  224. }
  225. }
  226. /* #endif */
  227. </style>