Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
1d00ceac
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
1d00ceac
编写于
11月 21, 2024
作者:
H
hdx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
long-list: 适配微信
上级
ccb9fdfe
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
15 deletion
+25
-15
pages/template/long-list/long-list-page.uvue
pages/template/long-list/long-list-page.uvue
+1
-1
pages/template/long-list/long-list.uvue
pages/template/long-list/long-list.uvue
+24
-14
未找到文件。
pages/template/long-list/long-list-page.uvue
浏览文件 @
1d00ceac
<template>
<template>
<list-view
ref="listView"
:id=id class="list" :rebound="false" :scroll-y="true" :custom-nested-scroll="true"
<list-view :id=id class="list" :rebound="false" :scroll-y="true" :custom-nested-scroll="true"
@scrolltolower="loadData(null)" associative-container="nested-scroll-view">
@scrolltolower="loadData(null)" associative-container="nested-scroll-view">
<list-item class="list-item" v-for="(item, _) in dataList" :key="item.plugin_id" type="10">
<list-item class="list-item" v-for="(item, _) in dataList" :key="item.plugin_id" type="10">
<view class="list-item-icon">
<view class="list-item-icon">
...
...
pages/template/long-list/long-list.uvue
浏览文件 @
1d00ceac
...
@@ -91,11 +91,14 @@
...
@@ -91,11 +91,14 @@
onReady() {
onReady() {
this.pageScrollView = this.$refs['pageScrollView'] as UniElement;
this.pageScrollView = this.$refs['pageScrollView'] as UniElement;
this.headerHeight = (this.$refs['header'] as UniElement).offsetHeight
this.headerHeight = (this.$refs['header'] as UniElement).offsetHeight
this.swiperWidth = (this.$refs['swiper'] as UniElement).getBoundingClientRect().width
this.tabScrollView = this.$refs['tabScroll'] as UniElement
this.tabScrollView = this.$refs['tabScroll'] as UniElement
this.indicatorNode = this.$refs['indicator'] as UniElement
this.indicatorNode = this.$refs['indicator'] as UniElement
this.cacheTabItemsSize()
(this.$refs["swiper"] as UniElement).getBoundingClientRectAsync().then((res : DOMRect) : Promise<void> => {
this.updateTabIndicator(this.swiperIndex, this.swiperIndex, 1)
this.swiperWidth = res.width
return this.cacheTabItemsSize()
}).then(() => {
this.updateTabIndicator(this.swiperIndex, this.swiperIndex, 1)
});
},
},
onPullDownRefresh() {
onPullDownRefresh() {
(this.$refs["longPage"]! as ComponentPublicInstance[])[this.swiperIndex].$callMethod('refreshData', () => {
(this.$refs["longPage"]! as ComponentPublicInstance[])[this.swiperIndex].$callMethod('refreshData', () => {
...
@@ -170,17 +173,18 @@
...
@@ -170,17 +173,18 @@
onSwiperAnimationfinish(e : SwiperAnimationFinishEvent) {
onSwiperAnimationfinish(e : SwiperAnimationFinishEvent) {
this.setSwiperIndex(e.detail.current, true)
this.setSwiperIndex(e.detail.current, true)
this.animationFinishIndex = e.detail.current
this.animationFinishIndex = e.detail.current
console.log('this.animationFinishIndex', e.detail.current);
},
},
cacheTabItemsSize() {
async
cacheTabItemsSize() {
this.swiperTabsRect.length = 0
this.swiperTabsRect.length = 0
;
const tabs = this.$refs["swipertab"] as UniElement[]
const tabs = this.$refs["swipertab"] as UniElement[]
tabs.forEach((node) => {
for (let i = 0; i < tabs.length; i++) {
const element = tabs[i];
const rect = await element.getBoundingClientRectAsync()
this.swiperTabsRect.push({
this.swiperTabsRect.push({
x:
node.offsetL
eft,
x:
rect.l
eft,
w:
node.offsetW
idth
w:
rect.w
idth
} as SwiperTabsItem)
} as SwiperTabsItem)
}
)
}
},
},
setSwiperIndex(index : number, updateIndicator : boolean) {
setSwiperIndex(index : number, updateIndicator : boolean) {
if (this.swiperIndex === index) {
if (this.swiperIndex === index) {
...
@@ -204,7 +208,7 @@
...
@@ -204,7 +208,7 @@
const indicator_line_w = lerpNumber(current_size.w, move_to_size.w, percentage)
const indicator_line_w = lerpNumber(current_size.w, move_to_size.w, percentage)
// 更新指示线
// 更新指示线
// #ifdef APP
// #ifdef APP
|| MP
const x = indicator_line_x + indicator_line_w / 2
const x = indicator_line_x + indicator_line_w / 2
this.indicatorNode?.style?.setProperty('transform', `translateX(${x}px) scaleX(${indicator_line_w})`)
this.indicatorNode?.style?.setProperty('transform', `translateX(${x}px) scaleX(${indicator_line_w})`)
// #endif
// #endif
...
@@ -217,9 +221,15 @@
...
@@ -217,9 +221,15 @@
// 滚动到水平中心位置
// 滚动到水平中心位置
const scroll_x = x - this.swiperWidth / 2
const scroll_x = x - this.swiperWidth / 2
if(this.tabScrollView != null){
// app 平台后续支持 scrollTo()
this.tabScrollView!.scrollLeft = scroll_x
// #ifndef MP-WEIXIN
}
this.tabScrollView!.scrollLeft = scroll_x
// #endif
// #ifdef MP-WEIXIN
this.tabScrollView!.scrollTo({
left: scroll_x
})
// #endif
},
},
initSwiperItemData(index : number) {
initSwiperItemData(index : number) {
if (!this.swiperList[index].preload) {
if (!this.swiperList[index].preload) {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录