Browse Source

首页导航条问题

shenjj 7 years ago
parent
commit
b4c9b9c3f1
2 changed files with 21 additions and 10 deletions
  1. 20 9
      components/home/floor/FloorBar.vue
  2. 1 1
      nuxt.config.js

+ 20 - 9
components/home/floor/FloorBar.vue

@@ -28,7 +28,15 @@
     },
     methods: {
       _calcaulateHeight() {
-        this.bannerHeight = document.querySelectorAll('.normal-floor')[0].offsetTop
+        let _heis0 = document.querySelectorAll('header')[0].clientHeight
+        let _heis1 = document.querySelectorAll('.header.clearfix')[0].clientHeight
+        let _heis2 = document.querySelectorAll('.nav-list')[0].clientHeight
+        let _heis3 = document.querySelectorAll('.carousel')[0].clientHeight
+        let _heis4 = document.querySelectorAll('.advert-slide')[0].clientHeight
+        let _heis5 = document.querySelectorAll('.banner')[0].clientHeight
+        let _heis6 = document.querySelectorAll('.floor.price-floor')[0].clientHeight
+        let _heis7 = document.querySelectorAll('.floor.price-floor')[1].clientHeight
+        this.bannerHeight = _heis0 + _heis1 + _heis2 + _heis3 + _heis4 + _heis5 + _heis6 + _heis7
         this.listHeight = []
         this.list = document.querySelectorAll('.normal-floor')
         let height = 0
@@ -36,7 +44,7 @@
         for (let i = 0; i < this.list.length; i++) {
           const item = this.list[i]
           if (i === 0) {
-            height += item.offsetTop + item.clientHeight / 2
+            height += this.bannerHeight + item.clientHeight / 2
           } else {
             height += item.clientHeight
           }
@@ -46,23 +54,26 @@
       onScroll () {
         if (window.location.pathname === '/') {
           let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
-          this.visible = scrolled >= this.bannerHeight - window.innerHeight / 2 + 220
+          console.log(this.bannerHeight)
+          this.visible = scrolled >= this.bannerHeight - window.innerHeight / 2 + 200
+          // console.log(this.bannerHeight, window.innerHeight)
           let _scrollHeight = scrolled
           const listHeight = this.listHeight
           for (let i = 0; i < listHeight.length; i++) {
             let height1 = listHeight[i]
-            // let height2 = listHeight[i + 1]
-            console.log(height1, _scrollHeight)
-            if (_scrollHeight >= height1) this.activeFloor = i
-            // if (_scrollHeight >= height1 && _scrollHeight < height2) {
-            //   this.activeFloor = i
-            // }
+            let height2 = listHeight[i + 1]
+            // console.log(height1, _scrollHeight)
+            // if (_scrollHeight >= height1) this.activeFloor = i
+            if (_scrollHeight >= height1 && _scrollHeight < height2) {
+              this.activeFloor = i
+            }
           }
           if (_scrollHeight > listHeight[listHeight.length - 1]) {
             this.visible = false
           }
           // let floors = document.querySelectorAll('.normal-floor')
           // let barOffset = document.querySelector('.floor-bar').offsetTop
+          // console.log(barOffset)
           // if (floors[0].offsetTop === 0) {
           // this.visible = scrolled >= floors[0].offsetTop + this.floor_scrollTop - barOffset && scrolled <= floors[floors.length - 1].offsetTop + floors[floors.length - 1].offsetHeight - barOffset - document.querySelector('.floor-bar').offsetHeight + this.floor_scrollTop
           // if (this.visible) {

+ 1 - 1
nuxt.config.js

@@ -1,6 +1,6 @@
 const path = require('path')
 const isProdMode = Object.is(process.env.NODE_ENV, 'production')
-const baseUrl = process.env.BASE_URL || (isProdMode ? 'http://api.usoftmall.com/' : 'http://192.168.253.121:9090/platform-b2c')
+const baseUrl = process.env.BASE_URL || (isProdMode ? 'http://api.usoftmall.com/' : 'http://10.1.51.125:8080/platform-b2c')
 const commonUrl = process.env.COMMON_URL || (isProdMode ? 'https://api-inquiry.usoftmall.com/' : 'http://218.17.158.219:24000/')
 
 module.exports = {