From ff31beac8f5ad65ddc0e31208c1f662968a65542 Mon Sep 17 00:00:00 2001 From: hdx Date: Thu, 24 Aug 2023 17:38:42 +0800 Subject: [PATCH] =?UTF-8?q?long-list:=20=E5=A2=9E=E5=8A=A0=20loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/template/long-list/long-list-page.uvue | 74 +++++++++++++------- pages/template/long-list/long-list.uvue | 19 ++--- 2 files changed, 54 insertions(+), 39 deletions(-) diff --git a/pages/template/long-list/long-list-page.uvue b/pages/template/long-list/long-list-page.uvue index 06fcabe6..167b564e 100644 --- a/pages/template/long-list/long-list-page.uvue +++ b/pages/template/long-list/long-list-page.uvue @@ -1,27 +1,33 @@ @@ -57,9 +63,23 @@ loading: false, dataList: [] as ListItem[], isEnded: false, + loadingError: '', $currentPage: 0 } }, + computed: { + loadingText() : string { + if (this.loading) { + return "加载中..." + } else if (this.isEnded) { + return "没有更多了" + } else if (this.loadingError.length > 0) { + return this.loadingError + } else { + return "" + } + } + }, mounted() { uni.loadFontFace({ global: false, @@ -105,7 +125,7 @@ } }, fail: (err) => { - console.log(err) + this.loadingError = err.errMsg }, complete: () => { this.loading = false @@ -128,10 +148,6 @@ if (nullStarCount > 0) { result += null_code.repeat(nullStarCount) } return result - }, - onScroll(e : ScrollEvent) { - // TODO e.detail.deltaY 值不正确 - this.$emit('pageScroll', e.detail.deltaY) } } } @@ -215,4 +231,10 @@ color: #008000; margin-left: auto; } + + .loading { + padding: 20px; + text-align: center; + background-color: #f8f8f8; + } \ No newline at end of file diff --git a/pages/template/long-list/long-list.uvue b/pages/template/long-list/long-list.uvue index 50351e1a..1d45b45f 100644 --- a/pages/template/long-list/long-list.uvue +++ b/pages/template/long-list/long-list.uvue @@ -10,7 +10,7 @@ {{item.name}} + :class="swiperIndex==index ? 'swiper-tabs-item-text-active' : ''">{{item.name}} @@ -22,7 +22,7 @@ - + @@ -120,17 +120,9 @@ //console.log(this.$lastSwiperIndex, moveToIndex, offsetX, this.$swiperWidth, percentage); }, onSwiperAnimationfinish(e : SwiperAnimationFinishEvent) { - this.$lastSwiperIndex = e.detail.current; // console.log("onSwiperAnimationfinish", e.detail.current); - // this.setSwiperIndex(e.detail.current, true); - }, - onSwiperItemPageScroll(dy : number) { - let top = this.pageScrollTop + dy - - if (top > this.$headerHeight) { top = this.$headerHeight } - if (top < 0) { top = 0 } - - this.pageScrollTop = top + this.$lastSwiperIndex = e.detail.current + this.setSwiperIndex(e.detail.current, true) }, queryTabItemsSize() { this.$swiperTabsRect.length = 0; @@ -186,7 +178,8 @@ } .swiper-list { - height: 100%; + flex: 1; + /* height: 100%; */ } .swiper-tabs { -- GitLab