customer.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template name="headerNavbar">
  2. <!-- 自定义导航栏 -->
  3. <view>
  4. <view
  5. class="navbar-wrap"
  6. :class="isScroll ? opacityNav : ''"
  7. :style="{
  8. height: CustomBar + 88 + 'px',
  9. paddingTop: StatusBar + 'px'
  10. }"
  11. >
  12. <view
  13. class="navbar-text"
  14. :style="{
  15. color: navbarData.textColor ? navbarData.textColor : '',
  16. lineHeight: CustomBar - StatusBar + 'px;',
  17. fontSize: fontSizeSetting + 'px;',
  18. paddingLeft: navbarData.textLeft ? '' : 12 + 'px'
  19. }"
  20. :class="platformClass"
  21. >
  22. {{ navbarData.title ? navbarData.title : ' ' }}
  23. </view>
  24. <view class="search-input">
  25. <view class="gosearch-btn" @click="this.$api.navigateTo(clickPath)">
  26. <view class="search-icon"><text class="iconfont icon-iconfonticonfontsousuo1"></text></view>
  27. <view class="search-text">{{ hotSearchText }}</view> <view class="search-btn">搜索</view>
  28. </view>
  29. <view class="gosearch-kf">
  30. <!-- #ifdef MP-WEIXIN -->
  31. <button class="contact-btn" open-type="contact" @bindcontact="handleContact">
  32. <text class="iconfont icon-zixunrexian"></text>
  33. </button>
  34. <!-- #endif -->
  35. </view>
  36. </view>
  37. <view class="swiper-banner-nav">
  38. <scroll-view class="scroll-view_H" scroll-x="true">
  39. <view class="tui-goods__item active">首页</view>
  40. <view class="tui-goods__item" v-for="(navs, index) in navBarsList" @click="NavToDetailPage(navs,index)">
  41. {{ navs.name }}
  42. </view>
  43. </scroll-view>
  44. <view class="swiper-nav-icon" @click="showDropScreenShow">
  45. <text class="iconfont" :class="dropScreenShow ? 'icon-xiangshangjiantou':'icon-xiangxiajiantou'"></text>
  46. </view>
  47. </view>
  48. </view>
  49. <!--顶部下拉筛选弹层 属性-->
  50. <tui-top-dropdown
  51. backgroundColor="#FFFFFF"
  52. :show="dropScreenShow"
  53. :height="310"
  54. :paddingbtm="10"
  55. :translatey="dropScreenH"
  56. @close="btnCloseDrop"
  57. >
  58. <scroll-view class="tui-scroll-box" scroll-y :scroll-top="scrollTop">
  59. <view class="tui-seizeaseat-24">
  60. <view class="tui-drop-item tui-icon-middle">全部分类</view>
  61. <view class="tui-drop-item tui-icon-middle active">首页</view>
  62. <view
  63. class="tui-drop-item tui-icon-middle"
  64. v-for="(item, index) in navBarsList"
  65. :key="index"
  66. @tap.stop="NavToDetailPage(item,index)"
  67. :data-index="index"
  68. >
  69. {{ item.name }}
  70. </view>
  71. </view>
  72. </scroll-view>
  73. </tui-top-dropdown>
  74. </view>
  75. </template>
  76. <script>
  77. var self
  78. import btSearch from '@/components/uni-search/bt-search.vue'
  79. export default {
  80. name: 'headerNavbar',
  81. components: {
  82. btSearch
  83. },
  84. props: {
  85. navbarData: {
  86. // 由父页面传递的数据
  87. type: Object
  88. },
  89. navBarsList: {
  90. type: Array
  91. },
  92. isScroll: {
  93. type: Boolean,
  94. default: () => false
  95. }
  96. },
  97. data() {
  98. return {
  99. clickPath: '/pages/search/search',
  100. hotSearchText: '搜索商品/项目仪器',
  101. CustomBar: this.CustomBar, // 顶部导航栏高度
  102. StatusBar: this.StatusBar,
  103. fontSizeSetting: this.fontSizeSetting,
  104. screenWidth: this.screenWidth,
  105. capsule: this.capsule,
  106. platformClass: this.platformClass,
  107. opacityNav: 'opacityNav', // 渐变颜色
  108. height: 64, //header高度
  109. scrollTop: 0,
  110. dropScreenH: this.CustomBar+78, //下拉筛选框距顶部距离
  111. dropScreenShow:false,
  112. animationData: {}
  113. }
  114. },
  115. created() {
  116. if (getCurrentPages().length === 1) {
  117. // 当只有一个页面时
  118. this.navbarData.haveBack = false
  119. } else {
  120. this.navbarData.haveBack = true
  121. }
  122. let obj = {};
  123. // #ifdef MP-WEIXIN
  124. obj = wx.getMenuButtonBoundingClientRect();
  125. // #endif
  126. uni.getSystemInfo({
  127. success: res => {
  128. this.height = obj.top ? obj.top + obj.height + 8 : res.statusBarHeight + 44;
  129. //略小,避免误差带来的影响
  130. this.dropScreenH = (this.height * 750) / res.windowWidth + 148;
  131. }
  132. });
  133. console.log('dropScreenH',this.dropScreenH)
  134. },
  135. onLoad() {},
  136. onPageScroll(e) {
  137. console.log(e)
  138. },
  139. methods: {
  140. BackPage: function() {
  141. this.$emit('navigateBack')
  142. },
  143. _goSearchPath: function() {
  144. this.$emit('goSearchPath')
  145. },
  146. _goHome: function() {
  147. uni.switchTab({
  148. url: '/pages/tabBar/home/index'
  149. })
  150. },
  151. NavToDetailPage(item,index) {//跳转
  152. if(index === 3){
  153. let linkPath = 'https://static.caimei365.com/app/caimei-activity-h5/html/2023/activity_02.html'
  154. this.$api.navigateTo(`/pages/h5/activity/activity?link=${linkPath}&linkId=382`)
  155. }else{
  156. /**
  157. * 页面跳转
  158. **/
  159. this.$api.FlooryNavigateTo(item)
  160. }
  161. },
  162. showDropScreenShow(){
  163. this.dropScreenShow = !this.dropScreenShow
  164. if(this.dropScreenShow){
  165. // 禁止页面滚动
  166. uni.setScrollEnabled(false)
  167. }else{
  168. // 禁止页面滚动
  169. uni.setScrollEnabled(true)
  170. }
  171. },
  172. btnCloseDrop(){
  173. this.dropScreenShow = false
  174. },
  175. handleContact(e) {
  176. console.log(e.detail.path)
  177. console.log(e.detail.query)
  178. }
  179. },
  180. onShow() {}
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .navbar-wrap {
  185. position: fixed;
  186. width: 100%;
  187. top: 0;
  188. z-index: 9999;
  189. box-sizing: border-box;
  190. background:#ffffff url(https://static.caimei365.com/app/img/bg/home_cumres_bg@2x.png);
  191. background-size: cover;
  192. border-bottom: none;
  193. }
  194. .opacityNav {
  195. }
  196. .navbar-text {
  197. font-size: 30rpx;
  198. color: #000000;
  199. font-weight: 500;
  200. }
  201. .navbar-text.center {
  202. text-align: center;
  203. }
  204. .navbar-text.left {
  205. text-align: left;
  206. padding-left: 45px;
  207. }
  208. .navbar-icon {
  209. position: fixed;
  210. display: flex;
  211. box-sizing: border-box;
  212. }
  213. .navbar-icon .iconfont {
  214. display: inline-block;
  215. overflow: hidden;
  216. font-size: 44rpx;
  217. padding-right: 40rpx;
  218. margin-top: 1px;
  219. }
  220. .navbar-icon .icon-iconfonticonfontsousuo1 {
  221. color: #000000;
  222. }
  223. .navbar-icon view {
  224. height: 18px;
  225. border-left: 0.5px solid rgba(0, 0, 0, 0.3);
  226. margin-top: 6px;
  227. }
  228. .navbar-loading {
  229. background: #fff;
  230. text-align: center;
  231. }
  232. .search-input {
  233. width: 100%;
  234. height: 90rpx;
  235. padding: 20rpx 24rpx 0rpx 24rpx;
  236. box-sizing: border-box;
  237. .gosearch-btn {
  238. width: 632rpx;
  239. height: 100%;
  240. padding: 5rpx;
  241. border-radius: 40rpx;
  242. background: #f0f0f0;
  243. color: #8a8a8a;
  244. background: #ffffff;
  245. position: relative;
  246. box-sizing: border-box;
  247. padding-left: 80rpx;
  248. border: 1px solid #ff5b00;
  249. float: left;
  250. .search-icon {
  251. width: 80rpx;
  252. height: 56rpx;
  253. position: absolute;
  254. left: 0;
  255. top: 9rpx;
  256. text-align: center;
  257. line-height: 56rpx;
  258. .icon-iconfonticonfontsousuo1 {
  259. margin: 0 6rpx;
  260. font-size: $font-size-40;
  261. color: #8a8a8a;
  262. z-index: 10;
  263. }
  264. }
  265. .search-text {
  266. font-size: $font-size-24;
  267. line-height: 56rpx;
  268. color: #8a8a8a;
  269. float: left;
  270. }
  271. .search-btn {
  272. width: 120rpx;
  273. height: 58rpx;
  274. border-radius: 30rpx;
  275. background-color: #ff5b00;
  276. line-height: 58rpx;
  277. text-align: center;
  278. font-size: $font-size-28;
  279. color: #ffffff;
  280. float: right;
  281. }
  282. }
  283. .gosearch-kf {
  284. width: 70rpx;
  285. height: 70rpx;
  286. border-radius: 50%;
  287. float: left;
  288. line-height: 70rpx;
  289. text-align: center;
  290. .contact-btn {
  291. width: 70rpx;
  292. height: 70rpx;
  293. background-color: rgba(0, 0, 0, 0);
  294. line-height: 70rpx;
  295. text-align: center;
  296. .iconfont {
  297. font-size: $font-size-48;
  298. color: #ff5b00;
  299. }
  300. }
  301. }
  302. }
  303. .swiper-banner-nav {
  304. width: 100%;
  305. height: 80rpx;
  306. box-sizing: border-box;
  307. padding: 15rpx 76rpx 15rpx 24rpx;
  308. overflow: hidden;
  309. display: flex;
  310. align-items: center;
  311. position: relative;
  312. .swiper-nav-icon {
  313. width: 76rpx;
  314. height: 80rpx;
  315. line-height: 80rpx;
  316. text-align: center;
  317. position: absolute;
  318. right: 0;
  319. top: 0;
  320. .iconfont {
  321. font-size: $font-size-28;
  322. color: #666666;
  323. }
  324. }
  325. .scroll-view_H {
  326. white-space: nowrap;
  327. width: 100%;
  328. .tui-goods__item {
  329. display: inline-block;
  330. margin: 0 20rpx;
  331. height: 50rpx;
  332. line-height: 50rpx;
  333. font-size: $font-size-26;
  334. color: #333333;
  335. text-align: center;
  336. &.active {
  337. color: #ff5b00;
  338. font-weight: bold;
  339. position: relative;
  340. &::before {
  341. content: '';
  342. width: 20rpx;
  343. height: 4rpx;
  344. border-radius: 2rpx;
  345. background: #ff5b00;
  346. position: absolute;
  347. bottom: 0;
  348. left: 50%;
  349. margin-left: -10rpx;
  350. }
  351. }
  352. }
  353. }
  354. }
  355. .tui-scroll-box{
  356. height: 280rpx;
  357. overflow: hidden;
  358. }
  359. .tui-seizeaseat-24 {
  360. width: 100%;
  361. height: auto;
  362. box-sizing: border-box;
  363. padding: 24rpx;
  364. .tui-drop-item {
  365. padding: 0 20rpx;
  366. height: 56rpx;
  367. float: left;
  368. line-height: 56rpx;
  369. background: #f5f5f5;
  370. font-size: 24rpx;
  371. margin: 12rpx 8rpx;
  372. text-align: center;
  373. border: 1px solid #f5f5f5;
  374. color: #666666;
  375. border-radius: 28rpx;
  376. &.active {
  377. background: #ffffff;
  378. border-color: #ff5b00;
  379. color: #ff5b00;
  380. }
  381. }
  382. }
  383. </style>