diff --git a/pages.json b/pages.json index 25fb4aa17a1ad38e6a2764446008650377d8c05b..d5bc0b79a8a371217c2252a8234b079683856f39 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 ee534b59de75e4016a87ecebf841c99c29706470..25226c6403c6ca05c15bf9ef985573a6475739cb 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 67affc80f00bcff20e324d322970c88978bfe138..71c52ac97049b309fb09cb6892bde1fde72ecf57 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')