提交 846b6fbb 编写于 作者: H hdx

long-list: 增加页面级下拉刷新,暂不支持页签下拉刷新

上级 48e993db
...@@ -832,7 +832,8 @@ ...@@ -832,7 +832,8 @@
{ {
"path": "pages/template/long-list/long-list", "path": "pages/template/long-list/long-list",
"style": { "style": {
"navigationBarTitleText": "复杂长列表" "navigationBarTitleText": "复杂长列表",
"enablePullDownRefresh": true
} }
}, },
{ {
......
...@@ -25,9 +25,10 @@ ...@@ -25,9 +25,10 @@
</view> </view>
</view> </view>
</list-item> </list-item>
<list-item key="loading" v-if="index==dataList.length-1"> <!-- TODO 暂时注释,否者在清空数据时引发异常 -->
<!-- <list-item v-if="index==dataList.length-1" key="loading">
<text class="loading">{{loadingText}}</text> <text class="loading">{{loadingText}}</text>
</list-item> </list-item> -->
</template> </template>
</list-view> </list-view>
</template> </template>
...@@ -83,7 +84,7 @@ ...@@ -83,7 +84,7 @@
} else { } else {
return "" return ""
} }
} },
}, },
created() { created() {
uni.loadFontFace({ uni.loadFontFace({
...@@ -97,6 +98,11 @@ ...@@ -97,6 +98,11 @@
} }
}, },
methods: { methods: {
refreshData() {
this.dataList.length = 0
this.$currentPage = 1
this.loadData()
},
loadData() { loadData() {
if (this.loading || this.isEnded) { if (this.loading || this.isEnded) {
return return
...@@ -129,6 +135,8 @@ ...@@ -129,6 +135,8 @@
}, },
complete: () => { complete: () => {
this.loading = false this.loading = false
// TODO
uni.stopPullDownRefresh()
} }
}) })
}, },
......
...@@ -97,6 +97,9 @@ ...@@ -97,6 +97,9 @@
this.cacheTabItemsSize() this.cacheTabItemsSize()
this.setSwiperIndex(0, true) this.setSwiperIndex(0, true)
}, },
onPullDownRefresh() {
(this.$refs["longPage"]! as ComponentPublicInstance[])[this.swiperIndex].$callMethod('refreshData')
},
methods: { methods: {
// TODO // TODO
onStartNestedScroll(event : StartNestedScrollEvent) : boolean { onStartNestedScroll(event : StartNestedScrollEvent) : boolean {
...@@ -105,15 +108,12 @@ ...@@ -105,15 +108,12 @@
onNestedPreScroll(event : NestedPreScrollEvent) { onNestedPreScroll(event : NestedPreScrollEvent) {
const deltaY = event.deltaY const deltaY = event.deltaY
const scrollTop = this.$pageScrollView!.scrollTop const scrollTop = this.$pageScrollView!.scrollTop
// console.log("deltaY=" + deltaY, "pageScrollTop=" + scrollTop)
/// 优先处理父容器滚动,父容器不能滚动时在滚动子 /// 优先处理父容器滚动,父容器不能滚动时在滚动子
// 向上滚动 // 向上滚动
if (deltaY > 0) { if (deltaY > 0) {
// 如果父容器 header scrollTop < offsetHeight,先滚动父容器 // 如果父容器 header scrollTop < offsetHeight,先滚动父容器
if (scrollTop < this.$headerHeight) { if (scrollTop < this.$headerHeight) {
// console.log('pageScrollTop=' + scrollTop)
const difference = this.$headerHeight - scrollTop - deltaY const difference = this.$headerHeight - scrollTop - deltaY
if (difference > 0) { if (difference > 0) {
this.$pageScrollView!.scrollBy(event.deltaX, deltaY) this.$pageScrollView!.scrollBy(event.deltaX, deltaY)
...@@ -163,7 +163,7 @@ ...@@ -163,7 +163,7 @@
this.updateTabIndicator(current_index, move_to_index, percentage) this.updateTabIndicator(current_index, move_to_index, percentage)
// 首次可见时初始化数据 // 首次可见时初始化数据
this.initSwiperItemPage(move_to_index) this.initSwiperItemData(move_to_index)
}, },
onSwiperAnimationfinish(e : SwiperAnimationFinishEvent) { onSwiperAnimationfinish(e : SwiperAnimationFinishEvent) {
this.setSwiperIndex(e.detail.current, true) this.setSwiperIndex(e.detail.current, true)
...@@ -186,7 +186,7 @@ ...@@ -186,7 +186,7 @@
this.swiperIndex = index this.swiperIndex = index
this.initSwiperItemPage(index) this.initSwiperItemData(index)
if (updateIndicator) { if (updateIndicator) {
this.updateTabIndicator(index, index, 1) this.updateTabIndicator(index, index, 1)
...@@ -207,7 +207,7 @@ ...@@ -207,7 +207,7 @@
const scroll_x = x - this.$swiperWidth / 2 const scroll_x = x - this.$swiperWidth / 2
this.$tabScrollView?.setAttribute('scrollLeft', scroll_x) this.$tabScrollView?.setAttribute('scrollLeft', scroll_x)
}, },
initSwiperItemPage(index : number) { initSwiperItemData(index : number) {
if (!this.swiperList[index].preload) { if (!this.swiperList[index].preload) {
this.swiperList[index].preload = true; this.swiperList[index].preload = true;
(this.$refs["longPage"]! as ComponentPublicInstance[])[index].$callMethod('loadData') (this.$refs["longPage"]! as ComponentPublicInstance[])[index].$callMethod('loadData')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册