From aeae9c2e39e900898e67ef4a659fa22276832c8f 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 16:58:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/order_food/order_food.vue | 46 ++++++++++++++++----------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/pages/order_food/order_food.vue b/pages/order_food/order_food.vue index 255e19f..45bdfa0 100644 --- a/pages/order_food/order_food.vue +++ b/pages/order_food/order_food.vue @@ -469,29 +469,6 @@ } }, - - /** - * 获取商品数据 - */ - async productqueryProduct() { - let res = await this.api.productqueryProduct({ - "shopId": uni.cache.get('shopUser'), - "productGroupId": '' - }) - if (res.code == 0) { - this.shopProductList = res.data; - if (this.cartLists && this.cartLists.data && this.cartLists.data.length >= 0) { - this.setNumber() - } - this.scrollTopSize = 0 - this.scrollHeight = 1000 - this.topArr = [] - setTimeout(() => { - this.getElementTop(); - }, 100); - } - }, - /** * 商品数量增加/减少 * @param {Object} item @@ -833,10 +810,30 @@ this.socketTicket.send(data); } }, + /** + * 获取商品数据 + */ + async productqueryProduct() { + let res = await this.api.productqueryProduct({ + "shopId": uni.cache.get('shopUser'), + "productGroupId": '' + }) + if (res.code == 0) { + this.shopProductList = res.data; + if (this.cartLists && this.cartLists.data && this.cartLists.data.length >= 0) { + this.setNumber() + } + this.scrollTopSize = 0 + this.scrollHeight = 1000 + this.topArr = [] + setTimeout(() => { + this.getElementTop(); + }, 500); + } + }, /* 获取元素顶部信息 */ getElementTop() { - new Promise((resolve, reject) => { let view = uni.createSelectorQuery().selectAll('.main-item'); view.boundingClientRect(async data => { @@ -846,6 +843,7 @@ this.scrollTopSize = res.top; //元素距离顶部的距离 }) }).then((res) => { + console.log(res, 111) let topArr = res.map((item) => { return item.top; /* 减去滚动容器距离顶部的距离 加导航栏高度*/ });