Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhangbo1_wd
2024-05-08 19:20:05 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9ee664b419f1a18c79023cb1d15380ba179329b9
9ee664b4
1 parent
2fc87ef7
二次互动数据请求放开,设置到complist
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
22 deletions
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageHelper.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageViewModel.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageHelper.ets
View file @
9ee664b
import { CompDTO, ContentDTO, PageDTO, PageInfoDTO } from 'wdBean';
import { CompDTO, ContentDTO,
InteractDataDTO,
PageDTO, PageInfoDTO } from 'wdBean';
import { CompStyle, ViewType } from 'wdConstant/Index';
import { CollectionUtils, DateTimeUtils, Logger, NetworkUtil, StringUtils } from 'wdKit';
import { CollectionUtils, DateTimeUtils, L
azyDataSource, L
ogger, NetworkUtil, StringUtils } from 'wdKit';
import { closeRefresh } from '../utils/PullDownRefresh';
import PageModel from './PageModel';
import PageViewModel from './PageViewModel';
...
...
@@ -10,6 +10,7 @@ import PageAdModel from './PageAdvModel';
import { ArrayList } from '@kit.ArkTS';
import { WDViewDefaultType } from '../components/view/EmptyComponent';
import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean';
import { BaseDTO } from 'wdBean/src/main/ets/bean/component/BaseDTO';
const TAG = 'PageHelper';
...
...
@@ -121,7 +122,6 @@ export class PageHelper {
pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
if (pageDto && pageDto.compList && pageDto.compList.length > 0) {
pageModel.viewType = ViewType.LOADED;
let sizeBefore: number = pageModel.compList.size();
if (isLastGroup) {
// 认为分页只会在最后一个group里
pageModel.currentPage++;
...
...
@@ -132,17 +132,15 @@ export class PageHelper {
//移除音频 和 活动
this.collectPageComp(pageModel, pageDto)
// pageModel.compList.push(...pageDto.compList)
// TODO 暂时去掉互动数据,待优化。(主要是互动数据返回,如何渲染到ui上)
// TODO updateItems(sizeBefore, data),这里可能有时序问题,导致覆盖别的group数据,需要优化,考虑精准替换
// 二次请求,批查互动数据
// PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => {
// // 刷新,替换所有数据
// // pageModel.compList.replaceAll(...data)
// pageModel.compList.updateItems(sizeBefore, data)
// pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
// })
PageViewModel.getInteractData(pageDto.compList).then((data: InteractDataDTO[]) => {
// 刷新,替换所有数据
this.resetInteract(data, pageModel.compList)
pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
pageModel.compList.reloadData()
})
// content级别的展现加载丢给comp自己,这里只需要处理屏蔽分页加载,pageModel.pageScroll
if (isLastGroup) {
closeRefresh(pageModel, true);
...
...
@@ -335,18 +333,17 @@ export class PageHelper {
// 直接认为有分页,一直加载分页。直到没有数据,再停止
pageModel.currentPage++;
pageModel.hasMore = true;
let sizeBefore: number = pageModel.compList.size();
//移除音频 和 活动
this.collectPageComp(pageModel, data)
// pageModel.compList.push(...data.compList)
// TODO 暂时屏蔽,此处代码会造成 广告逻辑错乱,只有第一页有广告数据,随着加载更多,第二页也会出现广告数据
// PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => {
// // 刷新,替换所有数据
// pageModel.compList.updateItems(sizeBefore, data)
// pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
// })
PageViewModel.getInteractData(data.compList).then((data: InteractDataDTO[]) => {
// 刷新,替换所有数据
this.resetInteract(data, pageModel.compList)
pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
pageModel.compList.reloadData()
})
}
}).catch((err: string | Resource) => {
promptAction.showToast({ message: err });
...
...
@@ -394,6 +391,36 @@ export class PageHelper {
}
/**
* 刷新互动数据到compList
* @param interact 批查互动数据结果
* @param compList comp list
*/
private resetInteract(interact: InteractDataDTO[], compList: LazyDataSource<BaseDTO>) {
if (interact == null || interact.length == 0) {
return
}
interact.forEach((interactData) => {
let id = interactData.contentId;
outer: for (let i = 0; i < compList.totalCount(); i++) {
let comp = compList.getData(i) as CompDTO;
if (comp == null || comp.operDataList == null || comp.operDataList.length == 0) {
continue;
}
for (let j = 0; j < comp.operDataList.length; j++) {
let content = comp.operDataList[j];
if (content == null) {
continue;
}
if (id == content.objectId) {
content.interactData = interactData;
break outer;
}
}
}
})
}
}
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageViewModel.ets
View file @
9ee664b
...
...
@@ -232,10 +232,10 @@ export class PageViewModel extends BaseViewModel {
}
}
return new Promise<
Comp
DTO[]>((success, error) => {
return new Promise<
InteractData
DTO[]>((success, error) => {
Promise.all(promises).then((result) => {
if (!CollectionUtils.isArray(result)) {
success(
compList
);
success(
new Array<InteractDataDTO>()
);
return;
}
...
...
@@ -246,8 +246,8 @@ export class PageViewModel extends BaseViewModel {
}
})
// 批查全部完成,统一设置到comp里
this.resetInteract(allInteractDataList, compList);
success(compList);
// this.resetInteract(allInteractDataList, compList);
success(allInteractDataList);
})
})
}
...
...
@@ -269,6 +269,9 @@ export class PageViewModel extends BaseViewModel {
});
}
/**
* @deprecated
*/
private resetInteract(interact: InteractDataDTO[], compList: CompDTO[]) {
if (interact == null || interact.length == 0) {
return
...
...
Please
register
or
login
to post a comment