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-25 16:12:55 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9c6f168c9404af86676511ad590c648fe37dbd87
9c6f168c
1 parent
08823cb6
desc:评论列表界面、评论弹窗
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
123 additions
and
26 deletions
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
View file @
9c6f168
...
...
@@ -8,6 +8,10 @@ import { MyCommentDataSource } from '../model/MyCommentDataSource'
import { HttpUtils } from 'wdNetwork/src/main/ets/utils/HttpUtils'
import { HttpUrlUtils } from 'wdNetwork/Index'
import PageModel from '../../../viewmodel/PageModel'
import { ErrorComponent } from '../../view/ErrorComponent'
import { EmptyComponent , WDViewDefaultType} from '../../view/EmptyComponent'
import { CustomPullToRefresh } from '../../reusable/CustomPullToRefresh'
import NoMoreLayout from '../../page/NoMoreLayout'
const TAG = 'QualityCommentsComponent';
...
...
@@ -16,8 +20,13 @@ const TAG = 'QualityCommentsComponent';
@Component
export struct QualityCommentsComponent {
@State private browSingModel: PageModel = new PageModel()
isloading : boolean = false
//刷新
@State viewType:number = ViewType.LOADING;
@State hasMore: boolean = true;
@State currentPage: number = 1;
private scroller: Scroller = new Scroller();
@State tileOpacity: number = 0;
firstPositionY: number = 0;
...
...
@@ -25,7 +34,7 @@ export struct QualityCommentsComponent {
topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
lastWindowColor: string = '#ffffff'
currentWindowColor: string = '#FF4202'
@State allDatas:
MyCommentDataSource = new MyComment
DataSource();
@State allDatas:
LazyDataSource<commentItemModel> = new Lazy
DataSource();
aboutToDisappear(): void {
...
...
@@ -40,14 +49,31 @@ export struct QualityCommentsComponent {
aboutToAppear(): void {
this.fullScreen();
this.getData();
}
getData(resolve?: (value: string | PromiseLike<string>) => void){
commentViewModel.fetchQualityCommentList(this.currentPage + '').then((commentListModel) => {
if(resolve) resolve('刷新成功')
commentViewModel.fetchQualityCommentList('1').then((commentListModel) => {
if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
if (this.currentPage === 1) {
this.allDatas.clear()
}
commentListModel.list.forEach(element => {
this.allDatas.push
Data
(commentViewModel.deepCopyCommentItemModel(element))
this.allDatas.push(commentViewModel.deepCopyCommentItemModel(element))
});
} else {
if (commentListModel.hasNext === 0) {
this.hasMore = false;
} else {
this.hasMore = true;
}
} else {
if (this.currentPage === 1) {
this.viewType = ViewType.EMPTY;
}
}
})
}
...
...
@@ -151,20 +177,77 @@ export struct QualityCommentsComponent {
build() {
Column() {
Stack({ alignContent: Alignment.Top }) {
Scroll() {
Column() {
Stack() {
this.titleHeader()
this.listLayout()
// if(this.viewType == ViewType.ERROR){
// ErrorComponent()
// }else if(this.viewType == ViewType.EMPTY){
// EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoComment})
// }else {
// CustomPullToRefresh({
// alldata:[],
// scroller:this.scroller,
// customList:()=>{
// // this.listLayout()
// this.testLayout()
// },
// onRefresh:(resolve)=>{
// this.currentPage = 1
// this.getData(resolve)
// },
// onLoadMore:(resolve)=> {
// if (this.hasMore === false) {
// if(resolve) resolve('')
// return
// }
// this.currentPage++
// this.getData(resolve)
// }
// })
// }
List({ space: 12 }) {
}.alignContent(Alignment.Top)
}.backgroundColor(this.currentWindowColor).width('100%')
}
.friction(0.6)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
.width('100%')
.height('100%')
this.TabbarTransparent()
this.TabbarNormal()
}
}
}
@Builder
listLayout(){
List({ space: 12, scroller:this.scroller }) {
// ListItemGroup({ header: this.titleHeader() })
LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {
ListItem() {
QualityCommentItem({ item: item, index: index }).margin({ left: 12, right: 12 })
}
})
// 加载更多
ListItem() {
if (this.hasMore === false) NoMoreLayout()
}
ListItem() {
}.height(this.bottomSafeHeight)
...
...
@@ -172,36 +255,31 @@ export struct QualityCommentsComponent {
.margin({ top: 196 })
.height("100%")
.width("100%")
.edgeEffect(EdgeEffect.Spring)
.edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
// .edgeEffect(EdgeEffect.Spring)
.nestedScroll({
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
})
// .margin({ bottom: this.bottomSafeHeight })
// .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}.alignContent(Alignment.Top)
}.backgroundColor(this.currentWindowColor).width('100%')
}
.friction(0.6)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
.width('100%')
.height('100%')
this.TabbarTransparent()
this.TabbarNormal()
@Builder
testLayout(){
List({ space: 12, scroller:this.scroller }){
LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {
ListItem() {
// QualityCommentItem({ item: item, index: index }).margin({ left: 12, right: 12 })
}
})
}
}
}
@Component
struct QualityCommentItem {
@ObjectLink item: commentItemModel
...
...
@@ -316,10 +394,10 @@ struct QualityCommentItem {
.margin({ left: 3 })
}
}.onClick(() => {
comment
ViewModel.commnet
LikeChange(this.item)
commentLikeChange(this.item)
commentViewModel.commentLike(this.item).then(() => {
}).catch(() => {
comment
ViewModel.commnet
LikeChange(this.item)
commentLikeChange(this.item)
})
})
}
...
...
@@ -331,5 +409,24 @@ struct QualityCommentItem {
}
}
function commentLikeChange(item: commentItemModel) {
item.api_status = !item.api_status
//点赞
if (item.api_status) {
if (item.likeNum.length > 0) {
item.likeNum = (Number.parseInt(item.likeNum) + 1) + ''
} else {
item.likeNum = '1'
}
}
//取消点赞
if (!item.api_status) {
item.likeNum = (Number.parseInt(item.likeNum) - 1) + ''
if (Number.parseInt(item.likeNum) <= 0) {
item.likeNum = ''
}
}
}
...
...
Please
register
or
login
to post a comment