From 3491197f9fd39193fae668d782354c06a6d2ecf1 Mon Sep 17 00:00:00 2001 From: wei <1937506227@qq.com> Date: Thu, 23 Oct 2025 16:09:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(allDish):=20=E4=BF=AE=E5=A4=8D=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=97=E8=A1=A8=E6=BB=9A=E5=8A=A8=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重置商品列表数据前添加延迟等待,确保scrollTop能正确生效 移除无效的翻页和下拉刷新逻辑,优化滚动加载体验 --- issue.md | 11 ++++++++ pages/allDish/allDish.vue | 58 +++++++++++++++++++++------------------ pages/home/home.vue | 10 +++++-- 3 files changed, 50 insertions(+), 29 deletions(-) create mode 100644 issue.md diff --git a/issue.md b/issue.md new file mode 100644 index 0000000..7275ebd --- /dev/null +++ b/issue.md @@ -0,0 +1,11 @@ +- TODO: 企业注册 + > ^[\u4e00-\u9fa5a-zA-Z0-9\(\)()&._-]+$ + - () + - () + - & + - . + - _ + - \- + - 中文 + - 英文 + - 数字 diff --git a/pages/allDish/allDish.vue b/pages/allDish/allDish.vue index ec1adb7..4bdb8b4 100644 --- a/pages/allDish/allDish.vue +++ b/pages/allDish/allDish.vue @@ -61,7 +61,7 @@ const currentType = ref(0); */ const bottomHeight = ref(0); /** - * 右侧商品列表的滚动高度 + * 右侧商品列表的滚动高度 FIXME: 无法生效 */ const scrollTop = ref(0); /** @@ -398,9 +398,13 @@ async function loadProductList(parentId, tips) { item.showChild = item.specs.length > 1 ? false : item.showChild; }); + const temp = products.value; + products.value = []; + await sleep(100); // 等待更新数据 scrollTop.value 无效的 + products.value = pageIndex.value === 1 ? res.data - : [...products.value, ...(res.data || [])]; + : [...temp, ...(res.data || [])]; rightHeight.value = ((await useRect("#scroll-page"))?.height || 1) + 1; if (tips === 1) { @@ -411,11 +415,12 @@ async function loadProductList(parentId, tips) { scrollTop.value = 0; bottomHeight.value = 0; } + scrollTop.value = 0; uni.hideNavigationBarLoading(); // 停止下拉刷新 uni.stopPullDownRefresh(); } /** - * 滚动事件 + * 滚动事件 判断触底否 * @param {Event} e - 滚动事件参数 */ function onScroll(e) { @@ -431,27 +436,30 @@ function onScroll(e) { /** * 翻页数据 */ -function onLoadList() { - const pageIdx = pageIndex.value + 1; +// function onLoadList() { +// console.log("翻页数据"); - if (pageIdx <= pageCount.value) { - pageIndex.value = pageIdx; - unLoading.value = false; - getProducts(scrollId.value); - } - else { - unLoading.value = true; - } -} +// const pageIdx = pageIndex.value + 1; + +// if (pageIdx <= pageCount.value) { +// pageIndex.value = pageIdx; +// unLoading.value = false; +// getProducts(scrollId.value); +// } +// else { +// unLoading.value = true; +// } +// } /** * 下拉刷新 */ -function onRefresherRefresh() { - triggered.value = false; - if (currentType.value != 0) { - getProducts(typeData.value[currentType.value - 1].id, 1); - } -} +// function onRefresherRefresh() { +// // console.log("下拉刷新"); +// triggered.value = false; +// if (currentType.value != 0) { +// getProducts(typeData.value[currentType.value - 1].id, 1); +// } +// } /** * 触摸开始事件 * @param e 触摸事件参数 @@ -518,7 +526,6 @@ async function onTouchEnd() { ) { bottomHeight.value = 0; if (!isSearching.value) { - scrollTop.value = 0; await getProducts(typeData.value[currentType.value + 1].id, 2); } } @@ -909,7 +916,6 @@ onHide(() => { @scroll="onScroll" 滚动过程中实时监听滚动位置 @refresherrefresh="onRefresherrefresh" 下拉刷新时触发重新加载当前分类数据 --> - { transition: '.01s all', }" @scrolltolower="() => { - // FIXME: onLoadList(); 原来的没有用了,这里还要吗 - onLoadList() + // TODO: onLoadList 原版如何触发 + // onLoadList() }" @scroll="onScroll" @refresherrefresh="() => { - // FIXME: onRefresherRefresh(); 原来的没有用了,这里还要吗 - onRefresherRefresh() + // TODO: onRefresherRefresh 原版如何触发 + // onRefresherRefresh() }" > { :style="{ height: locationBarHeight ? `${locationBarHeight}px` : 'auto' }" > + - {{ selectAddress?.street ?? '待完善' }} @@ -476,10 +476,10 @@ onShow(() => { - + - + @@ -525,6 +525,7 @@ onShow(() => {