yanlu

fix: 17212 人民号作品列表在作品数量较少时上滑无反应

@@ -13,6 +13,7 @@ import { @@ -13,6 +13,7 @@ import {
13 PeopleShipUserDetailData, 13 PeopleShipUserDetailData,
14 ArticleCountData 14 ArticleCountData
15 } from 'wdBean' 15 } from 'wdBean'
  16 +import { EmptyComponent } from '../view/EmptyComponent'
16 17
17 @Entry 18 @Entry
18 @Component 19 @Component
@@ -35,11 +36,20 @@ struct PeopleShipHomePage { @@ -35,11 +36,20 @@ struct PeopleShipHomePage {
35 @Provide @Watch('handleChangeAttentionStata') isLoadingAttention: boolean = false 36 @Provide @Watch('handleChangeAttentionStata') isLoadingAttention: boolean = false
36 //关注显示 37 //关注显示
37 @State attentionOpacity: boolean = false 38 @State attentionOpacity: boolean = false
38 - @Provide topHeight: number = 400 39 + @Provide topHeight: number = 286
  40 + @State isLoading: boolean = true
39 41
40 build() { 42 build() {
41 -  
42 Stack({ alignContent: Alignment.TopStart }) { 43 Stack({ alignContent: Alignment.TopStart }) {
  44 + // 顶部图片
  45 + Image($r('app.media.home_page_bg'))
  46 + .width('100%')
  47 + .height('120vp')
  48 + .objectFit(ImageFit.Fill)
  49 + .backgroundColor(Color.White)
  50 + .visibility(this.isLoading ? Visibility.None : Visibility.Visible)
  51 +
  52 + Column(){
43 // 头部返回 53 // 头部返回
44 PeopleShipHomePageNavComponent({ 54 PeopleShipHomePageNavComponent({
45 attentionOpacity: this.attentionOpacity, 55 attentionOpacity: this.attentionOpacity,
@@ -47,9 +57,7 @@ struct PeopleShipHomePage { @@ -47,9 +57,7 @@ struct PeopleShipHomePage {
47 detailModel: this.detailModel 57 detailModel: this.detailModel
48 }) 58 })
49 .height($r('app.float.top_bar_height')) 59 .height($r('app.float.top_bar_height'))
50 - .zIndex(100)  
51 .backgroundColor(Color.Transparent) 60 .backgroundColor(Color.Transparent)
52 -  
53 if (this.detailModel && this.detailModel.userName) { 61 if (this.detailModel && this.detailModel.userName) {
54 Scroll(this.scroller) { 62 Scroll(this.scroller) {
55 Column() { 63 Column() {
@@ -62,24 +70,32 @@ struct PeopleShipHomePage { @@ -62,24 +70,32 @@ struct PeopleShipHomePage {
62 }) 70 })
63 .width("100%") 71 .width("100%")
64 .height(this.topHeight) 72 .height(this.topHeight)
65 -  
66 // 列表 73 // 列表
  74 + Column(){
67 PeopleShipHomeListComponent({ 75 PeopleShipHomeListComponent({
68 publishCount: this.publishCount, 76 publishCount: this.publishCount,
69 creatorId: this.creatorId 77 creatorId: this.creatorId
70 }) 78 })
  79 + }.height('100%')
  80 +
71 81
72 } 82 }
73 .width("100%") 83 .width("100%")
74 .justifyContent(FlexAlign.Start) 84 .justifyContent(FlexAlign.Start)
  85 + .alignItems(HorizontalAlign.Start)
  86 + // .height('100%')
75 // .height(this.publishCount == 0 ? '100%' : '') 87 // .height(this.publishCount == 0 ? '100%' : '')
76 } 88 }
  89 + .scrollable(ScrollDirection.Vertical)
  90 + // .alignSelf(ItemAlign.Start)
  91 + // .align(Alignment.Start)
77 .edgeEffect(EdgeEffect.None) 92 .edgeEffect(EdgeEffect.None)
78 - .friction(0.6) 93 + .friction(0.7)
79 .backgroundColor(Color.White) 94 .backgroundColor(Color.White)
80 .scrollBar(BarState.Off) 95 .scrollBar(BarState.Off)
81 .width('100%') 96 .width('100%')
82 - .height('100%') 97 + .height('calc(100% - 44vp)')
  98 + // .layoutWeight(1)
83 .onDidScroll(() => { 99 .onDidScroll(() => {
84 // this.topOpacity = yOffset / (this.getDeviceHeight() * 0.2) 100 // this.topOpacity = yOffset / (this.getDeviceHeight() * 0.2)
85 this.topOpacity = this.scroller.currentOffset().yOffset / 100 101 this.topOpacity = this.scroller.currentOffset().yOffset / 100
@@ -94,6 +110,13 @@ struct PeopleShipHomePage { @@ -94,6 +110,13 @@ struct PeopleShipHomePage {
94 } 110 }
95 111
96 } 112 }
  113 + .alignItems(HorizontalAlign.Start)
  114 + .justifyContent(FlexAlign.Start)
  115 + .width('100%')
  116 + // .height('100%')
  117 + }
  118 + // .height('100%')
  119 + .width('100%')
97 120
98 } 121 }
99 122
@@ -104,9 +127,11 @@ struct PeopleShipHomePage { @@ -104,9 +127,11 @@ struct PeopleShipHomePage {
104 127
105 private async getData() { 128 private async getData() {
106 try { 129 try {
  130 + this.isLoading = true
107 // 获取页面信息 131 // 获取页面信息
108 this.detailModel = await PeopleShipHomePageDataModel.getPeopleShipHomePageDetailInfo(this.creatorId, '', '') 132 this.detailModel = await PeopleShipHomePageDataModel.getPeopleShipHomePageDetailInfo(this.creatorId, '', '')
109 Logger.debug('PeopleShipHomePage', '获取页面信息' + `${JSON.stringify(this.detailModel)}`) 133 Logger.debug('PeopleShipHomePage', '获取页面信息' + `${JSON.stringify(this.detailModel)}`)
  134 + this.isLoading = false
110 135
111 // 获取关注 136 // 获取关注
112 // 登录后获取,是否关注 137 // 登录后获取,是否关注
@@ -117,7 +142,7 @@ struct PeopleShipHomePage { @@ -117,7 +142,7 @@ struct PeopleShipHomePage {
117 } 142 }
118 143
119 } catch (exception) { 144 } catch (exception) {
120 - 145 + this.isLoading = false
121 } 146 }
122 } 147 }
123 148
1 -import { Logger, DisplayUtils} from 'wdKit' 1 +import { Logger} from 'wdKit'
2 import { PeopleShipHomePageDataModel } from '../../viewmodel/PeopleShipHomePageDataModel' 2 import { PeopleShipHomePageDataModel } from '../../viewmodel/PeopleShipHomePageDataModel'
3 import { 3 import {
4 ContentDTO, 4 ContentDTO,
@@ -16,11 +16,11 @@ import { @@ -16,11 +16,11 @@ import {
16 } from 'wdBean' 16 } from 'wdBean'
17 import { CardParser } from '../CardParser' 17 import { CardParser } from '../CardParser'
18 import { PageRepository } from '../../repository/PageRepository' 18 import { PageRepository } from '../../repository/PageRepository'
19 -import { RefreshLayoutBean } from '../page/RefreshLayoutBean'  
20 import CustomRefreshLoadLayout from '../page/CustomRefreshLoadLayout' 19 import CustomRefreshLoadLayout from '../page/CustomRefreshLoadLayout'
21 import { ErrorComponent } from '../view/ErrorComponent' 20 import { ErrorComponent } from '../view/ErrorComponent'
22 import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh' 21 import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh'
23 import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData' 22 import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData'
  23 +import LoadMoreLayout from '../page/LoadMoreLayout'
24 24
25 const TAG = 'PeopleShipHomeArticleListComponent'; 25 const TAG = 'PeopleShipHomeArticleListComponent';
26 26
@@ -47,45 +47,29 @@ export struct PeopleShipHomeArticleListComponent { @@ -47,45 +47,29 @@ export struct PeopleShipHomeArticleListComponent {
47 } else if (this.viewType == 2) { 47 } else if (this.viewType == 2) {
48 ErrorComponent() 48 ErrorComponent()
49 } else { 49 } else {
50 - CustomPullToRefresh({  
51 - alldata:this.arr,  
52 - scroller:this.scroller,  
53 - hasMore: this.hasMore,  
54 - customList:()=>{  
55 this.ListLayout() 50 this.ListLayout()
56 - },  
57 - onRefresh:(resolve)=>{  
58 - this.currentPage = 1  
59 - this.getPeopleShipPageArticleList(resolve)  
60 - },  
61 - onLoadMore:(resolve)=> {  
62 - if (this.hasMore === false) {  
63 - if(resolve) {  
64 - resolve('')  
65 - }  
66 - return  
67 - }  
68 - if(!this.isLoading && this.hasMore){  
69 - //加载分页数据  
70 - this.currentPage++;  
71 - this.getPeopleShipPageArticleList(resolve)  
72 - }else {  
73 - if(resolve) {  
74 - resolve('')  
75 - }  
76 - }  
77 - },  
78 - }) 51 + // CustomPullToRefresh({
  52 + // alldata:this.arr,
  53 + // scroller:this.scroller,
  54 + // hasMore: false,
  55 + // customList:()=>{
  56 + // this.ListLayout()
  57 + // },
  58 + // onRefresh:(resolve)=>{
  59 + // this.currentPage = 1
  60 + // this.getPeopleShipPageArticleList(resolve)
  61 + // },
  62 + // })
79 } 63 }
80 64
81 } 65 }
82 66
83 @Builder 67 @Builder
84 LoadingLayout() { 68 LoadingLayout() {
85 - CustomRefreshLoadLayout({  
86 - refreshBean: new RefreshLayoutBean(true,  
87 - $r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), 20)  
88 - }).height(DisplayUtils.getDeviceHeight() - this.topHeight) 69 + // CustomRefreshLoadLayout({
  70 + // refreshBean: new RefreshLayoutBean(true,
  71 + // $r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), 20)
  72 + // }).height(DisplayUtils.getDeviceHeight() - this.topHeight)
89 } 73 }
90 74
91 @Builder 75 @Builder
@@ -93,7 +77,6 @@ export struct PeopleShipHomeArticleListComponent { @@ -93,7 +77,6 @@ export struct PeopleShipHomeArticleListComponent {
93 77
94 List({scroller: this.scroller}) { 78 List({scroller: this.scroller}) {
95 // 下拉刷新 79 // 下拉刷新
96 -  
97 ForEach(this.arr, (item: ContentDTO) => { 80 ForEach(this.arr, (item: ContentDTO) => {
98 ListItem() { 81 ListItem() {
99 CardParser({ contentDTO: item }) 82 CardParser({ contentDTO: item })
@@ -103,11 +86,14 @@ export struct PeopleShipHomeArticleListComponent { @@ -103,11 +86,14 @@ export struct PeopleShipHomeArticleListComponent {
103 86
104 // 加载更多 87 // 加载更多
105 ListItem() { 88 ListItem() {
106 - if (!this.hasMore && !this.isLoading) { 89 + if (this.hasMore) {
  90 + LoadMoreLayout({ isVisible: this.hasMore })
  91 + } else if (!this.hasMore && !this.isLoading) {
107 PeopleShipNoMoreData() 92 PeopleShipNoMoreData()
108 } 93 }
109 } 94 }
110 } 95 }
  96 + .backgroundColor(Color.Transparent)
111 .width("100%") 97 .width("100%")
112 .height("100%") 98 .height("100%")
113 .edgeEffect(EdgeEffect.None) 99 .edgeEffect(EdgeEffect.None)
@@ -115,13 +101,13 @@ export struct PeopleShipHomeArticleListComponent { @@ -115,13 +101,13 @@ export struct PeopleShipHomeArticleListComponent {
115 scrollForward: NestedScrollMode.PARENT_FIRST, 101 scrollForward: NestedScrollMode.PARENT_FIRST,
116 scrollBackward: NestedScrollMode.SELF_FIRST 102 scrollBackward: NestedScrollMode.SELF_FIRST
117 }) 103 })
118 -  
119 - // .onReachEnd(() => {  
120 - // if(!this.isLoading && this.hasMore){  
121 - // //加载分页数据  
122 - // this.getPeopleShipPageArticleList()  
123 - // }  
124 - // }) 104 + .onReachEnd(() => {
  105 + if(!this.isLoading && this.hasMore){
  106 + //加载分页数据
  107 + this.currentPage++;
  108 + this.getPeopleShipPageArticleList()
  109 + }
  110 + })
125 } 111 }
126 112
127 aboutToAppear() { 113 aboutToAppear() {
@@ -313,7 +299,6 @@ export struct PeopleShipHomeArticleListComponent { @@ -313,7 +299,6 @@ export struct PeopleShipHomeArticleListComponent {
313 } 299 }
314 300
315 } 301 }
316 -  
317 // this.arr = listData.list 302 // this.arr = listData.list
318 } 303 }
319 304
@@ -24,10 +24,10 @@ export struct PeopleShipHomeListComponent { @@ -24,10 +24,10 @@ export struct PeopleShipHomeListComponent {
24 // 列表 24 // 列表
25 else if (this.publishCount == 0) { 25 else if (this.publishCount == 0) {
26 // 无数据展示 26 // 无数据展示
27 - EmptyComponent({emptyType: 12}).height(DisplayUtils.getDeviceHeight() - this.topHeight) 27 + EmptyComponent({emptyType: 12}).height('100%')
28 } else { 28 } else {
29 Column() { 29 Column() {
30 - Column() { 30 + Stack({ alignContent: Alignment.Top }){
31 // 页签 31 // 页签
32 Row() { 32 Row() {
33 Scroll() { 33 Scroll() {
@@ -44,13 +44,10 @@ export struct PeopleShipHomeListComponent { @@ -44,13 +44,10 @@ export struct PeopleShipHomeListComponent {
44 .scrollBar(BarState.Off) 44 .scrollBar(BarState.Off)
45 .width('100%') 45 .width('100%')
46 } 46 }
  47 + .zIndex(10)
47 .backgroundColor(Color.White) 48 .backgroundColor(Color.White)
48 - .alignItems(VerticalAlign.Bottom)  
49 - .width('100%')  
50 - }  
51 - .justifyContent(FlexAlign.Start)  
52 .height('44vp') 49 .height('44vp')
53 - .alignItems(HorizontalAlign.Start) 50 + .alignItems(VerticalAlign.Bottom)
54 .width('100%') 51 .width('100%')
55 52
56 Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { 53 Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
@@ -63,15 +60,15 @@ export struct PeopleShipHomeListComponent { @@ -63,15 +60,15 @@ export struct PeopleShipHomeListComponent {
63 currentIndex: index 60 currentIndex: index
64 }) 61 })
65 } 62 }
66 - // }.tabBar(this.tabBuilder(index, item.name ?? '')) 63 + // .tabBar(this.Tab(index, item.name ?? ''))
67 }) 64 })
68 65
69 } 66 }
70 .backgroundColor(Color.White) 67 .backgroundColor(Color.White)
71 .barWidth('100%') 68 .barWidth('100%')
72 - .barHeight(0)  
73 .vertical(false) 69 .vertical(false)
74 - .height(DisplayUtils.getDeviceHeight() - 144) 70 + .barHeight('44vp')
  71 + .height('100% ')
75 .animationDuration(0) 72 .animationDuration(0)
76 .divider({ 73 .divider({
77 strokeWidth: '0.5vp', 74 strokeWidth: '0.5vp',
@@ -82,16 +79,19 @@ export struct PeopleShipHomeListComponent { @@ -82,16 +79,19 @@ export struct PeopleShipHomeListComponent {
82 .onChange((index: number) => { 79 .onChange((index: number) => {
83 this.currentIndex = index 80 this.currentIndex = index
84 }) 81 })
  82 +
  83 + }
  84 +
85 } 85 }
86 } 86 }
87 } 87 }
88 88
89 @Builder 89 @Builder
90 LoadingLayout() { 90 LoadingLayout() {
91 - CustomRefreshLoadLayout({  
92 - refreshBean: new RefreshLayoutBean(true,  
93 - $r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), DisplayUtils.getDeviceHeight() - this.topHeight)  
94 - }).height(DisplayUtils.getDeviceHeight() - this.topHeight) 91 + // CustomRefreshLoadLayout({
  92 + // refreshBean: new RefreshLayoutBean(true,
  93 + // $r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), DisplayUtils.getDeviceHeight() - this.topHeight)
  94 + // }).height('100%')
95 } 95 }
96 96
97 // 单独的页签 97 // 单独的页签