From f442a5a85c0d27e0eac0f98ccd38d88707c81e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=95=BE?= <1144797966@qq.com> Date: Sat, 3 Aug 2024 11:18:26 +0800 Subject: [PATCH] 11 --- pages/order_food/order_food.vue | 68 ++++++++++++++++----------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/pages/order_food/order_food.vue b/pages/order_food/order_food.vue index 516d06c..676b3e4 100644 --- a/pages/order_food/order_food.vue +++ b/pages/order_food/order_food.vue @@ -9,10 +9,7 @@ - - - @@ -356,22 +353,16 @@ } }, onPageScroll(e) { - try { - if (e.scrollTop <= 44) { //搜索导航栏显示影藏 - this.opacity = false - } else { - this.opacity = true - } - } catch (e) { - //TODO handle the exception + if (e.scrollTop <= 44) { //搜索导航栏显示影藏 + this.opacity = false + } else { + this.opacity = true } this.$u.debounce(() => { - console.log(e.scrollTop, this.scrollTopSize) if (e.scrollTop >= this.scrollTopSize) { //控制大图层 - // this.isFixed = false; - this.$set(this, 'isFixed', false); + this.isFixed = false; } else { - this.$set(this, 'isFixed', true); + this.isFixed = true; } }, 10) @@ -526,9 +517,9 @@ */ shopAdd(item, index, index1, a, b) { let flag = true; - if ( this.cartLists.data.length > 0) { - this.cartLists.data.forEach((v,e)=>{ - if ( v.productId == item.id) { + if (this.cartLists.data.length > 0) { + this.cartLists.data.forEach((v, e) => { + if (v.productId == item.id) { flag = false; } console.log(v) @@ -538,18 +529,18 @@ console.log(this.amountcartNumber) console.log(flag) console.log(item) - if ( a == "+" ){ - if ( this.amountcartNumber <= 0 && flag) { - this.amountcartNumber = this.amountcartNumber + (item.suit==0?1:item.suit); - }else { + if (a == "+") { + if (this.amountcartNumber <= 0 && flag) { + this.amountcartNumber = this.amountcartNumber + (item.suit == 0 ? 1 : item.suit); + } else { this.amountcartNumber++; } } else { if (this.amountcartNumber > 0) { console.log(item) - if ( this.amountcartNumber <= item.suit && flag) { - this.amountcartNumber = this.amountcartNumber - (item.suit==0?1:item.suit); + if (this.amountcartNumber <= item.suit && flag) { + this.amountcartNumber = this.amountcartNumber - (item.suit == 0 ? 1 : item.suit); } else { this.amountcartNumber = this.amountcartNumber - 1; } @@ -878,7 +869,7 @@ /* 获取最后一项的高度,设置填充高度。判断和填充时做了 +-20 的操作,是为了滚动时更好的定位 */ let last = res[res.length - 1].height; if (last - 20 < this.scrollHeight) { - this.fillHeight = this.scrollHeight - last + 20;//这是吸到顶部的距离 + this.fillHeight = this.scrollHeight - last + 20; //这是吸到顶部的距离 // this.fillHeight = 200; } }); @@ -908,15 +899,18 @@ }, /* 左侧导航点击 */ leftTap(e) { - console.log(this.scrollTopSize + this.HeighT,11) + let HeighTdata = null + if (this.opacity) { + HeighTdata = this.HeighT + } else { + HeighTdata = this.HeighT * 2 + } + console.log(this.scrollTopSize + HeighTdata, 11) try { - if (this.isFixed) { - uni.pageScrollTo({ - scrollTop: this.scrollTopSize + this.HeighT, //滑动需要的距离 nav+列表距离的高度 - duration: 100 - }); - this.isFixed = false - } + uni.pageScrollTo({ + scrollTop: this.scrollTopSize + HeighTdata, //滑动需要的距离 nav+列表距离的高度 + duration: 0 + }); } catch (e) { //TODO handle the exception } @@ -1819,13 +1813,15 @@ color: #999999; margin-bottom: 8rpx; } - .describe,.name{ + + .describe, + .name { width: 270rpx; overflow: hidden; text-overflow: ellipsis; - white-space: nowrap; + white-space: nowrap; } - + .lookBack { color: #FF534B;