Showing
5 changed files
with
145 additions
and
99 deletions
| 1 | -import { PeopleShipAttentionContentListTopComponent } from './PeopleShipAttentionContentListTopComponent' | ||
| 2 | -import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem'; | ||
| 3 | -import { ContentDTO } from 'wdBean' | ||
| 4 | -import { CardParser } from '../CardParser' | ||
| 5 | - | ||
| 6 | -@Preview | ||
| 7 | -@Component | ||
| 8 | -export struct PeopleShipAttentionContentListComponent { | ||
| 9 | - | ||
| 10 | - @Prop followList: FollowListDetailItem[] | ||
| 11 | - | ||
| 12 | - @Prop attentionList: ContentDTO[] | ||
| 13 | - | ||
| 14 | - build() { | ||
| 15 | - List(){ | ||
| 16 | - // 头部关注列表 | ||
| 17 | - ListItem(){ | ||
| 18 | - PeopleShipAttentionContentListTopComponent({ | ||
| 19 | - followList: this.followList | ||
| 20 | - }) | ||
| 21 | - } | ||
| 22 | - ForEach(this.attentionList, (item: ContentDTO) => { | ||
| 23 | - ListItem() { | ||
| 24 | - CardParser({ contentDTO: item }) | ||
| 25 | - }.width("100%") | ||
| 26 | - .backgroundColor(Color.Transparent) | ||
| 27 | - | ||
| 28 | - }, (item: ContentDTO, index: number) => item.objectId + index.toString()) | ||
| 29 | - } | ||
| 30 | - .scrollBar(BarState.Off) | ||
| 31 | - .width('100%') | ||
| 32 | - .height('100%') | ||
| 33 | - } | ||
| 34 | -} | ||
| 35 | - |
| 1 | +import { PeopleShipHomePageHeadComponent } from '../peopleShipHomePage/PeopleShipHomePageHeadComponent' | ||
| 2 | +import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem'; | ||
| 3 | + | ||
| 4 | +@Component | ||
| 5 | +export struct PeopleShipAttentionContentListHeadComponent { | ||
| 6 | + | ||
| 7 | + @State index: number = 0 | ||
| 8 | + @ObjectLink item: FollowListDetailItem | ||
| 9 | + build() { | ||
| 10 | + Column(){ | ||
| 11 | + // 头像 | ||
| 12 | + PeopleShipHomePageHeadComponent({ | ||
| 13 | + diameter: 48, | ||
| 14 | + iconDiameter: 16, | ||
| 15 | + headPhotoUrl: this.index == 0 ? $r('app.media.attention_mine') : | ||
| 16 | + ((this.item.attentionHeadPhotoUrl && this.item.attentionHeadPhotoUrl.length > 0) ? | ||
| 17 | + this.item.attentionHeadPhotoUrl : $r('app.media.WDAccountOwnerHedaerDefaultIcon')), | ||
| 18 | + authIcon: this.index == 0 ? '' : this.item.authIcon | ||
| 19 | + }).margin({ | ||
| 20 | + bottom: '8vp' | ||
| 21 | + }) | ||
| 22 | + | ||
| 23 | + Text(this.index == 0 ? '我的关注' : this.item.attentionUserName) | ||
| 24 | + .fontColor($r('app.color.color_666666')) | ||
| 25 | + .fontSize($r('app.float.vp_13')) | ||
| 26 | + .fontWeight(400) | ||
| 27 | + .height('18vp') | ||
| 28 | + .lineHeight('18vp') | ||
| 29 | + .maxLines(1) | ||
| 30 | + .textOverflow({overflow: TextOverflow.Ellipsis}) | ||
| 31 | + .padding({ | ||
| 32 | + left: '2vp', | ||
| 33 | + right: '2vp' | ||
| 34 | + }) | ||
| 35 | + } | ||
| 36 | + .alignItems(HorizontalAlign.Center) | ||
| 37 | + .width('78vp') | ||
| 38 | + .margin({ | ||
| 39 | + left: this.index == 0 ? '8vp' : '4vp', | ||
| 40 | + top: '14vp', | ||
| 41 | + bottom: '14vp' | ||
| 42 | + }) | ||
| 43 | + } | ||
| 44 | +} | ||
| 45 | + |
| 1 | import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem'; | 1 | import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem'; |
| 2 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' | 2 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' |
| 3 | import { ProcessUtils } from 'wdRouter'; | 3 | import { ProcessUtils } from 'wdRouter'; |
| 4 | -import { PeopleShipHomePageHeadComponent } from '../peopleShipHomePage/PeopleShipHomePageHeadComponent' | ||
| 5 | - | 4 | +import { PeopleShipAttentionContentListHeadComponent } from './PeopleShipAttentionContentListHeadComponent' |
| 6 | 5 | ||
| 7 | @Component | 6 | @Component |
| 8 | export struct PeopleShipAttentionContentListTopComponent { | 7 | export struct PeopleShipAttentionContentListTopComponent { |
| @@ -41,45 +40,3 @@ export struct PeopleShipAttentionContentListTopComponent { | @@ -41,45 +40,3 @@ export struct PeopleShipAttentionContentListTopComponent { | ||
| 41 | } | 40 | } |
| 42 | } | 41 | } |
| 43 | } | 42 | } |
| 44 | - | ||
| 45 | -@Component | ||
| 46 | -struct PeopleShipAttentionContentListHeadComponent { | ||
| 47 | - | ||
| 48 | - @State index: number = 0 | ||
| 49 | - @ObjectLink item: FollowListDetailItem | ||
| 50 | - build() { | ||
| 51 | - Column(){ | ||
| 52 | - // 头像 | ||
| 53 | - PeopleShipHomePageHeadComponent({ | ||
| 54 | - diameter: 48, | ||
| 55 | - iconDiameter: 16, | ||
| 56 | - headPhotoUrl: this.index == 0 ? $r('app.media.attention_mine') : | ||
| 57 | - ((this.item.attentionHeadPhotoUrl && this.item.attentionHeadPhotoUrl.length > 0) ? | ||
| 58 | - this.item.attentionHeadPhotoUrl : $r('app.media.WDAccountOwnerHedaerDefaultIcon')), | ||
| 59 | - authIcon: this.index == 0 ? '' : this.item.authIcon | ||
| 60 | - }).margin({ | ||
| 61 | - bottom: '8vp' | ||
| 62 | - }) | ||
| 63 | - | ||
| 64 | - Text(this.index == 0 ? '我的关注' : this.item.attentionUserName) | ||
| 65 | - .fontColor($r('app.color.color_666666')) | ||
| 66 | - .fontSize($r('app.float.vp_13')) | ||
| 67 | - .fontWeight(400) | ||
| 68 | - .height('18vp') | ||
| 69 | - .lineHeight('18vp') | ||
| 70 | - .maxLines(1) | ||
| 71 | - .textOverflow({overflow: TextOverflow.Ellipsis}) | ||
| 72 | - .padding({ | ||
| 73 | - left: '2vp', | ||
| 74 | - right: '2vp' | ||
| 75 | - }) | ||
| 76 | - } | ||
| 77 | - .alignItems(HorizontalAlign.Center) | ||
| 78 | - .width('78vp') | ||
| 79 | - .margin({ | ||
| 80 | - left: this.index == 0 ? '8vp' : '4vp', | ||
| 81 | - top: '14vp', | ||
| 82 | - bottom: '14vp' | ||
| 83 | - }) | ||
| 84 | - } | ||
| 85 | -} |
| @@ -2,7 +2,14 @@ import { PeopleShipRecommendComponent } from './PeopleShipRecommendComponent'; | @@ -2,7 +2,14 @@ import { PeopleShipRecommendComponent } from './PeopleShipRecommendComponent'; | ||
| 2 | import { PeopleShipMainViewModel } from '../../viewmodel/PeopleShipMainViewModel'; | 2 | import { PeopleShipMainViewModel } from '../../viewmodel/PeopleShipMainViewModel'; |
| 3 | import { HttpUtils } from 'wdNetwork/Index'; | 3 | import { HttpUtils } from 'wdNetwork/Index'; |
| 4 | import { Logger, DateTimeUtils, EmitterEventId, EmitterUtils } from 'wdKit'; | 4 | import { Logger, DateTimeUtils, EmitterEventId, EmitterUtils } from 'wdKit'; |
| 5 | -import { RmhRecommendDTO, ContentDTO, AttentionBatchDTO, CreatorDTO } from 'wdBean'; | 5 | +import { |
| 6 | + RmhRecommendDTO, | ||
| 7 | + ContentDTO, | ||
| 8 | + AttentionBatchDTO, | ||
| 9 | + CreatorDTO, | ||
| 10 | + contentListParams, | ||
| 11 | + InteractDataDTO | ||
| 12 | +} from 'wdBean'; | ||
| 6 | import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType'; | 13 | import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType'; |
| 7 | import { channelSkeleton } from '../skeleton/channelSkeleton' | 14 | import { channelSkeleton } from '../skeleton/channelSkeleton' |
| 8 | import { EmptyComponent } from '../view/EmptyComponent'; | 15 | import { EmptyComponent } from '../view/EmptyComponent'; |
| @@ -56,6 +63,13 @@ export struct PeopleShipMainComponent { | @@ -56,6 +63,13 @@ export struct PeopleShipMainComponent { | ||
| 56 | this.LoadingLayout() | 63 | this.LoadingLayout() |
| 57 | } else if (this.viewType == ViewType.ERROR) { | 64 | } else if (this.viewType == ViewType.ERROR) { |
| 58 | ErrorComponent() | 65 | ErrorComponent() |
| 66 | + .onTouch((event: TouchEvent | undefined) => { | ||
| 67 | + if (event) { | ||
| 68 | + if (this.viewType === ViewType.ERROR) { | ||
| 69 | + this.getData() | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + }) | ||
| 59 | } else if (this.viewType == ViewType.EMPTY) { | 73 | } else if (this.viewType == ViewType.EMPTY) { |
| 60 | EmptyComponent() | 74 | EmptyComponent() |
| 61 | } else { | 75 | } else { |
| @@ -155,11 +169,6 @@ export struct PeopleShipMainComponent { | @@ -155,11 +169,6 @@ export struct PeopleShipMainComponent { | ||
| 155 | .scrollBar(BarState.Off) | 169 | .scrollBar(BarState.Off) |
| 156 | .width('100%') | 170 | .width('100%') |
| 157 | .height('100%') | 171 | .height('100%') |
| 158 | - | ||
| 159 | - // PeopleShipAttentionContentListComponent({ | ||
| 160 | - // followList: this.followList, | ||
| 161 | - // attentionList: this.attentionList | ||
| 162 | - // }) | ||
| 163 | } | 172 | } |
| 164 | 173 | ||
| 165 | aboutToAppear() { | 174 | aboutToAppear() { |
| @@ -259,14 +268,6 @@ export struct PeopleShipMainComponent { | @@ -259,14 +268,6 @@ export struct PeopleShipMainComponent { | ||
| 259 | // 获取列表数据 | 268 | // 获取列表数据 |
| 260 | let listData = await PeopleShipMainViewModel.getAttentionContentListInfo(this.currentPage, 20, this.loadTime) | 269 | let listData = await PeopleShipMainViewModel.getAttentionContentListInfo(this.currentPage, 20, this.loadTime) |
| 261 | Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(listData)}`) | 270 | Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(listData)}`) |
| 262 | - | ||
| 263 | - if (resolve ) { | ||
| 264 | - if (this.currentPage == 1) { | ||
| 265 | - resolve('已更新至最新') | ||
| 266 | - }else { | ||
| 267 | - resolve('') | ||
| 268 | - } | ||
| 269 | - } | ||
| 270 | if (listData && listData.list && listData.list.length > 0) { | 271 | if (listData && listData.list && listData.list.length > 0) { |
| 271 | if (listData.list.length === 20) { | 272 | if (listData.list.length === 20) { |
| 272 | this.hasMore = true; | 273 | this.hasMore = true; |
| @@ -276,14 +277,71 @@ export struct PeopleShipMainComponent { | @@ -276,14 +277,71 @@ export struct PeopleShipMainComponent { | ||
| 276 | if (this.currentPage == 1) { | 277 | if (this.currentPage == 1) { |
| 277 | this.attentionList = [] | 278 | this.attentionList = [] |
| 278 | } | 279 | } |
| 279 | - this.attentionList.push(...listData.list) | 280 | + //批量查询各类型内容动态数据接口 |
| 281 | + this.checkContentInteractData(listData.list, resolve) | ||
| 282 | + } else { | ||
| 283 | + this.resolveEnd(true, resolve) | ||
| 280 | } | 284 | } |
| 281 | - this.viewType = ViewType.LOADED | ||
| 282 | - this.isLoading = false | 285 | + |
| 283 | } catch (exception) { | 286 | } catch (exception) { |
| 287 | + this.resolveEnd(false, resolve) | ||
| 288 | + } | ||
| 289 | + } | ||
| 290 | + | ||
| 291 | + // 批量查询各类型内容动态数据接口 | ||
| 292 | + private async checkContentInteractData(list: ContentDTO[], resolve?: (value: string | PromiseLike<string>) => void) { | ||
| 293 | + // 批量查询内容当前用户点赞、收藏状态 | ||
| 294 | + try { | ||
| 295 | + // 获取列表数据 | ||
| 296 | + const params: contentListParams = { | ||
| 297 | + contentList: [] | ||
| 298 | + } | ||
| 299 | + list.forEach((item: ContentDTO) => { | ||
| 300 | + params.contentList.push({ | ||
| 301 | + contentId: item.objectId, | ||
| 302 | + contentType: Number(item.objectType ?? '1') | ||
| 303 | + }) | ||
| 304 | + }) | ||
| 305 | + | ||
| 306 | + let listData = await PeopleShipMainViewModel.getContentInteractInfo(params) | ||
| 307 | + Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(listData)}`) | ||
| 308 | + this.resolveEnd(true, resolve) | ||
| 309 | + list.forEach((element: ContentDTO) => { | ||
| 310 | + // 获取 interactData 数据 | ||
| 311 | + if (listData && listData.length > 0) { | ||
| 312 | + const objc = listData.find((interactModel: InteractDataDTO) => { | ||
| 313 | + return element.objectId == interactModel.contentId | ||
| 314 | + }) | ||
| 315 | + if (objc) { | ||
| 316 | + element.interactData = objc | ||
| 317 | + } | ||
| 318 | + } | ||
| 319 | + // 设置人民号都不可关注 | ||
| 320 | + if (element.rmhInfo) { | ||
| 321 | + element.rmhInfo.cnIsAttention = 0 | ||
| 322 | + } | ||
| 323 | + this.attentionList.push(element) | ||
| 324 | + }) | ||
| 325 | + | ||
| 326 | + } catch (exception) { | ||
| 327 | + this.resolveEnd(false, resolve) | ||
| 328 | + } | ||
| 329 | + } | ||
| 330 | + | ||
| 331 | + private resolveEnd(isTop: boolean, resolve?: (value: string | PromiseLike<string>) => void) { | ||
| 332 | + if (resolve) { | ||
| 333 | + if (this.currentPage == 1 && isTop) { | ||
| 334 | + resolve('已更新至最新') | ||
| 335 | + }else { | ||
| 336 | + resolve('') | ||
| 337 | + } | ||
| 338 | + } | ||
| 339 | + if (this.currentPage == 1 && !isTop) { | ||
| 284 | this.viewType = ViewType.ERROR | 340 | this.viewType = ViewType.ERROR |
| 285 | - this.isLoading = false | 341 | + } else { |
| 342 | + this.viewType = ViewType.LOADED | ||
| 286 | } | 343 | } |
| 344 | + this.isLoading = false | ||
| 287 | } | 345 | } |
| 288 | 346 | ||
| 289 | // 说是首页必须要调用 | 347 | // 说是首页必须要调用 |
| 1 | import { Logger } from 'wdKit'; | 1 | import { Logger } from 'wdKit'; |
| 2 | import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; | 2 | import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; |
| 3 | -import HashMap from '@ohos.util.HashMap'; | ||
| 4 | import { | 3 | import { |
| 5 | RmhRecommendDTO, | 4 | RmhRecommendDTO, |
| 6 | PeopleShipContentListDTO, | 5 | PeopleShipContentListDTO, |
| 7 | - AttentionBatchDTO | 6 | + AttentionBatchDTO, |
| 7 | + contentListParams, | ||
| 8 | + InteractDataDTO | ||
| 8 | } from 'wdBean'; | 9 | } from 'wdBean'; |
| 10 | +import { PageRepository } from '../repository/PageRepository' | ||
| 9 | 11 | ||
| 10 | const TAG = 'PeopleShipMainViewModel' | 12 | const TAG = 'PeopleShipMainViewModel' |
| 11 | 13 | ||
| @@ -103,5 +105,24 @@ export class PeopleShipMainViewModel { | @@ -103,5 +105,24 @@ export class PeopleShipMainViewModel { | ||
| 103 | }) | 105 | }) |
| 104 | } | 106 | } |
| 105 | 107 | ||
| 108 | + static async getContentInteractInfo(params: contentListParams): Promise<InteractDataDTO[]> { | ||
| 109 | + return new Promise<InteractDataDTO[]>((success, error) => { | ||
| 110 | + Logger.debug(TAG, `getContentInteractInfo pageInfo start`); | ||
| 111 | + PageRepository.getContentInteract(params) | ||
| 112 | + .then((resDTO) => { | ||
| 113 | + if (!resDTO.data || resDTO.code != 0) { | ||
| 114 | + error(resDTO.message) | ||
| 115 | + return | ||
| 116 | + } | ||
| 117 | + Logger.debug(TAG, "getContentInteractInfo then,navResDTO.timestamp:" + resDTO.timestamp); | ||
| 118 | + success(resDTO.data); | ||
| 119 | + }) | ||
| 120 | + .catch((err: Error) => { | ||
| 121 | + Logger.error(TAG, `getContentInteractInfo catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 122 | + error(err); | ||
| 123 | + }) | ||
| 124 | + }) | ||
| 125 | + } | ||
| 126 | + | ||
| 106 | 127 | ||
| 107 | } | 128 | } |
-
Please register or login to post a comment