Showing
2 changed files
with
69 additions
and
24 deletions
| @@ -3,6 +3,7 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' | @@ -3,6 +3,7 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' | ||
| 3 | import { WDMessageCenterMessageType } from '../../../model/InteractMessageModel' | 3 | import { WDMessageCenterMessageType } from '../../../model/InteractMessageModel' |
| 4 | import MinePageDatasModel from '../../../model/MinePageDatasModel' | 4 | import MinePageDatasModel from '../../../model/MinePageDatasModel' |
| 5 | import { MessageItem } from '../../../viewmodel/MessageItem' | 5 | import { MessageItem } from '../../../viewmodel/MessageItem' |
| 6 | +import { CustomPullToRefresh } from '../../reusable/CustomPullToRefresh' | ||
| 6 | import { CustomTitleUI } from '../../reusable/CustomTitleUI' | 7 | import { CustomTitleUI } from '../../reusable/CustomTitleUI' |
| 7 | import { MessageListItemUI } from './MessageListItemUI' | 8 | import { MessageListItemUI } from './MessageListItemUI' |
| 8 | 9 | ||
| @@ -11,6 +12,7 @@ const TAG = "MessageListUI" | @@ -11,6 +12,7 @@ const TAG = "MessageListUI" | ||
| 11 | @Component | 12 | @Component |
| 12 | export struct MessageListUI { | 13 | export struct MessageListUI { |
| 13 | @State msgData: MessageItem[] = [] | 14 | @State msgData: MessageItem[] = [] |
| 15 | + private scroller: Scroller = new Scroller(); | ||
| 14 | 16 | ||
| 15 | aboutToAppear() { | 17 | aboutToAppear() { |
| 16 | this.msgData = MinePageDatasModel.getMessageData() | 18 | this.msgData = MinePageDatasModel.getMessageData() |
| @@ -138,7 +140,27 @@ export struct MessageListUI { | @@ -138,7 +140,27 @@ export struct MessageListUI { | ||
| 138 | //标题栏目 | 140 | //标题栏目 |
| 139 | CustomTitleUI({ titleName: "消息" }) | 141 | CustomTitleUI({ titleName: "消息" }) |
| 140 | 142 | ||
| 141 | - List() { | 143 | + CustomPullToRefresh({ |
| 144 | + alldata:this.msgData, | ||
| 145 | + scroller:this.scroller, | ||
| 146 | + customList:()=>{ | ||
| 147 | + this.ListLayout() | ||
| 148 | + }, | ||
| 149 | + onRefresh:(resolve)=>{ | ||
| 150 | + | ||
| 151 | + if(resolve) resolve('刷新成功') | ||
| 152 | + }, | ||
| 153 | + onLoadMore:(resolve)=> { | ||
| 154 | + } | ||
| 155 | + }) | ||
| 156 | + } | ||
| 157 | + .backgroundColor($r('app.color.white')) | ||
| 158 | + .height('100%') | ||
| 159 | + .width('100%') | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + @Builder ListLayout(){ | ||
| 163 | + List({scroller: this.scroller}) { | ||
| 142 | ForEach(this.msgData, (item: MessageItem, index: number) => { | 164 | ForEach(this.msgData, (item: MessageItem, index: number) => { |
| 143 | ListItem() { | 165 | ListItem() { |
| 144 | MessageListItemUI({ item: item, index: index }) | 166 | MessageListItemUI({ item: item, index: index }) |
| @@ -169,14 +191,21 @@ export struct MessageListUI { | @@ -169,14 +191,21 @@ export struct MessageListUI { | ||
| 169 | }) | 191 | }) |
| 170 | } | 192 | } |
| 171 | } | 193 | } |
| 172 | - .backgroundColor($r('app.color.white')) | ||
| 173 | - .height('100%') | ||
| 174 | - .width('100%') | ||
| 175 | - } | 194 | + |
| 176 | 195 | ||
| 177 | sendEnterEvent(type:number){ | 196 | sendEnterEvent(type:number){ |
| 178 | MinePageDatasModel.sendEnterMessageData(type).then((value) => { | 197 | MinePageDatasModel.sendEnterMessageData(type).then((value) => { |
| 179 | - console.log(TAG, "消息已读") | 198 | + this.msgData.forEach((item) => { |
| 199 | + if (item.title == "预约消息" && type === 2) { | ||
| 200 | + if(item.unReadCount > 0){ | ||
| 201 | + item.unReadCount = 0 | ||
| 202 | + } | ||
| 203 | + }else if(item.title == "互动消息" && type === 1){ | ||
| 204 | + if(item.unReadCount > 0){ | ||
| 205 | + item.unReadCount = 0 | ||
| 206 | + } | ||
| 207 | + } | ||
| 208 | + }) | ||
| 180 | }).catch((err: Error) => { | 209 | }).catch((err: Error) => { |
| 181 | console.log(TAG, JSON.stringify(err)) | 210 | console.log(TAG, JSON.stringify(err)) |
| 182 | }) | 211 | }) |
| @@ -2,6 +2,7 @@ import { LazyDataSource, StringUtils } from 'wdKit/Index'; | @@ -2,6 +2,7 @@ import { LazyDataSource, StringUtils } from 'wdKit/Index'; | ||
| 2 | import { Remark, SubscribeMessageModel, | 2 | import { Remark, SubscribeMessageModel, |
| 3 | WDMessageCenterMessageType } from '../../../../model/InteractMessageModel'; | 3 | WDMessageCenterMessageType } from '../../../../model/InteractMessageModel'; |
| 4 | import MinePageDatasModel from '../../../../model/MinePageDatasModel'; | 4 | import MinePageDatasModel from '../../../../model/MinePageDatasModel'; |
| 5 | +import { CustomPullToRefresh } from '../../../reusable/CustomPullToRefresh'; | ||
| 5 | import { CustomTitleUI } from '../../../reusable/CustomTitleUI'; | 6 | import { CustomTitleUI } from '../../../reusable/CustomTitleUI'; |
| 6 | import { ListHasNoMoreDataUI } from '../../../reusable/ListHasNoMoreDataUI'; | 7 | import { ListHasNoMoreDataUI } from '../../../reusable/ListHasNoMoreDataUI'; |
| 7 | import { EmptyComponent } from '../../../view/EmptyComponent'; | 8 | import { EmptyComponent } from '../../../view/EmptyComponent'; |
| @@ -17,6 +18,7 @@ export struct SubscribeMessageComponent{ | @@ -17,6 +18,7 @@ export struct SubscribeMessageComponent{ | ||
| 17 | @State hasMore: boolean = true | 18 | @State hasMore: boolean = true |
| 18 | curPageNum: number = 1; | 19 | curPageNum: number = 1; |
| 19 | @State isGetRequest: boolean = false | 20 | @State isGetRequest: boolean = false |
| 21 | + private scroller: Scroller = new Scroller(); | ||
| 20 | 22 | ||
| 21 | aboutToAppear() { | 23 | aboutToAppear() { |
| 22 | this.getNewPageData() | 24 | this.getNewPageData() |
| @@ -32,19 +34,44 @@ export struct SubscribeMessageComponent{ | @@ -32,19 +34,44 @@ export struct SubscribeMessageComponent{ | ||
| 32 | .height('100%') | 34 | .height('100%') |
| 33 | .width('100%') | 35 | .width('100%') |
| 34 | } | 36 | } |
| 35 | - | ||
| 36 | } else { | 37 | } else { |
| 37 | - //刷新控件 TODO | ||
| 38 | - //List | ||
| 39 | - List() { | 38 | + CustomPullToRefresh({ |
| 39 | + alldata:this.data, | ||
| 40 | + scroller:this.scroller, | ||
| 41 | + customList:()=>{ | ||
| 42 | + this.ListLayout() | ||
| 43 | + }, | ||
| 44 | + onRefresh:(resolve)=>{ | ||
| 45 | + this.curPageNum = 1; | ||
| 46 | + this.hasMore = true | ||
| 47 | + this.isGetRequest = false | ||
| 48 | + this.data.clear() | ||
| 49 | + if (!this.isLoading) { | ||
| 50 | + this.getNewPageData() | ||
| 51 | + } | ||
| 52 | + if(resolve) resolve('刷新成功') | ||
| 53 | + }, | ||
| 54 | + onLoadMore:(resolve)=> { | ||
| 55 | + if (!this.isLoading) { | ||
| 56 | + //加载分页数据 | ||
| 57 | + this.getNewPageData() | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + }) | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + .backgroundColor($r('app.color.color_F9F9F9')) | ||
| 64 | + .height('100%') | ||
| 65 | + .width('100%') | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + @Builder ListLayout(){ | ||
| 69 | + List({scroller: this.scroller}) { | ||
| 40 | LazyForEach(this.data, (item: SubscribeMessageModel, index: number) => { | 70 | LazyForEach(this.data, (item: SubscribeMessageModel, index: number) => { |
| 41 | ListItem() { | 71 | ListItem() { |
| 42 | SubscribeListChildComponent({ item: item }) | 72 | SubscribeListChildComponent({ item: item }) |
| 43 | }.width('100%') | 73 | }.width('100%') |
| 44 | - .onClick(() => { | ||
| 45 | }) | 74 | }) |
| 46 | - }) | ||
| 47 | - | ||
| 48 | //没有更多数据 显示提示 | 75 | //没有更多数据 显示提示 |
| 49 | if (!this.hasMore) { | 76 | if (!this.hasMore) { |
| 50 | ListItem() { | 77 | ListItem() { |
| @@ -55,17 +82,6 @@ export struct SubscribeMessageComponent{ | @@ -55,17 +82,6 @@ export struct SubscribeMessageComponent{ | ||
| 55 | .cachedCount(4) | 82 | .cachedCount(4) |
| 56 | .scrollBar(BarState.Off) | 83 | .scrollBar(BarState.Off) |
| 57 | .layoutWeight(1) | 84 | .layoutWeight(1) |
| 58 | - .onReachEnd(() => { | ||
| 59 | - if (!this.isLoading) { | ||
| 60 | - //加载分页数据 | ||
| 61 | - this.getNewPageData() | ||
| 62 | - } | ||
| 63 | - }) | ||
| 64 | - } | ||
| 65 | - } | ||
| 66 | - .backgroundColor($r('app.color.color_F9F9F9')) | ||
| 67 | - .height('100%') | ||
| 68 | - .width('100%') | ||
| 69 | } | 85 | } |
| 70 | 86 | ||
| 71 | getNewPageData() { | 87 | getNewPageData() { |
-
Please register or login to post a comment