yanlu

jira: desc:人民号主页,下拉刷新

@@ -19,7 +19,6 @@ import { @@ -19,7 +19,6 @@ import {
19 struct PeopleShipHomePage { 19 struct PeopleShipHomePage {
20 // Todo 传入数据 后续在修改 20 // Todo 传入数据 后续在修改
21 creatorId: string = (router.getParams() as Record<string, string>)['creatorId']; 21 creatorId: string = (router.getParams() as Record<string, string>)['creatorId'];
22 - @State arr: number[] = []  
23 // 页面详情数据 22 // 页面详情数据
24 @Provide detailModel: PeopleShipUserDetailData = {} as PeopleShipUserDetailData 23 @Provide detailModel: PeopleShipUserDetailData = {} as PeopleShipUserDetailData
25 // 每个分类数量 24 // 每个分类数量
@@ -108,9 +107,12 @@ struct PeopleShipHomePage { @@ -108,9 +107,12 @@ struct PeopleShipHomePage {
108 Logger.debug('PeopleShipHomePage', '获取页面信息', `${JSON.stringify(this.detailModel)}`) 107 Logger.debug('PeopleShipHomePage', '获取页面信息', `${JSON.stringify(this.detailModel)}`)
109 108
110 // 获取关注 109 // 获取关注
111 - let followList: QueryListIsFollowedItem[] = await PeopleShipHomePageDataModel.getHomePageFollowListStatusData(this.creatorId)  
112 - Logger.debug('PeopleShipHomePage', '获取关注信息', `${JSON.stringify(followList)}`)  
113 - this.findFollowStata(followList) 110 + // 登录后获取,是否关注
  111 + if (HttpUrlUtils.getUserId()) {
  112 + let followList: QueryListIsFollowedItem[] = await PeopleShipHomePageDataModel.getHomePageFollowListStatusData(this.creatorId)
  113 + Logger.debug('PeopleShipHomePage', '获取关注信息', `${JSON.stringify(followList)}`)
  114 + this.findFollowStata(followList)
  115 + }
114 116
115 } catch (exception) { 117 } catch (exception) {
116 118
@@ -128,14 +130,17 @@ struct PeopleShipHomePage { @@ -128,14 +130,17 @@ struct PeopleShipHomePage {
128 } 130 }
129 131
130 handleChangeAttentionStata() { 132 handleChangeAttentionStata() {
  133 +
131 if (!this.isLoadingAttention) { 134 if (!this.isLoadingAttention) {
132 return 135 return
133 } 136 }
134 // 未登录,跳转登录 137 // 未登录,跳转登录
135 if (!HttpUrlUtils.getUserId()) { 138 if (!HttpUrlUtils.getUserId()) {
  139 + this.isLoadingAttention = false
136 WDRouterRule.jumpWithPage(WDRouterPage.loginPage) 140 WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
137 return 141 return
138 } 142 }
  143 +
139 let status = 0 144 let status = 0
140 if (this.isAttention == '0') { 145 if (this.isAttention == '0') {
141 status = 1 146 status = 1
@@ -20,24 +20,26 @@ import { RefreshLayoutBean } from '../page/RefreshLayoutBean' @@ -20,24 +20,26 @@ import { RefreshLayoutBean } from '../page/RefreshLayoutBean'
20 import CustomRefreshLoadLayout from '../page/CustomRefreshLoadLayout' 20 import CustomRefreshLoadLayout from '../page/CustomRefreshLoadLayout'
21 import { ErrorComponent } from '../view/ErrorComponent'; 21 import { ErrorComponent } from '../view/ErrorComponent';
22 import NoMoreLayout from '../page/NoMoreLayout'; 22 import NoMoreLayout from '../page/NoMoreLayout';
23 -import { LazyDataSource } from 'wdKit'; 23 +// import { LazyDataSource } from 'wdKit';
  24 +import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh'
24 25
25 const TAG = 'PeopleShipHomeArticleListComponent'; 26 const TAG = 'PeopleShipHomeArticleListComponent';
26 27
27 @Component 28 @Component
28 export struct PeopleShipHomeArticleListComponent { 29 export struct PeopleShipHomeArticleListComponent {
29 - // @State arr: ContentDTO[] = []  
30 - @State arr: LazyDataSource<ContentDTO> = new LazyDataSource(); 30 + @State arr: ContentDTO[] = []
  31 + // @State arr: LazyDataSource<ContentDTO> = new LazyDataSource();
31 @State typeModel: ArticleTypeData = new ArticleTypeData() 32 @State typeModel: ArticleTypeData = new ArticleTypeData()
32 @State creatorId: string = '' 33 @State creatorId: string = ''
33 @Consume detailModel: PeopleShipUserDetailData 34 @Consume detailModel: PeopleShipUserDetailData
34 - @State private viewType: number = 1;  
35 - currentIndex: number = 0 35 + @State private viewType: number = 1
  36 + currentIndex: number = 1
36 @Link @Watch('onChange') currentTopSelectedIndex: number 37 @Link @Watch('onChange') currentTopSelectedIndex: number
37 @State private hasMore: boolean = true 38 @State private hasMore: boolean = true
38 - @State currentPage: number = 1 39 + @State private currentPage: number = 1
39 @State private isLoading: boolean = false 40 @State private isLoading: boolean = false
40 @Consume topHeight: number 41 @Consume topHeight: number
  42 + private scroller: Scroller = new Scroller()
41 43
42 build() { 44 build() {
43 if (this.viewType == 1) { 45 if (this.viewType == 1) {
@@ -46,7 +48,34 @@ export struct PeopleShipHomeArticleListComponent { @@ -46,7 +48,34 @@ export struct PeopleShipHomeArticleListComponent {
46 } else if (this.viewType == 2) { 48 } else if (this.viewType == 2) {
47 ErrorComponent() 49 ErrorComponent()
48 } else { 50 } else {
49 - this.ListLayout() 51 + CustomPullToRefresh({
  52 + alldata:this.arr,
  53 + scroller:this.scroller,
  54 + hasMore: this.hasMore,
  55 + customList:()=>{
  56 + this.ListLayout()
  57 + },
  58 + onRefresh:(resolve)=>{
  59 + this.currentPage = 1
  60 + this.getPeopleShipPageArticleList(resolve)
  61 + },
  62 + onLoadMore:(resolve)=> {
  63 + if (this.hasMore === false) {
  64 + if(resolve) {
  65 + resolve('')
  66 + }
  67 + return
  68 + }
  69 + if(!this.isLoading && this.hasMore){
  70 + //加载分页数据
  71 + this.getPeopleShipPageArticleList(resolve)
  72 + }else {
  73 + if(resolve) {
  74 + resolve('')
  75 + }
  76 + }
  77 + },
  78 + })
50 } 79 }
51 80
52 } 81 }
@@ -62,10 +91,10 @@ export struct PeopleShipHomeArticleListComponent { @@ -62,10 +91,10 @@ export struct PeopleShipHomeArticleListComponent {
62 @Builder 91 @Builder
63 ListLayout() { 92 ListLayout() {
64 93
65 - List() { 94 + List({scroller: this.scroller}) {
66 // 下拉刷新 95 // 下拉刷新
67 96
68 - LazyForEach(this.arr, (item: ContentDTO) => { 97 + ForEach(this.arr, (item: ContentDTO) => {
69 ListItem() { 98 ListItem() {
70 CardParser({ contentDTO: item }) 99 CardParser({ contentDTO: item })
71 }.width("100%") 100 }.width("100%")
@@ -74,25 +103,25 @@ export struct PeopleShipHomeArticleListComponent { @@ -74,25 +103,25 @@ export struct PeopleShipHomeArticleListComponent {
74 103
75 // 加载更多 104 // 加载更多
76 ListItem() { 105 ListItem() {
77 - if (!this.hasMore) { 106 + if (!this.hasMore && !this.isLoading) {
78 NoMoreLayout() 107 NoMoreLayout()
79 } 108 }
80 } 109 }
81 } 110 }
82 .width("100%") 111 .width("100%")
83 .height("100%") 112 .height("100%")
84 - .edgeEffect(EdgeEffect.Spring) 113 + .edgeEffect(EdgeEffect.None)
85 .nestedScroll({ 114 .nestedScroll({
86 scrollForward: NestedScrollMode.PARENT_FIRST, 115 scrollForward: NestedScrollMode.PARENT_FIRST,
87 scrollBackward: NestedScrollMode.SELF_FIRST 116 scrollBackward: NestedScrollMode.SELF_FIRST
88 }) 117 })
89 118
90 - .onReachEnd(() => {  
91 - if(!this.isLoading && this.hasMore){  
92 - //加载分页数据  
93 - this.getPeopleShipPageArticleList()  
94 - }  
95 - }) 119 + // .onReachEnd(() => {
  120 + // if(!this.isLoading && this.hasMore){
  121 + // //加载分页数据
  122 + // this.getPeopleShipPageArticleList()
  123 + // }
  124 + // })
96 } 125 }
97 126
98 aboutToAppear() { 127 aboutToAppear() {
@@ -109,16 +138,28 @@ export struct PeopleShipHomeArticleListComponent { @@ -109,16 +138,28 @@ export struct PeopleShipHomeArticleListComponent {
109 } 138 }
110 } 139 }
111 140
112 - private async getPeopleShipPageArticleList() { 141 +
  142 + private async getPeopleShipPageArticleList(resolve?: (value: string | PromiseLike<string>) => void) {
113 Logger.info(`获取页面信息PeopleShipHomeArticleListComponent${this.typeModel.type}`) 143 Logger.info(`获取页面信息PeopleShipHomeArticleListComponent${this.typeModel.type}`)
114 if (this.isLoading) { 144 if (this.isLoading) {
  145 + if (resolve) {
  146 + resolve('')
  147 + }
115 return 148 return
116 } 149 }
117 try { 150 try {
118 this.isLoading = true 151 this.isLoading = true
119 let listData: ArticleListData = await PeopleShipHomePageDataModel.getPeopleShipHomePageArticleListData(this.creatorId, this.currentPage, 20, this.typeModel.type) 152 let listData: ArticleListData = await PeopleShipHomePageDataModel.getPeopleShipHomePageArticleListData(this.creatorId, this.currentPage, 20, this.typeModel.type)
120 Logger.debug(TAG, `获取页面信息, ${listData.list.length}`); 153 Logger.debug(TAG, `获取页面信息, ${listData.list.length}`);
  154 + Logger.debug(TAG, `已更新值最新, ${this.currentPage}`);
121 155
  156 + if (resolve ) {
  157 + if (this.currentPage == 1) {
  158 + resolve('已更新至最新')
  159 + }else {
  160 + resolve('')
  161 + }
  162 + }
122 if (listData && listData.list && listData.list.length > 0) { 163 if (listData && listData.list && listData.list.length > 0) {
123 this.viewType = 3; 164 this.viewType = 3;
124 if (listData.list.length === 20) { 165 if (listData.list.length === 20) {
@@ -130,15 +171,18 @@ export struct PeopleShipHomeArticleListComponent { @@ -130,15 +171,18 @@ export struct PeopleShipHomeArticleListComponent {
130 } else { 171 } else {
131 this.viewType = 1; 172 this.viewType = 1;
132 } 173 }
  174 + this.isLoading = false
133 this.queryArticleContentInteractCount(listData) 175 this.queryArticleContentInteractCount(listData)
134 - Logger.debug(TAG, '展示的总数', `${this.arr.totalCount()}`) 176 + Logger.debug(TAG, '展示的总数', `${this.arr.length}`)
135 }catch (exception) { 177 }catch (exception) {
  178 + if (resolve) {
  179 + resolve('')
  180 + }
136 this.isLoading = false 181 this.isLoading = false
137 - if (this.arr.totalCount() == 0) { 182 + if (this.arr.length == 0) {
138 this.viewType = 2 183 this.viewType = 2
139 } 184 }
140 } 185 }
141 -  
142 } 186 }
143 187
144 /** 188 /**
@@ -15,13 +15,13 @@ export struct PeopleShipHomePageHeadComponent { @@ -15,13 +15,13 @@ export struct PeopleShipHomePageHeadComponent {
15 .borderWidth('1vp') 15 .borderWidth('1vp')
16 .borderStyle(BorderStyle.Solid) 16 .borderStyle(BorderStyle.Solid)
17 .borderColor(Color.White) 17 .borderColor(Color.White)
18 - .objectFit(ImageFit.Auto) 18 + .objectFit(ImageFit.Cover)
19 if(this.authIcon.length > 0 ) { 19 if(this.authIcon.length > 0 ) {
20 Image( this.authIcon ) 20 Image( this.authIcon )
21 .width(this.iconDiameter) 21 .width(this.iconDiameter)
22 .height(this.iconDiameter) 22 .height(this.iconDiameter)
23 .borderRadius(this.iconDiameter/2) 23 .borderRadius(this.iconDiameter/2)
24 - .objectFit(ImageFit.Auto) 24 + .objectFit(ImageFit.Cover)
25 .margin({ 25 .margin({
26 right: '-3vp' 26 right: '-3vp'
27 }) 27 })
@@ -10,7 +10,7 @@ export struct CustomPullToRefresh { @@ -10,7 +10,7 @@ export struct CustomPullToRefresh {
10 onLoadMore: (resolve?: (value: string | PromiseLike<string>) => void) => void = () => { 10 onLoadMore: (resolve?: (value: string | PromiseLike<string>) => void) => void = () => {
11 } 11 }
12 ///是否存在上拉更多 12 ///是否存在上拉更多
13 - @State hasMore: boolean = true 13 + @Prop hasMore: boolean = true
14 refreshConfigurator: PullToRefreshConfigurator = new PullToRefreshConfigurator().setHasLoadMore(this.hasMore); 14 refreshConfigurator: PullToRefreshConfigurator = new PullToRefreshConfigurator().setHasLoadMore(this.hasMore);
15 build() { 15 build() {
16 Column(){ 16 Column(){