diff --git a/pages/order_food/order_food.vue b/pages/order_food/order_food.vue index 2052589..c8ee42b 100644 --- a/pages/order_food/order_food.vue +++ b/pages/order_food/order_food.vue @@ -327,7 +327,6 @@ fixedtrue: true, userInfo: uni.cache.get('userInfo'), //个人信息 opacity: false, //是否显示 - scrollHeight: 1000, scrollTopSize: 0, //距离顶部的高度 fillHeight: 0, // 填充高度,用于最后一项低于滚动区域时使用 leftArray: [], @@ -352,6 +351,7 @@ salePrice: '', //钱数 cartListsdatashow: false, //是否显示购物车 showCart: false, + lastbottom: '' //元素最低端的距离 } }, onPageScroll(e) { @@ -368,17 +368,21 @@ return `left-${this.leftIndex? this.leftIndex:0}`; }, HeighT() { //手机类型的尺寸 导航栏高度 + console.log(this.$store.getters.is_BarHeight) return this.$store.getters.is_BarHeight.heightBar + this.$store.getters.is_BarHeight.customBar }, + scrollHeight() { + return this.$store.getters.is_BarHeight.info.windowHeight - this.HeighT + } }, onReady() { - setTimeout(() => { - uni.getSystemInfo({ - success: (data) => { - this.scrollHeight = data.windowHeight - } - }) - }, 100); + // setTimeout(() => { + // uni.getSystemInfo({ + // success: (data) => { + // this.scrollHeight = data.windowHeight + // } + // }) + // }, 100); }, onLoad(e) { if (e.q) { @@ -402,7 +406,6 @@ scrollTop: 0, duration: 0 }); - console.log(!uni.cache.get('token')) if (!uni.cache.get('token')) { uni.login({ provider: 'weixin', @@ -840,7 +843,6 @@ this.setNumber() } this.scrollTopSize = 0 - this.scrollHeight = 1000 this.topArr = [] setTimeout(() => { this.getElementTop(); @@ -859,11 +861,14 @@ this.scrollTopSize = res.top; //元素距离顶部的距离 }) }).then((res) => { + console.log(res) let topArr = res.map((item) => { return item.top; /* 减去滚动容器距离顶部的距离 加导航栏高度*/ }); - this.scrollHeight = this.scrollHeight - this.HeighT + // this.scrollHeight = this.scrollHeight - this.HeighT this.topArr = topArr; + // 获取最后一个元素最低端的盒子到顶点的距离 + this.lastbottom = res[res.length - 1].bottom; /* 获取最后一项的高度,设置填充高度。判断和填充时做了 +-20 的操作,是为了滚动时更好的定位 */ let last = res[res.length - 1].height; if (last - 20 < this.scrollHeight) { @@ -889,12 +894,11 @@ index = i; break; } + // const lastElement = this.topArr[this.topArr.length - 1]; } - const lastElement = this.topArr[this.topArr.length - 1]; const currentElement = this.topArr[index]; - const diff = lastElement - currentElement; - console.log(diff) - if (diff > this.scrollHeight) { + const diff = this.lastbottom - currentElement; + if (diff > this.scrollHeight - 200) { //200是固定高度 this.leftIndex = (index < 0 ? 0 : index); } else { this.leftIndex = this.leftIndex @@ -1074,6 +1078,7 @@ .panelfiveitemsex { margin-top: 32rpx; + .panelfiveitemsex_oen { text:nth-child(1) { font-family: Source Han Sans CN, Source Han Sans CN;