Showing
9 changed files
with
177 additions
and
80 deletions
| @@ -289,4 +289,8 @@ export class LazyDataSource<T> extends BasicDataSource<T> { | @@ -289,4 +289,8 @@ export class LazyDataSource<T> extends BasicDataSource<T> { | ||
| 289 | this.dataArray.splice(start, this.dataArray.length, ...data); | 289 | this.dataArray.splice(start, this.dataArray.length, ...data); |
| 290 | this.notifyDataReload() | 290 | this.notifyDataReload() |
| 291 | } | 291 | } |
| 292 | + | ||
| 293 | + public reloadData(): void { | ||
| 294 | + this.notifyDataReload(); | ||
| 295 | + } | ||
| 292 | } | 296 | } |
| 1 | +import { commentItemModel } from './CommentModel' | ||
| 2 | + | ||
| 1 | @Observed | 3 | @Observed |
| 2 | export class publishCommentModel { | 4 | export class publishCommentModel { |
| 3 | 5 | ||
| @@ -25,7 +27,7 @@ export class publishCommentModel { | @@ -25,7 +27,7 @@ export class publishCommentModel { | ||
| 25 | /*评论内容*/ | 27 | /*评论内容*/ |
| 26 | commentContent: string = "" | 28 | commentContent: string = "" |
| 27 | /*1.文字 2.文字+表情 3.定制表情(客户端写死) 4.图片*/ | 29 | /*1.文字 2.文字+表情 3.定制表情(客户端写死) 4.图片*/ |
| 28 | - commentType: string = '1' | 30 | + commentType: string = '2' |
| 29 | /*根评论id,如果是一级评论,传-1;否则,传当前评论所属的根评论id*/ | 31 | /*根评论id,如果是一级评论,传-1;否则,传当前评论所属的根评论id*/ |
| 30 | rootCommentId: string = "-1" | 32 | rootCommentId: string = "-1" |
| 31 | /*父评论id,如果是其它评论的回复,该字段必填*/ | 33 | /*父评论id,如果是其它评论的回复,该字段必填*/ |
| @@ -35,6 +37,10 @@ export class publishCommentModel { | @@ -35,6 +37,10 @@ export class publishCommentModel { | ||
| 35 | //可选 | 37 | //可选 |
| 36 | placeHolderText: string = "优质评论会获得最佳评论人的称号" | 38 | placeHolderText: string = "优质评论会获得最佳评论人的称号" |
| 37 | 39 | ||
| 40 | + //最新发布的评论 | ||
| 41 | + lastCommentModel: commentItemModel = new commentItemModel() | ||
| 42 | + | ||
| 43 | + | ||
| 38 | } | 44 | } |
| 39 | 45 | ||
| 40 | 46 |
| 1 | import ArrayList from '@ohos.util.ArrayList' | 1 | import ArrayList from '@ohos.util.ArrayList' |
| 2 | import { ViewType } from 'wdConstant/Index'; | 2 | import { ViewType } from 'wdConstant/Index'; |
| 3 | -import { DateTimeUtils, LazyDataSource } from 'wdKit/Index'; | 3 | +import { DateTimeUtils, EmitterEventId, EmitterUtils, LazyDataSource } from 'wdKit/Index'; |
| 4 | import PageModel from '../../../viewmodel/PageModel'; | 4 | import PageModel from '../../../viewmodel/PageModel'; |
| 5 | import { commentItemModel, commentListModel, WDPublicUserType } from '../model/CommentModel'; | 5 | import { commentItemModel, commentListModel, WDPublicUserType } from '../model/CommentModel'; |
| 6 | import commentViewModel from '../viewmodel/CommentViewModel' | 6 | import commentViewModel from '../viewmodel/CommentViewModel' |
| @@ -9,6 +9,7 @@ import measure from '@ohos.measure' | @@ -9,6 +9,7 @@ import measure from '@ohos.measure' | ||
| 9 | import { CommentCustomDialog } from './CommentCustomDialog' | 9 | import { CommentCustomDialog } from './CommentCustomDialog' |
| 10 | import { publishCommentModel } from '../model/PublishCommentModel'; | 10 | import { publishCommentModel } from '../model/PublishCommentModel'; |
| 11 | import { ifaa } from '@kit.OnlineAuthenticationKit'; | 11 | import { ifaa } from '@kit.OnlineAuthenticationKit'; |
| 12 | +import { HttpUrlUtils } from 'wdNetwork/Index'; | ||
| 12 | 13 | ||
| 13 | const TAG = 'CommentComponent'; | 14 | const TAG = 'CommentComponent'; |
| 14 | 15 | ||
| @@ -18,18 +19,13 @@ const testString = '因为读书的人\n是低着头向上看的人\n身处一 | @@ -18,18 +19,13 @@ const testString = '因为读书的人\n是低着头向上看的人\n身处一 | ||
| 18 | @Preview | 19 | @Preview |
| 19 | @Component | 20 | @Component |
| 20 | export struct CommentComponent { | 21 | export struct CommentComponent { |
| 21 | - | ||
| 22 | // @State private browSingModel: commentListModel = new commentListModel() | 22 | // @State private browSingModel: commentListModel = new commentListModel() |
| 23 | /*必传*/ | 23 | /*必传*/ |
| 24 | @ObjectLink publishCommentModel: publishCommentModel | 24 | @ObjectLink publishCommentModel: publishCommentModel |
| 25 | - | ||
| 26 | isloading: boolean = false | 25 | isloading: boolean = false |
| 27 | - | ||
| 28 | @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource(); | 26 | @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource(); |
| 29 | - | ||
| 30 | @State dialogController: CustomDialogController | null = null; | 27 | @State dialogController: CustomDialogController | null = null; |
| 31 | 28 | ||
| 32 | - | ||
| 33 | // 在自定义组件即将析构销毁时将dialogControlle置空 | 29 | // 在自定义组件即将析构销毁时将dialogControlle置空 |
| 34 | aboutToDisappear() { | 30 | aboutToDisappear() { |
| 35 | this.dialogController = null // 将dialogController置空 | 31 | this.dialogController = null // 将dialogController置空 |
| @@ -37,12 +33,23 @@ export struct CommentComponent { | @@ -37,12 +33,23 @@ export struct CommentComponent { | ||
| 37 | 33 | ||
| 38 | aboutToAppear() { | 34 | aboutToAppear() { |
| 39 | 35 | ||
| 36 | + //注册通知,来自别的组件的评论成功通知 | ||
| 37 | + EmitterUtils.receiveEvent(EmitterEventId.COMMENT_PUBLISH, (targetId?: string) => { | ||
| 38 | + if (targetId) { | ||
| 39 | + if (targetId == this.publishCommentModel.targetId) { | ||
| 40 | + //新增评论 | ||
| 41 | + this.addCommentLocal() | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + }) | ||
| 45 | + | ||
| 46 | + | ||
| 40 | this.dialogController = new CustomDialogController({ | 47 | this.dialogController = new CustomDialogController({ |
| 41 | builder: CommentCustomDialog({ | 48 | builder: CommentCustomDialog({ |
| 42 | confirm: (value: Record<string, string>) => { | 49 | confirm: (value: Record<string, string>) => { |
| 43 | - | 50 | + this.addCommentLocal() |
| 44 | }, | 51 | }, |
| 45 | - publishCommentModel:this.publishCommentModel | 52 | + publishCommentModel: this.publishCommentModel |
| 46 | }), | 53 | }), |
| 47 | autoCancel: true, | 54 | autoCancel: true, |
| 48 | alignment: DialogAlignment.Bottom, | 55 | alignment: DialogAlignment.Bottom, |
| @@ -57,6 +64,24 @@ export struct CommentComponent { | @@ -57,6 +64,24 @@ export struct CommentComponent { | ||
| 57 | 64 | ||
| 58 | } | 65 | } |
| 59 | 66 | ||
| 67 | + // | ||
| 68 | + addCommentLocal() { | ||
| 69 | + let model = commentViewModel.deepCopyCommentItemModel(this.publishCommentModel.lastCommentModel) | ||
| 70 | + /*一级评论*/ | ||
| 71 | + if (this.publishCommentModel.lastCommentModel.parentId == '-1') { | ||
| 72 | + this.allDatas.addFirstItem(model) | ||
| 73 | + //TODO 跳转顶部 | ||
| 74 | + }else{ | ||
| 75 | + //二级评论 | ||
| 76 | + this.allDatas.getDataArray().forEach(element => { | ||
| 77 | + if (element.id == this.publishCommentModel.lastCommentModel.rootCommentId) { | ||
| 78 | + element.childCommentsLazyDataSource.addFirstItem(model) | ||
| 79 | + } | ||
| 80 | + }); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + } | ||
| 84 | + | ||
| 60 | /*标题:全部评论*/ | 85 | /*标题:全部评论*/ |
| 61 | @Builder | 86 | @Builder |
| 62 | titleHeader() { | 87 | titleHeader() { |
| @@ -73,6 +98,11 @@ export struct CommentComponent { | @@ -73,6 +98,11 @@ export struct CommentComponent { | ||
| 73 | 98 | ||
| 74 | } | 99 | } |
| 75 | .margin({ left: 16 }) | 100 | .margin({ left: 16 }) |
| 101 | + .onClick(()=>{ | ||
| 102 | + // this.allDatas.push(new commentItemModel()) | ||
| 103 | + // this.allDatas.addFirstItem(new commentItemModel()) | ||
| 104 | + // this.allDatas.reloadData(); | ||
| 105 | + }) | ||
| 76 | 106 | ||
| 77 | }.height(44) | 107 | }.height(44) |
| 78 | .width('100%') | 108 | .width('100%') |
| @@ -92,7 +122,11 @@ export struct CommentComponent { | @@ -92,7 +122,11 @@ export struct CommentComponent { | ||
| 92 | /*查看更多和收起*/ | 122 | /*查看更多和收起*/ |
| 93 | @Builder | 123 | @Builder |
| 94 | GroupFooterView(item: commentItemModel, index: number) { | 124 | GroupFooterView(item: commentItemModel, index: number) { |
| 95 | - footerExpandedView({ item: item, contentId: this.publishCommentModel.targetId, contentType: this.publishCommentModel.targetType }) | 125 | + footerExpandedView({ |
| 126 | + item: item, | ||
| 127 | + contentId: this.publishCommentModel.targetId, | ||
| 128 | + contentType: this.publishCommentModel.targetType | ||
| 129 | + }) | ||
| 96 | } | 130 | } |
| 97 | 131 | ||
| 98 | build() { | 132 | build() { |
| @@ -114,7 +148,7 @@ export struct CommentComponent { | @@ -114,7 +148,7 @@ export struct CommentComponent { | ||
| 114 | .onClick(() => { | 148 | .onClick(() => { |
| 115 | console.log(TAG) | 149 | console.log(TAG) |
| 116 | }) | 150 | }) |
| 117 | - }) | 151 | + },(childItem: commentItemModel, subIndex: number) => JSON.stringify(childItem) + subIndex.toString()) |
| 118 | } | 152 | } |
| 119 | } else { | 153 | } else { |
| 120 | ListItemGroup({ header: this.CommentHeaderItem(item, index) }) { | 154 | ListItemGroup({ header: this.CommentHeaderItem(item, index) }) { |
| @@ -129,29 +163,31 @@ export struct CommentComponent { | @@ -129,29 +163,31 @@ export struct CommentComponent { | ||
| 129 | .onClick(() => { | 163 | .onClick(() => { |
| 130 | console.log(TAG) | 164 | console.log(TAG) |
| 131 | }) | 165 | }) |
| 132 | - }) | 166 | + },(childItem: commentItemModel, subIndex: number) => JSON.stringify(childItem) + subIndex.toString()) |
| 133 | } | 167 | } |
| 134 | } | 168 | } |
| 135 | - }) | 169 | + },(item: commentItemModel, index: number) => JSON.stringify(item) + index.toString()) |
| 136 | }.layoutWeight(1) | 170 | }.layoutWeight(1) |
| 137 | } | 171 | } |
| 138 | } | 172 | } |
| 139 | 173 | ||
| 140 | //获取数据 | 174 | //获取数据 |
| 141 | async getData() { | 175 | async getData() { |
| 142 | - commentViewModel.fetchContentCommentList('1', this.publishCommentModel.targetId, this.publishCommentModel.targetType).then(commentListModel => { | ||
| 143 | - if (commentListModel && commentListModel.list && commentListModel.list.length > 0) { | ||
| 144 | - commentListModel.list.forEach(element => { | ||
| 145 | - element.hasMore = Number.parseInt(element.childCommentNum) ? true : false | ||
| 146 | - let newModel = commentViewModel.deepCopyCommentItemModel(element) | ||
| 147 | - // newModel.targetId = this.publishCommentModel.targetId | ||
| 148 | - // newModel.targetType = this.publishCommentModel.targetType | ||
| 149 | - this.allDatas.push(newModel) | ||
| 150 | - }); | 176 | + commentViewModel.fetchContentCommentList('1', this.publishCommentModel.targetId, this.publishCommentModel.targetType) |
| 177 | + .then(commentListModel => { | ||
| 178 | + if (commentListModel && commentListModel.list && commentListModel.list.length > 0) { | ||
| 179 | + commentListModel.list.forEach(element => { | ||
| 180 | + element.hasMore = Number.parseInt(element.childCommentNum) ? true : false | ||
| 181 | + let newModel = commentViewModel.deepCopyCommentItemModel(element) | ||
| 182 | + // 点赞用 | ||
| 183 | + newModel.targetId = this.publishCommentModel.targetId | ||
| 184 | + newModel.targetType = this.publishCommentModel.targetType | ||
| 185 | + this.allDatas.push(newModel) | ||
| 186 | + }); | ||
| 151 | 187 | ||
| 152 | 188 | ||
| 153 | - } | ||
| 154 | - }) | 189 | + } |
| 190 | + }) | ||
| 155 | 191 | ||
| 156 | } | 192 | } |
| 157 | } | 193 | } |
| @@ -243,6 +279,8 @@ struct ChildCommentItem { | @@ -243,6 +279,8 @@ struct ChildCommentItem { | ||
| 243 | }) | 279 | }) |
| 244 | .margin({ left: 95, right: 16, top: -5 }) | 280 | .margin({ left: 95, right: 16, top: -5 }) |
| 245 | .onClick(() => { | 281 | .onClick(() => { |
| 282 | + | ||
| 283 | + | ||
| 246 | this.publishCommentModel.rootCommentId = this.item.rootCommentId | 284 | this.publishCommentModel.rootCommentId = this.item.rootCommentId |
| 247 | this.publishCommentModel.parentId = this.item.id | 285 | this.publishCommentModel.parentId = this.item.id |
| 248 | this.publishCommentModel.placeHolderText = '回复' + this.item.fromUserName + ':' | 286 | this.publishCommentModel.placeHolderText = '回复' + this.item.fromUserName + ':' |
| 1 | import { inputMethodEngine } from '@kit.IMEKit' | 1 | import { inputMethodEngine } from '@kit.IMEKit' |
| 2 | +import { commentInfo } from 'wdBean/Index' | ||
| 3 | +import { commentItemModel } from '../model/CommentModel' | ||
| 2 | import { publishCommentModel } from '../model/PublishCommentModel' | 4 | import { publishCommentModel } from '../model/PublishCommentModel' |
| 3 | import commentViewModel from '../viewmodel/CommentViewModel' | 5 | import commentViewModel from '../viewmodel/CommentViewModel' |
| 4 | 6 | ||
| @@ -22,9 +24,10 @@ export struct CommentCustomDialog { | @@ -22,9 +24,10 @@ export struct CommentCustomDialog { | ||
| 22 | let bean: Record<string, string> = {}; | 24 | let bean: Record<string, string> = {}; |
| 23 | // this.publishCommentModel.commentContent = this.commentText | 25 | // this.publishCommentModel.commentContent = this.commentText |
| 24 | //TODO 判断类型 | 26 | //TODO 判断类型 |
| 25 | - this.publishCommentModel.commentType = '1' | ||
| 26 | - commentViewModel.publishComment(this.publishCommentModel).then(() => { | 27 | + this.publishCommentModel.commentType = '2' |
| 28 | + commentViewModel.publishComment(this.publishCommentModel).then((model:commentItemModel) => { | ||
| 27 | this.publishCommentModel.commentContent = '' | 29 | this.publishCommentModel.commentContent = '' |
| 30 | + this.publishCommentModel.lastCommentModel = model | ||
| 28 | // this.commentText = '' | 31 | // this.commentText = '' |
| 29 | if (this.controller != null) { | 32 | if (this.controller != null) { |
| 30 | this.controller.close() | 33 | this.controller.close() |
| 1 | +import { EmitterEventId, EmitterUtils } from 'wdKit/Index' | ||
| 1 | import { publishCommentModel } from '../model/PublishCommentModel' | 2 | import { publishCommentModel } from '../model/PublishCommentModel' |
| 3 | +import { CommentCustomDialog } from './CommentCustomDialog' | ||
| 4 | + | ||
| 2 | 5 | ||
| 3 | @Preview | 6 | @Preview |
| 4 | @Component | 7 | @Component |
| @@ -8,6 +11,34 @@ export struct CommentTabComponent { | @@ -8,6 +11,34 @@ export struct CommentTabComponent { | ||
| 8 | @State type:number = 1 | 11 | @State type:number = 1 |
| 9 | @State placeHolder: string = '说两句...' | 12 | @State placeHolder: string = '说两句...' |
| 10 | 13 | ||
| 14 | + @State dialogController: CustomDialogController | null = null; | ||
| 15 | + | ||
| 16 | + /*回调方法*/ | ||
| 17 | + dialogControllerConfirm: () => void = () => {} | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + aboutToAppear() { | ||
| 22 | + | ||
| 23 | + this.dialogController = new CustomDialogController({ | ||
| 24 | + builder: CommentCustomDialog({ | ||
| 25 | + confirm: (value: Record<string, string>) => { | ||
| 26 | + this.dialogControllerConfirm(); | ||
| 27 | + EmitterUtils.sendEvent(EmitterEventId.COMMENT_PUBLISH,this.publishCommentModel.targetId) | ||
| 28 | + }, | ||
| 29 | + publishCommentModel:this.publishCommentModel | ||
| 30 | + }), | ||
| 31 | + autoCancel: true, | ||
| 32 | + alignment: DialogAlignment.Bottom, | ||
| 33 | + customStyle: true, | ||
| 34 | + offset: { | ||
| 35 | + dx: 0, | ||
| 36 | + dy: -20 | ||
| 37 | + }, | ||
| 38 | + }) | ||
| 39 | + | ||
| 40 | + } | ||
| 41 | + | ||
| 11 | build() { | 42 | build() { |
| 12 | Row(){ | 43 | Row(){ |
| 13 | Stack({alignContent:Alignment.Start}){ | 44 | Stack({alignContent:Alignment.Start}){ |
| @@ -15,6 +46,10 @@ export struct CommentTabComponent { | @@ -15,6 +46,10 @@ export struct CommentTabComponent { | ||
| 15 | Text(this.placeHolder).fontSize(12).fontColor('#999999').margin({left:10}) | 46 | Text(this.placeHolder).fontSize(12).fontColor('#999999').margin({left:10}) |
| 16 | } | 47 | } |
| 17 | }.width(151).height(30) | 48 | }.width(151).height(30) |
| 49 | + .onClick(()=>{ | ||
| 50 | + this.publishCommentModel.parentId = '-1'; | ||
| 51 | + this.dialogController?.open(); | ||
| 52 | + }) | ||
| 18 | } | 53 | } |
| 19 | } | 54 | } |
| 20 | 55 | ||
| @@ -25,25 +60,52 @@ export struct CommentIconComponent { | @@ -25,25 +60,52 @@ export struct CommentIconComponent { | ||
| 25 | /*展示类型*/ | 60 | /*展示类型*/ |
| 26 | @State type:number = 1 | 61 | @State type:number = 1 |
| 27 | 62 | ||
| 63 | + /*回调方法*/ | ||
| 64 | + onClickItem: () => void = () => {} | ||
| 65 | + | ||
| 28 | build() { | 66 | build() { |
| 29 | Row(){ | 67 | Row(){ |
| 30 | Stack({alignContent:Alignment.TopEnd}){ | 68 | Stack({alignContent:Alignment.TopEnd}){ |
| 31 | Image($r('app.media.comment_icon')).width(24).height(24) | 69 | Image($r('app.media.comment_icon')).width(24).height(24) |
| 32 | // Stack({alignContent:Alignment.Start}) { | 70 | // Stack({alignContent:Alignment.Start}) { |
| 33 | - // Image($r('app.media.comment_icon_number')).objectFit(ImageFit.Fill).width(12).height(12) | ||
| 34 | - Text(this.publishCommentModel.totalCommentNumer + '12345' +' ') | ||
| 35 | - .fontSize(8) | ||
| 36 | - .fontColor('#ffffff') | ||
| 37 | - // .backgroundColor('#ED2800') | ||
| 38 | - .height(12) | ||
| 39 | - .margin({ left: 6 }) | ||
| 40 | - .backgroundImage($r('app.media.comment_icon_number')) | ||
| 41 | - // }.width(25) | 71 | + RelativeContainer() { |
| 72 | + Image($r('app.media.comment_icon_number_bg')) | ||
| 73 | + .objectFit(ImageFit.Fill) | ||
| 74 | + .resizable({ slice: {top:1, left: 20 , right:1, bottom:1} }) | ||
| 75 | + .alignRules({ | ||
| 76 | + top: {anchor: "Text", align: VerticalAlign.Top}, | ||
| 77 | + left: {anchor: "Text", align: HorizontalAlign.Start}, | ||
| 78 | + right: {anchor: "Text", align: HorizontalAlign.End}, | ||
| 79 | + bottom : {anchor: "Text", align: VerticalAlign.Bottom}, | ||
| 80 | + }) | ||
| 81 | + // .offset({ | ||
| 82 | + // x:-6 | ||
| 83 | + // }) | ||
| 84 | + .id("Image") | ||
| 85 | + | ||
| 86 | + Text('123213123123123') | ||
| 87 | + .fontSize(8) | ||
| 88 | + .fontColor('#ffffff')// .backgroundColor('#ED2800') | ||
| 89 | + .height(12) | ||
| 90 | + .alignRules({ | ||
| 91 | + top: {anchor: "__container__", align: VerticalAlign.Top}, | ||
| 92 | + left: {anchor: "__container__", align: HorizontalAlign.Start} | ||
| 93 | + }) | ||
| 94 | + // .margin({left: 4,right:4 | ||
| 95 | + // }) | ||
| 96 | + /*动态计算文字宽度*/ | ||
| 97 | + .width(50) | ||
| 98 | + // .backgroundColor(Color.Green) | ||
| 99 | + .id("Text") | ||
| 100 | + | ||
| 101 | + } | ||
| 102 | + // } | ||
| 42 | 103 | ||
| 43 | .offset({ | 104 | .offset({ |
| 44 | x:12 | 105 | x:12 |
| 45 | }) | 106 | }) |
| 46 | } | 107 | } |
| 47 | }.width(24).height(24) | 108 | }.width(24).height(24) |
| 109 | + // .backgroundColor(Color.Blue) | ||
| 48 | } | 110 | } |
| 49 | } | 111 | } |
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
| @@ -185,37 +185,14 @@ export struct QualityCommentsComponent { | @@ -185,37 +185,14 @@ export struct QualityCommentsComponent { | ||
| 185 | Column() { | 185 | Column() { |
| 186 | Stack() { | 186 | Stack() { |
| 187 | this.titleHeader() | 187 | this.titleHeader() |
| 188 | - this.listLayout() | ||
| 189 | - | ||
| 190 | - // if(this.viewType == ViewType.ERROR){ | ||
| 191 | - // ErrorComponent() | ||
| 192 | - // }else if(this.viewType == ViewType.EMPTY){ | ||
| 193 | - // EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoComment}) | ||
| 194 | - // }else { | ||
| 195 | - // CustomPullToRefresh({ | ||
| 196 | - // alldata:[], | ||
| 197 | - // scroller:this.scroller, | ||
| 198 | - // customList:()=>{ | ||
| 199 | - // this.listLayout() | ||
| 200 | - // // this.testLayout() | ||
| 201 | - // }, | ||
| 202 | - // onRefresh:(resolve)=>{ | ||
| 203 | - // this.currentPage = 1 | ||
| 204 | - // this.getData(resolve) | ||
| 205 | - // }, | ||
| 206 | - // onLoadMore:(resolve)=> { | ||
| 207 | - // if (this.hasMore === false) { | ||
| 208 | - // if(resolve) resolve('') | ||
| 209 | - // return | ||
| 210 | - // } | ||
| 211 | - // this.currentPage++ | ||
| 212 | - // this.getData(resolve) | ||
| 213 | - // } | ||
| 214 | - // }) | ||
| 215 | - // } | ||
| 216 | - | ||
| 217 | - | ||
| 218 | 188 | ||
| 189 | + if(this.viewType == ViewType.ERROR){ | ||
| 190 | + ErrorComponent() | ||
| 191 | + }else if(this.viewType == ViewType.EMPTY){ | ||
| 192 | + EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoComment}) | ||
| 193 | + }else { | ||
| 194 | + this.listLayout() | ||
| 195 | + } | ||
| 219 | 196 | ||
| 220 | }.alignContent(Alignment.Top) | 197 | }.alignContent(Alignment.Top) |
| 221 | }.backgroundColor(this.currentWindowColor).width('100%') | 198 | }.backgroundColor(this.currentWindowColor).width('100%') |
| @@ -251,12 +228,15 @@ export struct QualityCommentsComponent { | @@ -251,12 +228,15 @@ export struct QualityCommentsComponent { | ||
| 251 | ListItem() { | 228 | ListItem() { |
| 252 | 229 | ||
| 253 | }.height(this.bottomSafeHeight) | 230 | }.height(this.bottomSafeHeight) |
| 254 | - } | 231 | + }.onReachEnd(()=>{ |
| 232 | + this.currentPage++ | ||
| 233 | + this.getData() | ||
| 234 | + }) | ||
| 255 | .margin({ top: 196 }) | 235 | .margin({ top: 196 }) |
| 256 | .height("100%") | 236 | .height("100%") |
| 257 | .width("100%") | 237 | .width("100%") |
| 258 | - .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果 | ||
| 259 | - // .edgeEffect(EdgeEffect.Spring) | 238 | + // .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果 |
| 239 | + .edgeEffect(EdgeEffect.Spring) | ||
| 260 | .nestedScroll({ | 240 | .nestedScroll({ |
| 261 | scrollForward: NestedScrollMode.PARENT_FIRST, | 241 | scrollForward: NestedScrollMode.PARENT_FIRST, |
| 262 | scrollBackward: NestedScrollMode.SELF_FIRST | 242 | scrollBackward: NestedScrollMode.SELF_FIRST |
| @@ -148,7 +148,7 @@ class CommentViewModel { | @@ -148,7 +148,7 @@ class CommentViewModel { | ||
| 148 | bean['userName'] = UserDataLocal.getUserId(); | 148 | bean['userName'] = UserDataLocal.getUserId(); |
| 149 | bean['userHeaderUrl'] = UserDataLocal.getUserHeaderUrl(); | 149 | bean['userHeaderUrl'] = UserDataLocal.getUserHeaderUrl(); |
| 150 | 150 | ||
| 151 | - HttpRequest.post<ResponseDTO<commentStatusModel[]>>(url, bean, headers).then((data: ResponseDTO<commentStatusModel[]>) => { | 151 | + HttpBizUtil.post<ResponseDTO<commentStatusModel[]>>(url, bean, headers).then((data: ResponseDTO<commentStatusModel[]>) => { |
| 152 | if (data.code != 0) { | 152 | if (data.code != 0) { |
| 153 | fail() | 153 | fail() |
| 154 | return | 154 | return |
| @@ -164,7 +164,7 @@ class CommentViewModel { | @@ -164,7 +164,7 @@ class CommentViewModel { | ||
| 164 | /*发布评论*/ | 164 | /*发布评论*/ |
| 165 | publishComment(model: publishCommentModel) { | 165 | publishComment(model: publishCommentModel) { |
| 166 | 166 | ||
| 167 | - return new Promise<void>((success, fail) => { | 167 | + return new Promise<commentItemModel>((success, fail) => { |
| 168 | let url = HttpUrlUtils.getPublishCommentUrl() | 168 | let url = HttpUrlUtils.getPublishCommentUrl() |
| 169 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 169 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 170 | let bean: Record<string, string> = {}; | 170 | let bean: Record<string, string> = {}; |
| @@ -182,14 +182,15 @@ class CommentViewModel { | @@ -182,14 +182,15 @@ class CommentViewModel { | ||
| 182 | bean['targetType'] = model.targetType | 182 | bean['targetType'] = model.targetType |
| 183 | bean['parentId'] = model.parentId | 183 | bean['parentId'] = model.parentId |
| 184 | 184 | ||
| 185 | - HttpRequest.post<ResponseDTO<commentStatusModel[]>>(url, bean, headers).then((data: ResponseDTO<commentStatusModel[]>) => { | 185 | + HttpRequest.post<ResponseDTO<commentItemModel>>(url, bean, headers).then((data: ResponseDTO<commentItemModel>) => { |
| 186 | if (data.code != 0) { | 186 | if (data.code != 0) { |
| 187 | ToastUtils.showToast(data.message, 1000); | 187 | ToastUtils.showToast(data.message, 1000); |
| 188 | fail() | 188 | fail() |
| 189 | return | 189 | return |
| 190 | } | 190 | } |
| 191 | ToastUtils.showToast(data.message, 1000); | 191 | ToastUtils.showToast(data.message, 1000); |
| 192 | - success() | 192 | + let model = data.data as commentItemModel |
| 193 | + success(model) | ||
| 193 | }, (error: Error) => { | 194 | }, (error: Error) => { |
| 194 | ToastUtils.showToast('评论失败', 1000); | 195 | ToastUtils.showToast('评论失败', 1000); |
| 195 | fail() | 196 | fail() |
| @@ -240,7 +241,7 @@ class CommentViewModel { | @@ -240,7 +241,7 @@ class CommentViewModel { | ||
| 240 | let promiseArray: Promise<commentStatusListModel | void>[] = []; | 241 | let promiseArray: Promise<commentStatusListModel | void>[] = []; |
| 241 | 242 | ||
| 242 | //未登录不用批查 | 243 | //未登录不用批查 |
| 243 | - if (HttpUrlUtils.getUserId()){ | 244 | + if (HttpUrlUtils.getUserId()) { |
| 244 | if (commentIDs.length > 0) { | 245 | if (commentIDs.length > 0) { |
| 245 | let promise1 = new Promise<void>((success) => { | 246 | let promise1 = new Promise<void>((success) => { |
| 246 | // HttpRequest HttpBizUtil | 247 | // HttpRequest HttpBizUtil |
| @@ -285,7 +286,7 @@ class CommentViewModel { | @@ -285,7 +286,7 @@ class CommentViewModel { | ||
| 285 | }) | 286 | }) |
| 286 | promiseArray.push(promise1); | 287 | promiseArray.push(promise1); |
| 287 | } | 288 | } |
| 288 | - } | 289 | + } |
| 289 | if (fromUserIDs.length > 0) { | 290 | if (fromUserIDs.length > 0) { |
| 290 | let promise2 = new Promise<void>((success) => { | 291 | let promise2 = new Promise<void>((success) => { |
| 291 | let url = HttpUrlUtils.getBatchUserUrl(); | 292 | let url = HttpUrlUtils.getBatchUserUrl(); |
| @@ -386,8 +387,6 @@ class CommentViewModel { | @@ -386,8 +387,6 @@ class CommentViewModel { | ||
| 386 | 387 | ||
| 387 | } | 388 | } |
| 388 | 389 | ||
| 389 | - | ||
| 390 | - | ||
| 391 | deepCopyCommentItemModel(model: commentItemModel) { | 390 | deepCopyCommentItemModel(model: commentItemModel) { |
| 392 | let newModel = new commentItemModel() | 391 | let newModel = new commentItemModel() |
| 393 | 392 | ||
| @@ -411,10 +410,13 @@ class CommentViewModel { | @@ -411,10 +410,13 @@ class CommentViewModel { | ||
| 411 | newModel.fromUserHeader = model.fromUserHeader | 410 | newModel.fromUserHeader = model.fromUserHeader |
| 412 | newModel.fromUserId = model.fromUserId | 411 | newModel.fromUserId = model.fromUserId |
| 413 | newModel.fromUserName = model.fromUserName | 412 | newModel.fromUserName = model.fromUserName |
| 414 | - newModel.fromUserType = model.fromUserType | 413 | + if (model.toUserType != null) { |
| 414 | + newModel.fromUserType = model.fromUserType | ||
| 415 | + } | ||
| 415 | newModel.id = model.id | 416 | newModel.id = model.id |
| 416 | - newModel.likeNum = model.likeNum.toString() | ||
| 417 | - | 417 | + if (model.likeNum) { |
| 418 | + newModel.likeNum = model.likeNum.toString() | ||
| 419 | + } | ||
| 418 | if (Number.parseInt(newModel.likeNum) <= 0) { | 420 | if (Number.parseInt(newModel.likeNum) <= 0) { |
| 419 | newModel.likeNum = '' | 421 | newModel.likeNum = '' |
| 420 | } | 422 | } |
-
Please register or login to post a comment