From a377db115ca44fa9bbaafbba4e11c4cf204c7bdc Mon Sep 17 00:00:00 2001 From: hdx Date: Tue, 5 Sep 2023 19:01:59 +0800 Subject: [PATCH] long-list: TODO add loading --- pages/template/long-list/long-list-page.uvue | 111 +++++++++++-------- pages/template/long-list/long-list.uvue | 8 +- 2 files changed, 71 insertions(+), 48 deletions(-) diff --git a/pages/template/long-list/long-list-page.uvue b/pages/template/long-list/long-list-page.uvue index 63e2334a..c6ef10ae 100644 --- a/pages/template/long-list/long-list-page.uvue +++ b/pages/template/long-list/long-list-page.uvue @@ -1,35 +1,32 @@ @@ -87,21 +84,32 @@ }, }, created() { - // TODO 后续通过css加载本地路径 - uni.loadFontFace({ - global: false, - family: 'UtsIconsFontFamily', - source: '/static/fonts/icon-star.ttf' - }) + this.insertLoadingData() if (this.preload) { this.loadData(null) } }, methods: { + // TODO 目前 list-item 不支持注释节点 + // 暂时在数据末尾插入一条空数据用于显示 loading + insertLoadingData() { + const loadingData = { + plugin_id: -1, + plugin_img_link: '', + plugin_name: '', + plugin_intro: '', + score: 0, + tags: [], + update_date: '', + author_name: '', + } as ListItem + this.dataList.push(loadingData) + }, refreshData(loadComplete : (() => void) | null) { this.dataList.length = 0 this.$currentPage = 1 + this.insertLoadingData() this.loadData(loadComplete) }, loadData(loadComplete : (() => void) | null) { @@ -123,7 +131,9 @@ return } - this.dataList.push(...responseData.data) + // TODO + this.dataList.splice(this.dataList.length - 1, 0, ...responseData.data) + // this.dataList.push(...responseData.data) if (responseData.data.length == 0) { this.isEnded = true @@ -164,12 +174,11 @@ + \ 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 1af15922..7dd17a8b 100644 --- a/pages/template/long-list/long-list.uvue +++ b/pages/template/long-list/long-list.uvue @@ -111,7 +111,7 @@ const deltaY = event.deltaY const scrollTop = this.$pageScrollView!.scrollTop - /// 优先处理父容器滚动,父容器不能滚动时在滚动子 + /// 优先处理父容器滚动,父容器不能滚动时滚动子 // 向上滚动 if (deltaY > 0) { // 如果父容器 header scrollTop < offsetHeight,先滚动父容器 @@ -220,6 +220,12 @@