diff --git a/pages/order_food/order_food.vue b/pages/order_food/order_food.vue index a3860fc..2f2c26d 100644 --- a/pages/order_food/order_food.vue +++ b/pages/order_food/order_food.vue @@ -35,7 +35,7 @@ 本店招牌菜 - + @@ -92,7 +92,8 @@ - + {{item.name}} @@ -108,7 +109,7 @@ - @@ -355,7 +356,8 @@ salePrice: '', //钱数 cartListsdatashow: false, //是否显示购物车 showCart: false, - lastbottom: '' //元素最低端的距离 + lastbottom: '', //元素最低端的距离 + scrollxleft: false } }, onPageScroll(e) { @@ -889,7 +891,7 @@ // this.scrollHeight = this.scrollHeight - this.HeighT this.topArr = topArr; // 获取最后一个元素最低端的盒子到顶点的距离 - this.lastbottom = res[res.length - 1].bottom; + this.lastbottom = res[res.length - 1].bottom - 20; /* 获取最后一项的高度,设置填充高度。判断和填充时做了 +-20 的操作,是为了滚动时更好的定位 */ let last = res[res.length - 1].height; if (last - 20 < this.scrollHeight) { @@ -908,21 +910,25 @@ let scrollFn = () => { let top = e.scrollTop; let index = 0; - /* 查找当前滚动距离 */ - for (let i = (this.topArr.length - 1); i >= 0; i--) { - /* 在部分安卓设备上,因手机逻辑分辨率与rpx单位计算不是整数,滚动距离与有误差,增加2px来完善该问题 */ - if ((top + 2) >= this.topArr[i] - this.HeighT) { - index = i; - break; - } - // const lastElement = this.topArr[this.topArr.length - 1]; - } - const currentElement = this.topArr[index]; - const diff = this.lastbottom - currentElement; - if (diff > this.scrollHeight - 200) { //200是固定高度 - this.leftIndex = (index < 0 ? 0 : index); + // 判断左边是否可以滑动 + if (top + 2 > this.topArr[0]) { + this.scrollxleft = true } else { + this.scrollxleft = false + } + /* 查找当前滚动距离 */ + if (this.scrollHeight - 200 >= (this.topArr[this.topArr.length - 1] - this.topArr[this + .leftIndex])) { //4109 this.leftIndex = this.leftIndex + } else { + for (let i = (this.topArr.length - 1); i >= 0; i--) { + /* 在部分安卓设备上,因手机逻辑分辨率与rpx单位计算不是整数,滚动距离与有误差,增加2px来完善该问题 */ + if ((top + 2) >= this.topArr[i] - this.HeighT) { + index = i; + break; + } + } + this.leftIndex = (index < 0 ? 0 : index); } } }, @@ -1719,7 +1725,7 @@ } .items { - height: 180rpx; + height: 90px; position: relative; font-weight: 400; font-size: 24rpx;