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
yangsunyue_wd
2024-04-28 15:45:22 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
691b2c0374fe6978ea2ed908224c460bc8f68f13
691b2c03
1 parent
f5853d2f
desc:评论列表加载更多
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
2 deletions
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentComponent.ets
View file @
691b2c0
...
...
@@ -10,6 +10,7 @@ import { CommentCustomDialog } from './CommentCustomDialog'
import { publishCommentModel } from '../model/PublishCommentModel';
import { ifaa } from '@kit.OnlineAuthenticationKit';
import { HttpUrlUtils } from 'wdNetwork/Index';
import NoMoreLayout from '../../page/NoMoreLayout';
const TAG = 'CommentComponent';
...
...
@@ -19,6 +20,8 @@ const testString = '因为读书的人\n是低着头向上看的人\n身处一
@Preview
@Component
export struct CommentComponent {
@State hasMore: boolean = true;
@State currentPage: number = 1;
// @State private browSingModel: commentListModel = new commentListModel()
/*必传*/
@ObjectLink publishCommentModel: publishCommentModel
...
...
@@ -167,7 +170,19 @@ export struct CommentComponent {
}
}
}, (item: commentItemModel, index: number) => JSON.stringify(item) + index.toString())
// 加载更多
ListItem() {
if (this.hasMore === false) NoMoreLayout()
}
}
.onReachEnd(()=>{
if (this.hasMore) {
this.getData()
}
})
.enableScrollInteraction(false)
}
...
...
@@ -175,10 +190,22 @@ export struct CommentComponent {
//获取数据
async getData() {
commentViewModel.fetchContentCommentList(
'1
', this.publishCommentModel.targetId, this.publishCommentModel.targetType)
commentViewModel.fetchContentCommentList(
this.currentPage + '
', this.publishCommentModel.targetId, this.publishCommentModel.targetType)
.then(commentListModel => {
this.publishCommentModel.totalCommentNumer = commentListModel.totalCount + ''
this.currentPage++
if (Number.parseInt(commentListModel.totalCommentNum) > Number.parseInt(this.publishCommentModel.totalCommentNumer)) {
this.publishCommentModel.totalCommentNumer = commentListModel.totalCommentNum + ''
}
if (commentListModel.hasNext === 0) {
this.hasMore = false;
} else {
this.hasMore = true;
}
if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
commentListModel.list.forEach(element => {
element.hasMore = Number.parseInt(element.childCommentNum) ? true : false
let newModel = commentViewModel.deepCopyCommentItemModel(element)
...
...
@@ -189,6 +216,8 @@ export struct CommentComponent {
});
}else{
this.hasMore = false
}
})
...
...
Please
register
or
login
to post a comment