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
chenjun1_wd
2024-08-24 00:44:46 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e45e814dc979ba96806a485319a13ecbd796e913
e45e814d
1 parent
7490af8a
换一换与安卓对齐
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
5 deletions
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleColumn09.ets
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleColumn09.ets
View file @
e45e814
...
...
@@ -14,7 +14,7 @@ const TAG = 'Zh_Single_Column-09'
@Entry
@Component
export struct ZhSingleColumn09 {
@State fullyTraversed: boolean = false;
@State fullyTraversed: boolean = false;
//换一换置灰标记
@State private pageModel: PageModel = new PageModel();
@State pageId: string = '';
@State pageName: string = '';
...
...
@@ -26,11 +26,46 @@ export struct ZhSingleColumn09 {
@State compIndex: number = 0;
@State currentOperDataListIndex: number = 0; //记录换一换点击次数
@State visitedIndices: Set<number> = new Set<number>();
private currentIndex: number = 0;
@State currentDataList: ContentDTO[] = []
async aboutToAppear(): Promise<void> {
this.loadImg = await onlyWifiLoadImg();
this.operDataList = this.shuffleArray(this.compDTO?.operDataList)
// this.operDataList = this.shuffleArray(this.compDTO?.operDataList)
this.operDataList = this.padData(this.compDTO?.operDataList)
this.currentOperDataListIndex = this.compDTO?.operDataList.length
this.currentDataList = this.getNextBatch()
}
/**
* 若数据不满足8个以上直接返回
* 若最后一屏不够补齐至8个
* */
private padData(data: ContentDTO[]): ContentDTO[] {
if (data.length < 9) {
return data
}
const remainder = data.length % 8;
if (remainder === 0) {
return data;
}
const paddingCount = 8 - remainder;
const padding = data.slice(0, paddingCount);
return [...data, ...padding];
}
/**
* 换一换切换数据
* */
public getNextBatch(): ContentDTO[] {
const batch = this.operDataList.slice(this.currentIndex, this.currentIndex + 8);
this.currentIndex += 8;
if (this.currentIndex >= this.operDataList.length) {
this.fullyTraversed = true //数据展现完毕,置灰标记
}
return batch;
}
trackClick(type: 'close_interest_card_click' | 'interest_card_selecting_click') {
...
...
@@ -142,8 +177,8 @@ export struct ZhSingleColumn09 {
.justifyContent(FlexAlign.SpaceBetween)
.width('100%')
Flex({wrap: FlexWrap.Wrap}) {
ForEach(this.operDataList.slice(0, 8), (item: ContentDTO, index: number) => {
Flex({ wrap: FlexWrap.Wrap }) {
ForEach(this.currentDataList, (item: ContentDTO, index: number) => {
Row() {
Stack({ alignContent: Alignment.TopEnd }) {
Image(this.loadImg ? item.coverUrl : '')
...
...
@@ -204,10 +239,14 @@ export struct ZhSingleColumn09 {
return
}
if (this.compDTO?.operDataList.length > 8) {
this.operDataList = this.shuffleArray(this.operDataList)
//
this.operDataList = this.shuffleArray(this.operDataList)
// if (this.pageModel) {
// this.pageModel.compList.deleteItem(this.compIndex)
// }
if (this.fullyTraversed) {
return; // 所有数据已取完
}
this.currentDataList = this.getNextBatch()
this.activeIndexs = [];
}
})
...
...
Please
register
or
login
to post a comment