From 846b6fbb15ce1bd9afdf7b342f3f7f050c35d32e Mon Sep 17 00:00:00 2001 From: hdx Date: Mon, 4 Sep 2023 15:42:04 +0800 Subject: [PATCH] =?UTF-8?q?long-list:=20=E5=A2=9E=E5=8A=A0=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=BA=A7=E4=B8=8B=E6=8B=89=E5=88=B7=E6=96=B0=EF=BC=8C?= =?UTF-8?q?=E6=9A=82=E4=B8=8D=E6=94=AF=E6=8C=81=E9=A1=B5=E7=AD=BE=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 3 ++- pages/template/long-list/long-list-page.uvue | 14 +++++++++++--- pages/template/long-list/long-list.uvue | 12 ++++++------ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/pages.json b/pages.json index 25fb4aa1..d5bc0b79 100644 --- a/pages.json +++ b/pages.json @@ -832,7 +832,8 @@ { "path": "pages/template/long-list/long-list", "style": { - "navigationBarTitleText": "复杂长列表" + "navigationBarTitleText": "复杂长列表", + "enablePullDownRefresh": true } }, { diff --git a/pages/template/long-list/long-list-page.uvue b/pages/template/long-list/long-list-page.uvue index ee534b59..25226c64 100644 --- a/pages/template/long-list/long-list-page.uvue +++ b/pages/template/long-list/long-list-page.uvue @@ -25,9 +25,10 @@ - + + @@ -83,7 +84,7 @@ } else { return "" } - } + }, }, created() { uni.loadFontFace({ @@ -97,6 +98,11 @@ } }, methods: { + refreshData() { + this.dataList.length = 0 + this.$currentPage = 1 + this.loadData() + }, loadData() { if (this.loading || this.isEnded) { return @@ -129,6 +135,8 @@ }, complete: () => { this.loading = false + // TODO + uni.stopPullDownRefresh() } }) }, diff --git a/pages/template/long-list/long-list.uvue b/pages/template/long-list/long-list.uvue index 67affc80..71c52ac9 100644 --- a/pages/template/long-list/long-list.uvue +++ b/pages/template/long-list/long-list.uvue @@ -97,6 +97,9 @@ this.cacheTabItemsSize() this.setSwiperIndex(0, true) }, + onPullDownRefresh() { + (this.$refs["longPage"]! as ComponentPublicInstance[])[this.swiperIndex].$callMethod('refreshData') + }, methods: { // TODO onStartNestedScroll(event : StartNestedScrollEvent) : boolean { @@ -105,15 +108,12 @@ onNestedPreScroll(event : NestedPreScrollEvent) { const deltaY = event.deltaY const scrollTop = this.$pageScrollView!.scrollTop - // console.log("deltaY=" + deltaY, "pageScrollTop=" + scrollTop) /// 优先处理父容器滚动,父容器不能滚动时在滚动子 - // 向上滚动 if (deltaY > 0) { // 如果父容器 header scrollTop < offsetHeight,先滚动父容器 if (scrollTop < this.$headerHeight) { - // console.log('pageScrollTop=' + scrollTop) const difference = this.$headerHeight - scrollTop - deltaY if (difference > 0) { this.$pageScrollView!.scrollBy(event.deltaX, deltaY) @@ -163,7 +163,7 @@ this.updateTabIndicator(current_index, move_to_index, percentage) // 首次可见时初始化数据 - this.initSwiperItemPage(move_to_index) + this.initSwiperItemData(move_to_index) }, onSwiperAnimationfinish(e : SwiperAnimationFinishEvent) { this.setSwiperIndex(e.detail.current, true) @@ -186,7 +186,7 @@ this.swiperIndex = index - this.initSwiperItemPage(index) + this.initSwiperItemData(index) if (updateIndicator) { this.updateTabIndicator(index, index, 1) @@ -207,7 +207,7 @@ const scroll_x = x - this.$swiperWidth / 2 this.$tabScrollView?.setAttribute('scrollLeft', scroll_x) }, - initSwiperItemPage(index : number) { + initSwiperItemData(index : number) { if (!this.swiperList[index].preload) { this.swiperList[index].preload = true; (this.$refs["longPage"]! as ComponentPublicInstance[])[index].$callMethod('loadData') -- GitLab