headerSerch.vue 4.0 KB

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