yangsunyue_wd

desc:评论列表界面

@@ -555,6 +555,12 @@ export class HttpUrlUtils { @@ -555,6 +555,12 @@ export class HttpUrlUtils {
555 return url 555 return url
556 } 556 }
557 557
  558 + /*获取子评论列表*/
  559 + static getChildContentCommentListDataUrl() {
  560 + let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/childCommentList"
  561 + return url
  562 + }
  563 +
558 /*评论状态*/ 564 /*评论状态*/
559 static getBatchCommentStatusUrl() { 565 static getBatchCommentStatusUrl() {
560 let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/batchCommentStatus" 566 let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/batchCommentStatus"
@@ -567,6 +573,18 @@ export class HttpUrlUtils { @@ -567,6 +573,18 @@ export class HttpUrlUtils {
567 return url 573 return url
568 } 574 }
569 575
  576 + /*发布评论*/
  577 + static getPublishCommentUrl() {
  578 + let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/publish"
  579 + return url
  580 + }
  581 +
  582 + /*游客发布评论*/
  583 + static getNoUserPublishCommentUrl() {
  584 + let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/commentLike"
  585 + return url
  586 + }
  587 +
570 /*levleIcon*/ 588 /*levleIcon*/
571 static getBatchUserUrl() { 589 static getBatchUserUrl() {
572 let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-point/auth/level/zh/c/batchUser" 590 let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-point/auth/level/zh/c/batchUser"
  1 +import { LazyDataSource } from 'wdKit/Index'
1 import PageModel from '../../../viewmodel/PageModel' 2 import PageModel from '../../../viewmodel/PageModel'
2 3
3 4
@@ -11,13 +12,13 @@ export enum WDPublicUserType { @@ -11,13 +12,13 @@ export enum WDPublicUserType {
11 WDPublicUserType_Unkown = 0, 12 WDPublicUserType_Unkown = 0,
12 13
13 /// 普通用户 14 /// 普通用户
14 - WDPublicUserType_NormalUser = 1, 15 + WDPublicUserType_NormalUser = 1,
15 16
16 /// 号主 17 /// 号主
17 - WDPublicUserType_AccountOwner = 2, 18 + WDPublicUserType_AccountOwner = 2,
18 19
19 /// 矩阵号 20 /// 矩阵号
20 - WDPublicUserType_Matrix = 3, 21 + WDPublicUserType_Matrix = 3,
21 22
22 /// 运营子账号 23 /// 运营子账号
23 WDPublicUserType_OperatingSubAccount = 4, 24 WDPublicUserType_OperatingSubAccount = 4,
@@ -27,16 +28,23 @@ export enum WDPublicUserType { @@ -27,16 +28,23 @@ export enum WDPublicUserType {
27 } 28 }
28 29
29 @Observed 30 @Observed
30 -export class commentListModel extends PageModel{  
31 - pageNum: number = 0  
32 - pageSize: number = 0 31 +export class commentListModel extends PageModel {
  32 + pageNum: number = 1
  33 + pageSize: number = 10
33 totalCount: number = 0 34 totalCount: number = 0
34 hasNext: number = 0 35 hasNext: number = 0
35 list: commentItemModel[] = [] 36 list: commentItemModel[] = []
  37 + // constructor(pageNum:number, pageSize:number, totalCount: number, hasNext: number, list: commentItemModel[]) {
  38 + // super()
  39 + // this.pageNum = pageNum
  40 + // this.pageSize = pageSize
  41 + // this.totalCount = totalCount
  42 + // this.hasNext = hasNext
  43 + // this.list = list
  44 + // }
36 } 45 }
37 46
38 47
39 -  
40 @Observed 48 @Observed
41 export class commentItemModel { 49 export class commentItemModel {
42 authorLike: string = '' 50 authorLike: string = ''
@@ -44,6 +52,7 @@ export class commentItemModel { @@ -44,6 +52,7 @@ export class commentItemModel {
44 checkStatus: string = '' 52 checkStatus: string = ''
45 childCommentNum: string = '' 53 childCommentNum: string = ''
46 childComments: commentItemModel[] = [] 54 childComments: commentItemModel[] = []
  55 + childCommentsLazyDataSource: LazyDataSource<commentItemModel> = new LazyDataSource()
47 commentContent: string = '' 56 commentContent: string = ''
48 commentContentSensitive: string = '' 57 commentContentSensitive: string = ''
49 commentLevel: number = 0 58 commentLevel: number = 0
@@ -60,8 +69,7 @@ export class commentItemModel { @@ -60,8 +69,7 @@ export class commentItemModel {
60 fromUserName: string = '' 69 fromUserName: string = ''
61 fromUserType: WDPublicUserType = 0 70 fromUserType: WDPublicUserType = 0
62 id: string = '' 71 id: string = ''
63 - likeNum: string = ''  
64 - 72 + likeNum: string = '0'
65 mySelf: string = '' 73 mySelf: string = ''
66 parentId: string = '' 74 parentId: string = ''
67 region: string = '' 75 region: string = ''
@@ -77,36 +85,32 @@ export class commentItemModel { @@ -77,36 +85,32 @@ export class commentItemModel {
77 uuid: string = '' 85 uuid: string = ''
78 /*本地使用,收起时默认3行 -1为不限制行数*/ 86 /*本地使用,收起时默认3行 -1为不限制行数*/
79 maxLine: number = 3 87 maxLine: number = 3
80 -  
81 /*是否有展示更多*/ 88 /*是否有展示更多*/
82 - hasMore:boolean = false 89 + hasMore: boolean = false
83 /*当有展示更多的时候,当前的状态是展开还是收起*/ 90 /*当有展示更多的时候,当前的状态是展开还是收起*/
84 - expanded:boolean = false  
85 -  
86 - highQualityExpireTime:string = '';  
87 - highQualityTime:string = '';  
88 - targetTitle:string = '';  
89 - targetStatus:string = '';  
90 - targetId:string = '';  
91 - targetRelId:string = '';  
92 - targetRelObjectId:string = '';  
93 - targetRelType:string = '';  
94 - targetType:string = '';  
95 - visitorComment:string = '';  
96 - shareInfo:commentItemShareInfoModel = new commentItemShareInfoModel;  
97 -  
98 - api_commentId:string = ''; 91 + expanded: boolean = false
  92 + /*是否正在加载子评论*/
  93 + isLoading: boolean = false
  94 + highQualityExpireTime: string = '';
  95 + highQualityTime: string = '';
  96 + targetTitle: string = '';
  97 + targetStatus: string = '';
  98 + targetId: string = '';
  99 + targetRelId: string = '';
  100 + targetRelObjectId: string = '';
  101 + targetRelType: string = '';
  102 + targetType: string = '';
  103 + visitorComment: string = '';
  104 + shareInfo: commentItemShareInfoModel = new commentItemShareInfoModel;
  105 + api_commentId: string = '';
99 /*评论点赞状态 0-未点赞 1-已点赞*/ 106 /*评论点赞状态 0-未点赞 1-已点赞*/
100 - api_status:boolean = false;  
101 -  
102 - api_level:string = '';  
103 - api_levelHead:string = 'http';  
104 - api_userId:string = '';  
105 -  
106 - api_creatorId:string = '';  
107 - api_userType:string = '';  
108 - api_authIcon:string = '';  
109 - 107 + api_status: boolean = false;
  108 + api_level: string = '';
  109 + api_levelHead: string = 'http';
  110 + api_userId: string = '';
  111 + api_creatorId: string = '';
  112 + api_userType: string = '';
  113 + api_authIcon: string = '';
110 } 114 }
111 115
112 @Observed 116 @Observed
@@ -118,7 +122,7 @@ export class commentItemShareInfoModel { @@ -118,7 +122,7 @@ export class commentItemShareInfoModel {
118 } 122 }
119 123
120 @Observed 124 @Observed
121 -export class commentStatusListModel extends PageModel{ 125 +export class commentStatusListModel extends PageModel {
122 pageNum: number = 0 126 pageNum: number = 0
123 pageSize: number = 0 127 pageSize: number = 0
124 totalCount: number = 0 128 totalCount: number = 0
@@ -129,18 +133,17 @@ export class commentStatusListModel extends PageModel{ @@ -129,18 +133,17 @@ export class commentStatusListModel extends PageModel{
129 133
130 @Observed 134 @Observed
131 export class commentStatusModel { 135 export class commentStatusModel {
132 - commentId:string = '';  
133 - status:boolean = false;  
134 -  
135 - level:string = '';  
136 - levelHead:string = '';  
137 - userId:string = ''; 136 + commentId: string = '';
  137 + status: boolean = false;
  138 + level: string = '';
  139 + levelHead: string = '';
  140 + userId: string = '';
  141 + creatorId: string = '';
  142 + userType: string = '';
  143 + authIcon: string = '';
  144 +}
138 145
139 146
140 - creatorId:string = '';  
141 - userType:string = '';  
142 - authIcon:string = '';  
143 147
144 -}  
145 148
146 149
  1 +import { commentItemModel } from './CommentModel';
  2 +
  3 +class BasicDataSource implements IDataSource {
  4 + private listeners: DataChangeListener[] = [];
  5 + private originDataArray: commentItemModel[] = [];
  6 +
  7 + public totalCount(): number {
  8 + return 0;
  9 + }
  10 +
  11 + public getData(index: number): commentItemModel {
  12 + return this.originDataArray[index];
  13 + }
  14 +
  15 + registerDataChangeListener(listener: DataChangeListener): void {
  16 + if (this.listeners.indexOf(listener) < 0) {
  17 + console.info('add listener');
  18 + this.listeners.push(listener);
  19 + }
  20 + }
  21 +
  22 + unregisterDataChangeListener(listener: DataChangeListener): void {
  23 + const pos = this.listeners.indexOf(listener);
  24 + if (pos >= 0) {
  25 + console.info('remove listener');
  26 + this.listeners.splice(pos, 1);
  27 + }
  28 + }
  29 +
  30 + notifyDataReload(): void {
  31 + this.listeners.forEach(listener => {
  32 + listener.onDataReloaded();
  33 + })
  34 + }
  35 +
  36 + notifyDataAdd(index: number): void {
  37 + this.listeners.forEach(listener => {
  38 + listener.onDataAdd(index);
  39 + })
  40 + }
  41 +
  42 + notifyDataChange(index: number): void {
  43 + this.listeners.forEach(listener => {
  44 + listener.onDataChange(index);
  45 + })
  46 + }
  47 +
  48 + notifyDataDelete(index: number): void {
  49 + this.listeners.forEach(listener => {
  50 + listener.onDataDelete(index);
  51 + })
  52 + }
  53 +
  54 + notifyDataMove(from: number, to: number): void {
  55 + this.listeners.forEach(listener => {
  56 + listener.onDataMove(from, to);
  57 + })
  58 + }
  59 +}
  60 +
  61 +export class MyCommentDataSource extends BasicDataSource {
  62 + private dataArray: commentItemModel[] = [];
  63 +
  64 + public totalCount(): number {
  65 + return this.dataArray.length;
  66 + }
  67 +
  68 + public getData(index: number): commentItemModel {
  69 + return this.dataArray[index];
  70 + }
  71 +
  72 + public addData(index: number, data: commentItemModel): void {
  73 + this.dataArray.splice(index, 0, data);
  74 + this.notifyDataAdd(index);
  75 + }
  76 +
  77 + public pushData(data: commentItemModel): void {
  78 + this.dataArray.push(data);
  79 + this.notifyDataAdd(this.dataArray.length - 1);
  80 + }
  81 +}
  1 +@Observed
  2 +export class publishCommentModel {
  3 + /*被评论的内容id*/
  4 + targetId: string = ""
  5 + /*被评论的内容关系id*/
  6 + targetRelId: string = ""
  7 + /*1.文字 2.文字+表情 3.定制表情(客户端写死) 4.图片*/
  8 + commentType: string = '1'
  9 + /*根评论id,如果是一级评论,传-1;否则,传当前评论所属的根评论id*/
  10 + rootCommentId: string = "-1"
  11 + /*【迭代二新增】内容的标题,取bff内容详情接口中newsTitle字段*/
  12 + targetTitle: string = ""
  13 + /*被评论的内容关系类型,1.频道关系;2.专题关系;【人民号内容为空】默认0*/
  14 + targetRelType: string = ''
  15 + /*【迭代二新增】关联的频道id/专题id;*/
  16 + targetRelObjectId: string = ""
  17 + /*评论图片url,多个逗号隔开*/
  18 + commentPics: string = ""
  19 + /*评论内容*/
  20 + commentContent: string = ""
  21 + /*【迭代二新增】是否是重点稿件 1是 0否*/
  22 + keyArticle: string = ''
  23 + /*内容类别, 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,14:动态(13和14为中文版新增)*/
  24 + targetType: string = ''
  25 + /*父评论id,如果是其它评论的回复,该字段必填*/
  26 + parentId: string = "-1"
  27 +
  28 +
  29 + placeHolderText: string = "优质评论会获得最佳评论人的称号"
  30 +
  31 +}
  32 +
  33 +
@@ -6,38 +6,68 @@ import { commentItemModel, commentListModel, WDPublicUserType } from '../model/C @@ -6,38 +6,68 @@ import { commentItemModel, commentListModel, WDPublicUserType } from '../model/C
6 import commentViewModel from '../viewmodel/CommentViewModel' 6 import commentViewModel from '../viewmodel/CommentViewModel'
7 import { CommentText } from './CommentText'; 7 import { CommentText } from './CommentText';
8 import measure from '@ohos.measure' 8 import measure from '@ohos.measure'
9 -import {CommentCustomDialog} from './CommentCustomDialog' 9 +import { CommentCustomDialog } from './CommentCustomDialog'
  10 +import { publishCommentModel } from '../model/PublishCommentModel';
  11 +import { ifaa } from '@kit.OnlineAuthenticationKit';
10 12
11 const TAG = 'CommentComponent'; 13 const TAG = 'CommentComponent';
12 14
13 15
14 -  
15 -  
16 -  
17 -@Entry 16 +// @Entry
18 @Preview 17 @Preview
19 @Component 18 @Component
20 export struct CommentComponent { 19 export struct CommentComponent {
21 - @State private browSingModel: commentListModel = new commentListModel() 20 + @State contentId: string = '30004266013'
  21 + /*内容类别, 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,14:动态(13和14为中文版新增)*/
  22 + @State contentType: string = '8'
  23 + /*内容的标题,取bff内容详情接口中newsTitle字段*/
  24 + @State targetTitle: string = '北约同意向乌克兰提供防空系统在内的更多军事支持'
  25 + /*被评论的内容关系id*/
  26 + @State targetRelId: string = "500002849023"
  27 + /*关联的频道id/专题id*/
  28 + @State targetRelObjectId: string = "2002"
  29 + /*是否是重点稿件 1是 0否*/
  30 + @State keyArticle: string = "0"
  31 + /*被评论的内容关系类型,1.频道关系;2.专题关系;【人民号内容为空】默认0*/
  32 + @State targetRelType: string = "1"
  33 + // @State private browSingModel: commentListModel = new commentListModel()
22 isloading: boolean = false 34 isloading: boolean = false
23 @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource(); 35 @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource();
24 -  
25 - dialogController: CustomDialogController = new CustomDialogController({  
26 - builder: CommentCustomDialog(), 36 + @State publishCommentModel: publishCommentModel = new publishCommentModel()
  37 + @State dialogController: CustomDialogController | null = new CustomDialogController({
  38 +
  39 + builder: CommentCustomDialog({
  40 + confirm: (value: Record<string, string>) => {
  41 + this.publishComment(value)
  42 + },
  43 + commentText: this.publishCommentModel.commentContent,
  44 + placeHolderText: this.publishCommentModel.placeHolderText,
  45 + }),
27 autoCancel: true, 46 autoCancel: true,
28 alignment: DialogAlignment.Bottom, 47 alignment: DialogAlignment.Bottom,
29 customStyle: true, 48 customStyle: true,
30 offset: { 49 offset: {
31 dx: 0, 50 dx: 0,
32 dy: -20 51 dy: -20
33 - } 52 + },
34 }) 53 })
35 54
  55 + // 在自定义组件即将析构销毁时将dialogControlle置空
  56 + aboutToDisappear() {
  57 + this.dialogController = null // 将dialogController置空
  58 + }
  59 +
36 aboutToAppear() { 60 aboutToAppear() {
  61 + this.publishCommentModel.targetTitle = this.targetTitle
  62 + this.publishCommentModel.targetId = this.contentId
  63 + this.publishCommentModel.targetType = this.contentType
  64 + this.publishCommentModel.targetRelId = this.targetRelId
  65 + this.publishCommentModel.targetRelType = this.targetRelType
  66 + this.publishCommentModel.targetRelObjectId = this.targetRelObjectId
  67 + this.publishCommentModel.keyArticle = this.keyArticle
  68 +
37 this.getData(); 69 this.getData();
38 - this.getData();  
39 - this.getData();  
40 - this.getData(); 70 +
41 } 71 }
42 72
43 /*标题:全部评论*/ 73 /*标题:全部评论*/
@@ -64,109 +94,346 @@ export struct CommentComponent { @@ -64,109 +94,346 @@ export struct CommentComponent {
64 94
65 /*1级评论作为titleHeader*/ 95 /*1级评论作为titleHeader*/
66 @Builder 96 @Builder
67 - CommentHeaderItem(item: commentItemModel) { 97 + CommentHeaderItem(item: commentItemModel, index: number) {
  98 + commentHeaderView({
  99 + item: item,
  100 + dialogController: this.dialogController,
  101 + publishCommentModel: this.publishCommentModel
  102 + })
  103 + }
  104 +
  105 + /*查看更多和收起*/
  106 + @Builder
  107 + GroupFooterView(item: commentItemModel, index: number) {
  108 + footerExpandedView({ item: item, contentId: this.contentId, contentType: this.contentType })
  109 + }
  110 +
  111 + build() {
  112 + Column() {
  113 + List() {
  114 + ListItemGroup({ header: this.titleHeader() })
  115 +
  116 + LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {
  117 + if (item.hasMore) {
  118 + ListItemGroup({ header: this.CommentHeaderItem(item, index), footer: this.GroupFooterView(item, index) }) {
  119 + LazyForEach(item.childCommentsLazyDataSource, (childItem: commentItemModel, subIndex: number) => {
  120 + ListItem() {
  121 + ChildCommentItem({
  122 + item: childItem,
  123 + dialogController: this.dialogController,
  124 + publishCommentModel: this.publishCommentModel
  125 + });
  126 + }
  127 + .onClick(() => {
  128 + console.log(TAG)
  129 + })
  130 + })
  131 + }
  132 + } else {
  133 + ListItemGroup({ header: this.CommentHeaderItem(item, index) }) {
  134 + LazyForEach(item.childCommentsLazyDataSource, (childItem: commentItemModel, subIndex: number) => {
  135 + ListItem() {
  136 + ChildCommentItem({
  137 + item: childItem,
  138 + dialogController: this.dialogController,
  139 + publishCommentModel: this.publishCommentModel
  140 + });
  141 + }
  142 + .onClick(() => {
  143 + console.log(TAG)
  144 + })
  145 + })
  146 + }
  147 + }
  148 + })
  149 + }.layoutWeight(1)
  150 + }
  151 + }
  152 +
  153 + //获取数据
  154 + async getData() {
  155 + commentViewModel.fetchContentCommentList('1', this.contentId, this.contentType).then(commentListModel => {
  156 + if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
  157 + commentListModel.list.forEach(element => {
  158 + element.hasMore = Number.parseInt(element.childCommentNum) ? true : false
  159 + let newModel = commentViewModel.deepCopyCommentItemModel(element)
  160 + newModel.targetId = this.contentId
  161 + newModel.targetType = this.contentType
  162 + this.allDatas.push(newModel)
  163 + });
  164 +
  165 +
  166 + }
  167 + })
  168 +
  169 + }
  170 +
  171 + /*回复评论*/
  172 + publishComment(value: Record<string, string>) {
  173 +
  174 + this.publishCommentModel.commentContent = value['commentContent']
  175 + this.publishCommentModel.commentType = value['commentType']
  176 +
  177 + commentViewModel.publishComment(this.publishCommentModel).then(() => {
  178 + this.publishCommentModel.commentContent = ''
  179 + }).catch(() => {
  180 +
  181 + })
  182 +
  183 + }
  184 +}
  185 +
  186 +
  187 +@Component
  188 +struct ChildCommentItem {
  189 + @Link publishCommentModel: publishCommentModel
  190 + @Link dialogController: CustomDialogController | null
  191 + @ObjectLink item: commentItemModel
  192 +
  193 + build() {
68 Column() { 194 Column() {
69 Row() { 195 Row() {
70 //头像 196 //头像
71 Stack() { 197 Stack() {
72 - Image(item.fromUserHeader) 198 + Image(this.item.fromUserHeader)
73 .alt($r('app.media.default_head')) 199 .alt($r('app.media.default_head'))
74 - .width('32')  
75 - .height('32') 200 + .width('24')
  201 + .height('24')
76 .objectFit(ImageFit.Cover) 202 .objectFit(ImageFit.Cover)
77 .borderRadius(16) 203 .borderRadius(16)
78 - Image(item.api_levelHead)  
79 - .width('48')  
80 - .height('48') 204 + Image(this.item.api_levelHead)
  205 + .width('36')
  206 + .height('36')
81 .objectFit(ImageFit.Cover) 207 .objectFit(ImageFit.Cover)
82 .borderRadius(24) 208 .borderRadius(24)
83 } 209 }
84 .width(48) 210 .width(48)
85 .height(48) 211 .height(48)
86 - .margin({ left: 8 }) 212 + .margin({ left: 47 })
87 .alignContent(Alignment.Center) 213 .alignContent(Alignment.Center)
88 .onClick(() => { 214 .onClick(() => {
89 // TODO 跳转个人详情 215 // TODO 跳转个人详情
90 }) 216 })
91 217
92 //昵称 218 //昵称
93 - Text(item.fromUserName)  
94 - .fontSize(14)  
95 - .fontColor($r('app.color.color_222222'))  
96 - .fontWeight(FontWeight.Medium)  
97 - .margin({ left: 5 }) 219 + Text() {
  220 + Span(this.item.fromUserName)
  221 + if (this.item.toUserName) {
  222 + Span(' ')
  223 + ImageSpan($r('app.media.comment_reply')).size({ width: 6, height: 9 }).offset({ y: -2.5 })
  224 + Span(' ')
  225 + Span(this.item.toUserName)
  226 + }
  227 + }
  228 + .maxLines(1)
  229 + .layoutWeight(1)
  230 + .fontSize(14)
  231 + .fontColor($r('app.color.color_222222'))
  232 + .fontWeight(FontWeight.Medium)
  233 + .margin({ left: 0 , right:0})
98 234
99 235
100 /// 暂时不显示 “我” 的标签了 236 /// 暂时不显示 “我” 的标签了
101 /// 人民号>置顶>作者 237 /// 人民号>置顶>作者
102 238
103 //人民号 239 //人民号
104 - // if (item.fromUserType === WDPublicUserType.WDPublicUserType_Matrix) {  
105 - Image($r('app.media.comment_rmh_tag')).width(20).height(20).margin({ left: 5 });  
106 - // } 240 + if (this.item.fromUserType === WDPublicUserType.WDPublicUserType_Matrix) {
  241 + Image($r('app.media.comment_rmh_tag')).width(20).height(20).margin({ left: 5 });
  242 + }
107 //置顶 243 //置顶
108 - // if (item.topFlag) {  
109 - Image($r('app.media.comment_icon_zhiding')).width(30).height(18).margin({ left: 5 });  
110 - // } 244 + if (this.item.topFlag) {
  245 + Image($r('app.media.comment_icon_zhiding')).width(30).height(18).margin({ left: 5 });
  246 + }
111 //作者 247 //作者
112 - // if (item.contentAuthor === 1) {  
113 - Text('作者')  
114 - .fontSize(11)  
115 - .fontColor('#968562')  
116 - .backgroundColor('#F1EFEB')  
117 - .textAlign(TextAlign.Center)  
118 - .borderRadius(2)  
119 - .width(30)  
120 - .height(18)  
121 - .margin({ left: 5 });  
122 - // }  
123 - } 248 + if (this.item.contentAuthor === 1) {
  249 + Text('作者')
  250 + .fontSize(11)
  251 + .fontColor('#968562')
  252 + .backgroundColor('#F1EFEB')
  253 + .textAlign(TextAlign.Center)
  254 + .borderRadius(2)
  255 + .width(30)
  256 + .height(18)
  257 + .margin({ left: 5 });
  258 + }
  259 + }.margin({ left: 0, right: 16 })
  260 + // .backgroundColor(Color.Red)
124 261
125 CommentText({ 262 CommentText({
126 - longMessage: item.commentContent, 263 + longMessage: this.item.commentContent,
127 maxline: 3, 264 maxline: 3,
128 - fontSize: 16, 265 + fontSize: 14,
129 fontWeight: FontWeight.Regular, 266 fontWeight: FontWeight.Regular,
130 - marginWidth: (59 + 16) 267 + marginWidth: (95 + 16)
131 }) 268 })
132 - .margin({ left: 59, right: 16 }) 269 + .margin({ left: 95, right: 16, top: -5 })
  270 + .onClick(() => {
  271 + this.publishCommentModel.rootCommentId = this.item.rootCommentId
  272 + this.publishCommentModel.parentId = this.item.id
  273 + this.publishCommentModel.placeHolderText = '回复' + this.item.fromUserName + ':'
  274 + if (this.dialogController != null) {
  275 + this.dialogController.open()
  276 + }
  277 + })
133 278
134 279
135 - this.CommentFooterView(item); 280 + commentFooterView({
  281 + item: this.item,
  282 + dialogController: this.dialogController,
  283 + publishCommentModel: this.publishCommentModel
  284 + }).margin({ left: 95, right: 16 })
136 }.alignItems(HorizontalAlign.Start) 285 }.alignItems(HorizontalAlign.Start)
137 - 286 + .width('100%')
138 } 287 }
  288 +}
139 289
140 - /*查看更多和收起*/  
141 - @Builder  
142 - GroupFooterView(item: commentItemModel) { 290 +
  291 +@Component
  292 +struct footerExpandedView {
  293 + @ObjectLink item: commentItemModel
  294 + contentId: string = ''
  295 + contentType: string = ''
  296 +
  297 + build() {
143 Row() { 298 Row() {
144 - if (item.expanded){ 299 + if (this.item.expanded) {
145 Row() { 300 Row() {
146 Text('收起').fontColor($r('app.color.color_222222')).fontSize(14) 301 Text('收起').fontColor($r('app.color.color_222222')).fontSize(14)
147 Image($r('app.media.comment_pickUp')).width(12).height(12) 302 Image($r('app.media.comment_pickUp')).width(12).height(12)
148 }.margin({ left: 213 }) 303 }.margin({ left: 213 })
149 - }else { 304 + .onClick(() => {
  305 + this.item.expanded = !this.item.expanded
  306 + this.item.childComments = []
  307 + this.item.childCommentsLazyDataSource.clear()
  308 + })
  309 + } else {
150 Row() { 310 Row() {
151 Text().backgroundColor($r('app.color.color_EDEDED')).width(24).height(1) 311 Text().backgroundColor($r('app.color.color_EDEDED')).width(24).height(1)
152 Text('查看更多回复').fontColor($r('app.color.color_222222')).fontSize(14).margin({ left: 6 }) 312 Text('查看更多回复').fontColor($r('app.color.color_222222')).fontSize(14).margin({ left: 6 })
153 Image($r('app.media.comment_unfold')).width(12).height(12) 313 Image($r('app.media.comment_unfold')).width(12).height(12)
154 }.margin({ left: 53 }) 314 }.margin({ left: 53 })
  315 + .onClick(() => {
  316 + if (this.item.isLoading) {
  317 + return
  318 + }
  319 + this.item.isLoading = true
  320 + //load child
  321 + commentViewModel.fetchChildContentCommentList('1', this.contentId, this.contentType, this.item.id)
  322 + .then((commentListModel) => {
  323 + this.item.isLoading = false
  324 + this.item.expanded = !this.item.expanded
  325 + commentListModel.list.forEach(element => {
  326 + this.item.childComments.push(element)
  327 + let newModel = commentViewModel.deepCopyCommentItemModel(element)
  328 + newModel.targetId = this.contentId
  329 + newModel.targetType = this.contentType
  330 +
  331 + this.item.childCommentsLazyDataSource.push(newModel)
  332 + })
  333 + }).catch(() => {
  334 + this.item.isLoading = false
  335 + })
  336 + })
155 } 337 }
  338 + }.height(30)
  339 + }
  340 +}
156 341
  342 +@Component
  343 +struct commentHeaderView {
  344 + @Link publishCommentModel: publishCommentModel
  345 + @Link dialogController: CustomDialogController | null
  346 + @ObjectLink item: commentItemModel
157 347
  348 + build() {
  349 + Column() {
  350 + Row() {
  351 + //头像
  352 + Stack() {
  353 + Image(this.item.fromUserHeader)
  354 + .alt($r('app.media.default_head'))
  355 + .width('32')
  356 + .height('32')
  357 + .objectFit(ImageFit.Cover)
  358 + .borderRadius(16)
  359 + Image(this.item.api_levelHead)
  360 + .width('48')
  361 + .height('48')
  362 + .objectFit(ImageFit.Cover)
  363 + .borderRadius(24)
  364 + }
  365 + .width(48)
  366 + .height(48)
  367 + .margin({ left: 8 })
  368 + .alignContent(Alignment.Center)
  369 + .onClick(() => {
  370 + // TODO 跳转个人详情
  371 + })
158 372
  373 + //昵称
  374 + Text(this.item.fromUserName)
  375 + .fontSize(14)
  376 + .fontColor($r('app.color.color_222222'))
  377 + .fontWeight(FontWeight.Medium)
  378 + .margin({ left: 5 })
159 379
160 - }.height(30) 380 +
  381 + /// 暂时不显示 “我” 的标签了
  382 + /// 人民号>置顶>作者
  383 +
  384 + //人民号
  385 + if (this.item.fromUserType === WDPublicUserType.WDPublicUserType_Matrix) {
  386 + Image($r('app.media.comment_rmh_tag')).width(20).height(20).margin({ left: 5 });
  387 + }
  388 + //置顶
  389 + if (this.item.topFlag) {
  390 + Image($r('app.media.comment_icon_zhiding')).width(30).height(18).margin({ left: 5 });
  391 + }
  392 + //作者
  393 + if (this.item.contentAuthor === 1) {
  394 + Text('作者')
  395 + .fontSize(11)
  396 + .fontColor('#968562')
  397 + .backgroundColor('#F1EFEB')
  398 + .textAlign(TextAlign.Center)
  399 + .borderRadius(2)
  400 + .width(30)
  401 + .height(18)
  402 + .margin({ left: 5 });
  403 + }
  404 + }
  405 +
  406 + CommentText({
  407 + longMessage: this.item.commentContent,
  408 + maxline: 3,
  409 + fontSize: 16,
  410 + fontWeight: FontWeight.Regular,
  411 + marginWidth: (59 + 16)
  412 + })
  413 + .margin({ left: 59, right: 16, top: -5 })
  414 +
  415 +
  416 + commentFooterView({
  417 + item: this.item,
  418 + dialogController: this.dialogController,
  419 + publishCommentModel: this.publishCommentModel
  420 + }).margin({ left: 59, right: 16 })
  421 + }.alignItems(HorizontalAlign.Start)
161 } 422 }
  423 +}
162 424
163 - /*评论内容下面的IP地址时间点赞*/  
164 - @Builder  
165 - CommentFooterView(item: commentItemModel) { 425 +/*评论内容下面的IP地址时间点赞*/
  426 +@Component
  427 +struct commentFooterView {
  428 + @Link publishCommentModel: publishCommentModel
  429 + @Link dialogController: CustomDialogController | null
  430 + @ObjectLink item: commentItemModel
  431 +
  432 + build() {
166 Row() { 433 Row() {
167 434
168 Row({ space: 6 }) { 435 Row({ space: 6 }) {
169 - Text(item.region ? (item.region + '网友') : '人民日报客户端网友') 436 + Text(this.item.region ? (this.item.region + '网友') : '人民日报客户端网友')
170 .fontColor($r('app.color.color_B0B0B0')) 437 .fontColor($r('app.color.color_B0B0B0'))
171 .fontSize(12); 438 .fontSize(12);
172 Image($r('app.media.comment_hyphen')) 439 Image($r('app.media.comment_hyphen'))
@@ -175,15 +442,7 @@ export struct CommentComponent { @@ -175,15 +442,7 @@ export struct CommentComponent {
175 height: 4 442 height: 4
176 }) 443 })
177 444
178 - //TODO: 时间格式需要本地调整  
179 - // / 展现专用,用于获取多久之前  
180 - // ///小于1分钟:刚刚  
181 - // ///1~60分钟:x分钟前  
182 - // ///1小时~1天:x小时前  
183 - // ///1天~2天:1天前  
184 - // ///2天~:日期隐藏  
185 -  
186 - Text(DateTimeUtils.getCommentTime(Number.parseFloat(item.createTime))) 445 + Text(DateTimeUtils.getCommentTime(DateTimeUtils.getDateTimestamp(this.item.createTime)))
187 .fontColor($r('app.color.color_B0B0B0')) 446 .fontColor($r('app.color.color_B0B0B0'))
188 .fontSize(12) 447 .fontSize(12)
189 448
@@ -202,98 +461,51 @@ export struct CommentComponent { @@ -202,98 +461,51 @@ export struct CommentComponent {
202 } 461 }
203 462
204 Row({ space: 6 }) { 463 Row({ space: 6 }) {
205 - Text(item.likeNum) 464 + Text(this.item.likeNum)
206 .fontColor($r('app.color.color_666666')) 465 .fontColor($r('app.color.color_666666'))
207 .fontSize(14) 466 .fontSize(14)
208 467
209 - Image($r('app.media.comment_like_normal')) 468 + Image($r(this.item.api_status ? 'app.media.comment_like_select' : 'app.media.comment_like_normal'))
210 .size({ 469 .size({
211 width: 16, 470 width: 16,
212 height: 16 471 height: 16
213 }) 472 })
214 - .onClick(() => {  
215 - //TODO: 点赞  
216 - }) 473 +
217 } 474 }
  475 + .onClick(() => {
  476 + commentLikeChange(this.item)
  477 + commentViewModel.commentLike(this.item).then(() => {
  478 + }).catch(() => {
  479 + commentLikeChange(this.item)
  480 + })
  481 + })
218 482
219 } 483 }
220 .justifyContent(FlexAlign.SpaceBetween) 484 .justifyContent(FlexAlign.SpaceBetween)
  485 + .width('100%')
221 .height(30) 486 .height(30)
222 - .margin({ left: 59, right: 16 })  
223 } 487 }
  488 +}
224 489
225 - build() {  
226 - Column() {  
227 -  
228 - List() {  
229 - ListItemGroup({ header: this.titleHeader() })  
230 - .onClick(()=>{  
231 - console.log(TAG)  
232 - this.dialogController.open()  
233 - })  
234 - LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {  
235 - if (item.hasMore) {  
236 - ListItemGroup({ header: this.CommentHeaderItem(item), footer: this.GroupFooterView(item) }) {  
237 - ForEach(item.childComments, (childItem: commentItemModel, subIndex: number) => {  
238 - ListItem() {  
239 - ChildCommentItem();  
240 - }  
241 - .onClick(()=>{  
242 - console.log(TAG)  
243 - })  
244 - })  
245 - }  
246 - }else {  
247 - ListItemGroup({ header: this.CommentHeaderItem(item)}) {  
248 - ForEach(item.childComments, (childItem: commentItemModel, subIndex: number) => {  
249 - ListItem() {  
250 - ChildCommentItem();  
251 - }  
252 - .onClick(()=>{  
253 - console.log(TAG)  
254 - })  
255 - })  
256 - }  
257 - }  
258 - })  
259 - }.layoutWeight(1) 490 +function commentLikeChange(item: commentItemModel) {
  491 + item.api_status = !item.api_status
  492 + //点赞
  493 + if (item.api_status) {
  494 + if (item.likeNum.length > 0) {
  495 + item.likeNum = (Number.parseInt(item.likeNum) + 1) + ''
  496 + } else {
  497 + item.likeNum = '1'
260 } 498 }
261 } 499 }
262 -  
263 - //获取数据  
264 - async getData() {  
265 - this.browSingModel.currentPage = 1  
266 - commentViewModel.getCommentLocal(getContext()).then(commentListModel => {  
267 - if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {  
268 - commentListModel.hasMore = true;  
269 - this.browSingModel.viewType = ViewType.LOADED;  
270 - this.allDatas.push(...commentListModel.list)  
271 - if (commentListModel.list.length === this.browSingModel.pageSize) {  
272 - this.browSingModel.currentPage++;  
273 - this.browSingModel.hasMore = true;  
274 - } else {  
275 - this.browSingModel.hasMore = false;  
276 - }  
277 - } else {  
278 - this.browSingModel.viewType = ViewType.EMPTY;  
279 - }  
280 -  
281 -  
282 -  
283 - })  
284 - }  
285 -  
286 - /*回复评论*/  
287 - ReplyComment() {  
288 - 500 + //取消点赞
  501 + if (!item.api_status) {
  502 + item.likeNum = (Number.parseInt(item.likeNum) - 1) + ''
  503 + if (Number.parseInt(item.likeNum) <= 0) {
  504 + item.likeNum = ''
  505 + }
289 } 506 }
290 } 507 }
291 508
292 509
293 -@Component  
294 -struct ChildCommentItem {  
295 - build() {  
296 - Text('child')  
297 - }  
298 -} 510 +
299 511
  1 +import { inputMethodEngine } from '@kit.IMEKit'
  2 +import { publishCommentModel } from '../model/PublishCommentModel'
  3 +import commentViewModel from '../viewmodel/CommentViewModel'
  4 +
1 @Preview 5 @Preview
2 @CustomDialog 6 @CustomDialog
3 export struct CommentCustomDialog { 7 export struct CommentCustomDialog {
4 - controller: CustomDialogController = new CustomDialogController({  
5 - builder: CommentCustomDialog(),  
6 - autoCancel: true,  
7 - alignment: DialogAlignment.Bottom,  
8 - customStyle: true,  
9 - }) 8 + commentText: string = ''
  9 + placeHolderText: string = '优质评论会获得最佳评论人的称号'
  10 + controller?: CustomDialogController
  11 + confirm: (value: Record<string, string>) => void = () => {
  12 + }
  13 + @State private emojiSwitch: boolean = false
  14 + textInputController: TextAreaController = new TextAreaController()
10 15
11 build() { 16 build() {
12 Column() { 17 Column() {
13 Row() { 18 Row() {
14 - TextArea({ placeholder: '优质评论会获得最佳评论人的称号' }) 19 + TextArea({
  20 + placeholder: this.placeHolderText,
  21 + controller: this.textInputController,
  22 + text: this.commentText
  23 + })
15 .height('100%') 24 .height('100%')
16 .width('100%') 25 .width('100%')
17 .backgroundColor($r('app.color.color_transparent')) 26 .backgroundColor($r('app.color.color_transparent'))
  27 + .onChange(value => {
  28 + this.commentText = value;
  29 + })
18 } 30 }
19 .backgroundColor('#F9F9F9') 31 .backgroundColor('#F9F9F9')
20 // .width('100%') 32 // .width('100%')
21 - .margin({ top: 12,right: 12, left: 12, bottom: 10 }) 33 + .margin({ top: 12, right: 12, left: 12, bottom: 10 })
22 .height(80) 34 .height(80)
23 .borderRadius(4) 35 .borderRadius(4)
24 36
25 - Row(){  
26 Row() { 37 Row() {
27 - Row({ space: 12 }) {  
28 - //语音暂时不做,隐藏  
29 - // Image($r('app.media.WDInput_voice')).width(30).height(30) 38 + Row() {
  39 + Row({ space: 12 }) {
  40 + //语音暂时不做,隐藏
  41 + // Image($r('app.media.WDInput_voice')).width(30).height(30)
30 42
31 - Image($r('app.media.WDInput_keyboardImage')).width(30).height(30)  
32 - }  
33 - // Blank() 43 + Image($r(this.emojiSwitch ? 'app.media.WDInput_keyboardImage' : 'app.media.WDInput_emojiImage'))
  44 + .width(30)
  45 + .height(30)
  46 + .onClick(() => {
  47 +
  48 + // this.commentText = this.commentText + '神鼎'
  49 + this.emojiSwitch = !this.emojiSwitch
  50 + if (this.emojiSwitch) {
  51 + this.textInputController.stopEditing()
  52 + } else {
  53 + this.textInputController.caretPosition(this.textInputController.getTextContentRect().x)
  54 + }
  55 +
  56 + })
  57 + }
  58 +
  59 + // Blank()
  60 +
  61 + Row() {
  62 + Text('发布')
  63 + .backgroundColor('#F89381')
  64 + .width(80)
  65 + .height(30)
  66 + .fontSize(15)
  67 + .fontColor(Color.White)
  68 + .textAlign(TextAlign.Center)
  69 + .borderRadius(4)
  70 + .onClick(() => {
  71 + if (this.commentText.length > 0) {
  72 + //请求评论接口
  73 + //commentType
  74 + //commentContent
  75 + let bean: Record<string, string> = {};
  76 + bean['commentContent'] = this.commentText
  77 + //TODO 判断类型
  78 + bean['commentType'] = '1'
  79 + this.confirm(bean)
  80 + if (this.controller != null) {
  81 + this.controller.close()
  82 + }
  83 + }
  84 + })
  85 + }
  86 + }.justifyContent(FlexAlign.SpaceBetween)
  87 + .width('100%')
  88 + .height(60)
  89 +
  90 + // .margin({ right: 12, left: 12 })
  91 + // .backgroundColor(Color.Red)
  92 + }.padding({ left: 12, right: 12 })
  93 +
  94 +
  95 + //表情view
  96 + if (this.emojiSwitch) {
  97 + emojiView()
  98 + }
34 99
35 - Row() {  
36 - Text('发布')  
37 - .backgroundColor('#F89381')  
38 - .width(80)  
39 - .height(30)  
40 - .fontSize(15)  
41 - .fontColor(Color.White)  
42 - .textAlign(TextAlign.Center)  
43 - .borderRadius(4)  
44 - }  
45 - }.justifyContent(FlexAlign.SpaceBetween)  
46 - .width('100%')  
47 - .height(60)  
48 - // .margin({ right: 12, left: 12 })  
49 - // .backgroundColor(Color.Red)  
50 - }.padding({left:12, right:12})  
51 }.backgroundColor(Color.White) 100 }.backgroundColor(Color.White)
52 .width('100%') 101 .width('100%')
53 .offset({ 102 .offset({
@@ -56,6 +105,12 @@ export struct CommentCustomDialog { @@ -56,6 +105,12 @@ export struct CommentCustomDialog {
56 } 105 }
57 } 106 }
58 107
  108 +@Component
  109 +struct emojiView {
  110 + build() {
  111 + }
  112 +}
  113 +
59 114
60 115
61 116
@@ -13,10 +13,9 @@ export struct CommentText { @@ -13,10 +13,9 @@ export struct CommentText {
13 @State longMessage: string = '' 13 @State longMessage: string = ''
14 // 最大显示行数 14 // 最大显示行数
15 @State maxLineMesssage: string = ''; 15 @State maxLineMesssage: string = '';
16 -  
17 @State lines: number = 3; 16 @State lines: number = 3;
18 @State maxline: number = 3; 17 @State maxline: number = 3;
19 - @State marginWidth:number = 0; 18 + @State marginWidth: number = 0;
20 // 长文本状态(展开 or 收起) 19 // 长文本状态(展开 or 收起)
21 @State collapseText: string = collapseString 20 @State collapseText: string = collapseString
22 // 屏幕宽度(单位px) 21 // 屏幕宽度(单位px)
@@ -30,7 +29,6 @@ export struct CommentText { @@ -30,7 +29,6 @@ export struct CommentText {
30 fontColor: ResourceColor = $r('app.color.color_222222') 29 fontColor: ResourceColor = $r('app.color.color_222222')
31 // 测量文本宽度(单位px) 30 // 测量文本宽度(单位px)
32 @State textWidth: number = 0; 31 @State textWidth: number = 0;
33 -  
34 // constructor(longMessage?:string,) { 32 // constructor(longMessage?:string,) {
35 // super(); 33 // super();
36 // this.longMessage = longMessage; 34 // this.longMessage = longMessage;
@@ -38,8 +36,6 @@ export struct CommentText { @@ -38,8 +36,6 @@ export struct CommentText {
38 // 获取当前所有的display对象 36 // 获取当前所有的display对象
39 promise: Promise<Array<display.Display>> = display.getAllDisplays() 37 promise: Promise<Array<display.Display>> = display.getAllDisplays()
40 38
41 -  
42 -  
43 aboutToAppear() { 39 aboutToAppear() {
44 console.log(`文本宽度为:${this.textWidth}`) 40 console.log(`文本宽度为:${this.textWidth}`)
45 let padding = vp2px(5 + this.marginWidth) 41 let padding = vp2px(5 + this.marginWidth)
@@ -48,7 +44,7 @@ export struct CommentText { @@ -48,7 +44,7 @@ export struct CommentText {
48 textContent: this.longMessage, 44 textContent: this.longMessage,
49 fontSize: this.fontSize, 45 fontSize: this.fontSize,
50 fontWeight: this.fontWeight, 46 fontWeight: this.fontWeight,
51 - constraintWidth:(this.screenWidth - padding) 47 + constraintWidth: (this.screenWidth - padding)
52 }) 48 })
53 49
54 console.log(`文本宽度为:${this.textWidth}`) 50 console.log(`文本宽度为:${this.textWidth}`)
@@ -66,7 +62,7 @@ export struct CommentText { @@ -66,7 +62,7 @@ export struct CommentText {
66 62
67 63
68 let padding = vp2px(5 + this.marginWidth) 64 let padding = vp2px(5 + this.marginWidth)
69 - let maxLineTextWidth = (this.screenWidth - padding) * this.maxline; 65 + let maxLineTextWidth = (this.screenWidth - padding) * this.maxline;
70 66
71 for (let index = 0; index < this.longMessage.length; index++) { 67 for (let index = 0; index < this.longMessage.length; index++) {
72 const element = this.longMessage.substring(0, index) 68 const element = this.longMessage.substring(0, index)
@@ -75,7 +71,7 @@ export struct CommentText { @@ -75,7 +71,7 @@ export struct CommentText {
75 textContent: string, 71 textContent: string,
76 fontSize: this.fontSize, 72 fontSize: this.fontSize,
77 fontWeight: this.fontWeight, 73 fontWeight: this.fontWeight,
78 - constraintWidth:(this.screenWidth - padding) 74 + constraintWidth: (this.screenWidth - padding)
79 }) 75 })
80 76
81 //计算有误差20 77 //计算有误差20
@@ -101,45 +97,46 @@ export struct CommentText { @@ -101,45 +97,46 @@ export struct CommentText {
101 Column() { 97 Column() {
102 if (this.isExpanded) { 98 if (this.isExpanded) {
103 // Stack({ alignContent: Alignment.BottomEnd }) { 99 // Stack({ alignContent: Alignment.BottomEnd }) {
104 - Text(this.longMessage) {  
105 - Span(this.expandedStates ? this.longMessage : this.maxLineMesssage)  
106 - Span(this.collapseText).onClick(() => {  
107 - if (this.collapseText == collapseString) {  
108 - this.collapseText = uncollapseString;  
109 - this.expandedStates = true;  
110 - this.lines = -1; // 使得设置的最大行属性无效  
111 - // 展开动画  
112 - // animateTo({  
113 - // duration: 150,  
114 - // curve: curves.springMotion(),  
115 - // }, () => {  
116 - // this.lines = -1; // 使得设置的最大行属性无效  
117 - // })  
118 - } else {  
119 - this.collapseText = collapseString;  
120 - this.expandedStates = false;  
121 - this.lines = this.maxline; // 只显示3行  
122 - // 收起动画  
123 - // animateTo({  
124 - // duration: 100,  
125 - // curve: Curve.Friction,  
126 - // }, () => {  
127 - // this.lines = this.maxline; // 只显示3行  
128 - // })  
129 - }  
130 - })  
131 - }  
132 - .width('100%')  
133 - .fontSize(this.fontSize)  
134 - .fontWeight(this.fontWeight)  
135 - .fontColor(this.fontColor)  
136 - .maxLines(this.lines)  
137 - // .backgroundColor(Color.Red) 100 + Text(this.longMessage) {
  101 + Span(this.expandedStates ? this.longMessage : this.maxLineMesssage)
  102 + Span(this.collapseText).onClick(() => {
  103 + if (this.collapseText == collapseString) {
  104 + this.collapseText = uncollapseString;
  105 + this.expandedStates = true;
  106 + this.lines = -1; // 使得设置的最大行属性无效
  107 + // 展开动画
  108 + // animateTo({
  109 + // duration: 150,
  110 + // curve: curves.springMotion(),
  111 + // }, () => {
  112 + // this.lines = -1; // 使得设置的最大行属性无效
  113 + // })
  114 + } else {
  115 + this.collapseText = collapseString;
  116 + this.expandedStates = false;
  117 + this.lines = this.maxline; // 只显示3行
  118 + // 收起动画
  119 + // animateTo({
  120 + // duration: 100,
  121 + // curve: Curve.Friction,
  122 + // }, () => {
  123 + // this.lines = this.maxline; // 只显示3行
  124 + // })
  125 + }
  126 + })
  127 + }
  128 + .width('100%')
  129 + .fontSize(this.fontSize)
  130 + .fontWeight(this.fontWeight)
  131 + .fontColor(this.fontColor)
  132 + .maxLines(this.lines)
  133 +
  134 + // .backgroundColor(Color.Red)
138 135
139 // } 136 // }
140 } 137 }
141 else { 138 else {
142 - Text('我没有展开收起') 139 + Text(this.longMessage)
143 .width('100%') 140 .width('100%')
144 .fontSize(this.fontSize) 141 .fontSize(this.fontSize)
145 .fontWeight(this.fontWeight) 142 .fontWeight(this.fontWeight)
@@ -4,6 +4,9 @@ import { commentItemModel, commentListModel } from '../model/CommentModel' @@ -4,6 +4,9 @@ import { commentItemModel, commentListModel } from '../model/CommentModel'
4 import commentViewModel from '../viewmodel/CommentViewModel' 4 import commentViewModel from '../viewmodel/CommentViewModel'
5 import { router, window } from '@kit.ArkUI' 5 import { router, window } from '@kit.ArkUI'
6 import { CustomTitleUI } from '../../reusable/CustomTitleUI' 6 import { CustomTitleUI } from '../../reusable/CustomTitleUI'
  7 +import { MyCommentDataSource } from '../model/MyCommentDataSource'
  8 +import { HttpUtils } from 'wdNetwork/src/main/ets/utils/HttpUtils'
  9 +import { HttpUrlUtils } from 'wdNetwork/Index'
7 10
8 const TAG = 'QualityCommentsComponent'; 11 const TAG = 'QualityCommentsComponent';
9 12
@@ -15,11 +18,11 @@ export struct QualityCommentsComponent { @@ -15,11 +18,11 @@ export struct QualityCommentsComponent {
15 firstPositionY: number = 0; 18 firstPositionY: number = 0;
16 bottomSafeHeight: string = AppStorage.get<number>('bottomSafeHeight') + 'px'; 19 bottomSafeHeight: string = AppStorage.get<number>('bottomSafeHeight') + 'px';
17 topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number; 20 topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
18 - @State private browSingModel: commentListModel = new commentListModel() 21 + // @State private browSingModel: commentListModel = new commentListModel()
19 isloading: boolean = false 22 isloading: boolean = false
20 lastWindowColor: string = '#ffffff' 23 lastWindowColor: string = '#ffffff'
21 currentWindowColor: string = '#FF4202' 24 currentWindowColor: string = '#FF4202'
22 - @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource(); 25 + @State allDatas: MyCommentDataSource = new MyCommentDataSource();
23 26
24 aboutToDisappear(): void { 27 aboutToDisappear(): void {
25 28
@@ -37,23 +40,11 @@ export struct QualityCommentsComponent { @@ -37,23 +40,11 @@ export struct QualityCommentsComponent {
37 40
38 commentViewModel.fetchQualityCommentList('1').then((commentListModel) => { 41 commentViewModel.fetchQualityCommentList('1').then((commentListModel) => {
39 if (commentListModel && commentListModel.list && commentListModel.list.length > 0) { 42 if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
40 - // commentListModel.hasMore = true;  
41 - // this.browSingModel.viewType = ViewType.LOADED;  
42 -  
43 - // commentListModel.list.forEach(element => {  
44 - // this.allDatas.push(new commentItemModel())  
45 - // });  
46 -  
47 - this.allDatas.push(...commentListModel.list)  
48 -  
49 - // if (commentListModel.list.length === this.browSingModel.pageSize) {  
50 - // this.browSingModel.currentPage++;  
51 - // this.browSingModel.hasMore = true;  
52 - // } else {  
53 - // this.browSingModel.hasMore = false;  
54 - // } 43 + commentListModel.list.forEach(element => {
  44 + this.allDatas.pushData(commentViewModel.deepCopyCommentItemModel(element))
  45 + });
55 } else { 46 } else {
56 - this.browSingModel.viewType = ViewType.EMPTY; 47 +
57 } 48 }
58 }) 49 })
59 } 50 }
@@ -61,13 +52,7 @@ export struct QualityCommentsComponent { @@ -61,13 +52,7 @@ export struct QualityCommentsComponent {
61 fullScreen() { 52 fullScreen() {
62 const windowStage = WindowModel.shared.getWindowStage() as window.WindowStage 53 const windowStage = WindowModel.shared.getWindowStage() as window.WindowStage
63 const windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口 54 const windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口
64 - // windowClass.setWindowBackgroundColor(this.currentWindowColor)  
65 windowClass.setWindowLayoutFullScreen(true) 55 windowClass.setWindowLayoutFullScreen(true)
66 - // windowClass.setWindowSystemBarProperties({ statusBarColor: '#fff' })  
67 -  
68 - // windowClass.setWindowLayoutFullScreen(true).then(() => {  
69 - // console.log(TAG + 'setWindowLayoutFullScreen');  
70 - // })  
71 56
72 } 57 }
73 58
@@ -174,7 +159,7 @@ export struct QualityCommentsComponent { @@ -174,7 +159,7 @@ export struct QualityCommentsComponent {
174 // ListItemGroup({ header: this.titleHeader() }) 159 // ListItemGroup({ header: this.titleHeader() })
175 LazyForEach(this.allDatas, (item: commentItemModel, index: number) => { 160 LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {
176 ListItem() { 161 ListItem() {
177 - QualityCommentItem({ item: item, index:index }).margin({ left: 12, right: 12 }) 162 + QualityCommentItem({ item: item, index: index }).margin({ left: 12, right: 12 })
178 } 163 }
179 }) 164 })
180 ListItem() { 165 ListItem() {
@@ -217,7 +202,7 @@ export struct QualityCommentsComponent { @@ -217,7 +202,7 @@ export struct QualityCommentsComponent {
217 @Component 202 @Component
218 struct QualityCommentItem { 203 struct QualityCommentItem {
219 @ObjectLink item: commentItemModel 204 @ObjectLink item: commentItemModel
220 - index:number = 0 205 + index: number = 0
221 206
222 build() { 207 build() {
223 Column() { 208 Column() {
@@ -227,6 +212,8 @@ struct QualityCommentItem { @@ -227,6 +212,8 @@ struct QualityCommentItem {
227 RelativeContainer() { 212 RelativeContainer() {
228 213
229 Image(this.item.fromUserHeader) 214 Image(this.item.fromUserHeader)
  215 +
  216 + .alt($r(commentViewModel.adjustUserType(this.item.fromUserType) ? 'app.media.WDAccountOwnerHedaerDefaultIcon' : 'app.media.WDAccountDefaultIcon'))
230 .width(50) 217 .width(50)
231 .height(50) 218 .height(50)
232 .borderRadius(25) 219 .borderRadius(25)
@@ -326,13 +313,10 @@ struct QualityCommentItem { @@ -326,13 +313,10 @@ struct QualityCommentItem {
326 .margin({ left: 3 }) 313 .margin({ left: 3 })
327 } 314 }
328 }.onClick(() => { 315 }.onClick(() => {
329 - this.item.api_status = !this.item.api_status  
330 -  
331 - // commentViewModel.commnetLikeChange(this.item) 316 + commentViewModel.commnetLikeChange(this.item)
332 commentViewModel.commentLike(this.item).then(() => { 317 commentViewModel.commentLike(this.item).then(() => {
333 -  
334 }).catch(() => { 318 }).catch(() => {
335 - // commentViewModel.commnetLikeChange(this.item) 319 + commentViewModel.commnetLikeChange(this.item)
336 }) 320 })
337 }) 321 })
338 } 322 }
1 -import { Logger, ResourcesUtils, UserDataLocal } from 'wdKit/Index'; 1 +import { DateTimeUtils, Logger, ResourcesUtils, ToastUtils, UserDataLocal } from 'wdKit/Index';
2 import { HttpBizUtil, HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index'; 2 import { HttpBizUtil, HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
3 import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; 3 import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
4 -import { commentItemModel, commentListModel, commentStatusListModel, commentStatusModel } from '../model/CommentModel'; 4 +import {
  5 + commentItemModel,
  6 + commentListModel,
  7 + commentStatusListModel,
  8 + commentStatusModel,
  9 + WDPublicUserType
  10 +} from '../model/CommentModel';
5 import HashMap from '@ohos.util.HashMap'; 11 import HashMap from '@ohos.util.HashMap';
6 import { ifaa } from '@kit.OnlineAuthenticationKit'; 12 import { ifaa } from '@kit.OnlineAuthenticationKit';
  13 +import { publishCommentModel } from '../model/PublishCommentModel';
7 14
8 const TAG = "CommentViewModel" 15 const TAG = "CommentViewModel"
9 16
@@ -21,30 +28,68 @@ class CommentViewModel { @@ -21,30 +28,68 @@ class CommentViewModel {
21 return CommentViewModel.instance; 28 return CommentViewModel.instance;
22 } 29 }
23 30
24 - /*获取本地mock数据*/  
25 - async getCommentLocal(context: Context): Promise<commentListModel> {  
26 - Logger.info(TAG, `getBottomNavDataMock start`);  
27 - let compRes: ResponseDTO<commentListModel> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<commentListModel>>(context, 'comment_local.json');  
28 - if (!compRes || !compRes.data) {  
29 - Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`);  
30 - return new commentListModel()  
31 - }  
32 - Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);  
33 - return this.fetchCommentStatusAndConfigAuthIcon(compRes.data)  
34 - // this.fetchCommentStatusAndConfigAuthIcon(compRes.data)  
35 - // return compRes.data 31 + /*获取所有评论*/
  32 + fetchContentCommentList(pageNum: string, contentId: string, contentType: string): Promise<commentListModel> {
  33 +
  34 + let url = HttpUrlUtils.getContentCommentListDataUrl() + `?&pageSize=${10}&pageNum=${pageNum}&contentId=${contentId}&contentType=${contentType}&deviceId=${HttpUrlUtils.getDeviceId()}&userId=${HttpUrlUtils.getUserId()}&userType=${HttpUrlUtils.getUserType()}&time=${DateTimeUtils.getCurTime(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)}`
  35 + url = url.replace(' ', '%20')
  36 +
  37 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  38 + return new Promise<commentListModel>((success, fail) => {
  39 + HttpRequest.get<ResponseDTO<commentListModel>>(url, headers).then((data: ResponseDTO<commentListModel>) => {
  40 + if (!data || !data.data) {
  41 + fail("数据为空")
  42 + return
  43 + }
  44 + if (data.code != 0) {
  45 + fail(data.message)
  46 + return
  47 + }
  48 + let listData = data.data as commentListModel
  49 + this.fetchCommentStatusAndConfigAuthIcon(listData).then((commentListModel) => {
  50 + console.log(TAG, 'fetchCommentStatusAndConfigAuthIcon完成')
  51 + success(commentListModel)
  52 + })
  53 +
  54 + }, (error: Error) => {
  55 + fail(error.message)
  56 + Logger.debug(TAG, error.toString())
  57 + })
  58 + })
36 } 59 }
37 60
38 - /*获取热门评论本地mock数据*/  
39 - async fetchQualityCommentListLocal(context: Context): Promise<commentListModel> {  
40 - Logger.info(TAG, `getBottomNavDataMock start`);  
41 - let compRes: ResponseDTO<commentListModel> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<commentListModel>>(context, 'qualityComment_local.json');  
42 - if (!compRes || !compRes.data) {  
43 - Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`);  
44 - return new commentListModel()  
45 - }  
46 - Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);  
47 - return this.fetchCommentStatusAndConfigAuthIcon(compRes.data) 61 + /*获取所有子评论*/
  62 +
  63 + fetchChildContentCommentList(pageNum: string, contentId: string, contentType: string, commentId: String): Promise<commentListModel> {
  64 + // https://pd-apis-uat.pdnews.cn/api/rmrb-comment/comment/zh/c/childCommentList?commentId=44846810&contentId=30004266013&contentType=8&deviceId=35C78D13-A84A-47CE-A5D0-E114E4E49939&pageNum=1&pageSize=10&time=2024-04-23%2014%3A44%3A57&userId=&userType=0
  65 + let url = HttpUrlUtils.getChildContentCommentListDataUrl() + `?&pageSize=${10}&pageNum=${pageNum}&commentId=${commentId}&contentId=${contentId}&contentType=${contentType}&deviceId=${HttpUrlUtils.getDeviceId()}&userId=${HttpUrlUtils.getUserId()}&userType=${HttpUrlUtils.getUserType()}&time=${DateTimeUtils.getCurTime(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)}`
  66 + url = url.replace(' ', '%20')
  67 +
  68 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  69 + return new Promise<commentListModel>((success, fail) => {
  70 + HttpRequest.get<ResponseDTO<commentListModel>>(url, headers).then((data: ResponseDTO<commentListModel>) => {
  71 + if (!data || !data.data) {
  72 + fail("数据为空")
  73 + return
  74 + }
  75 + if (data.code != 0) {
  76 + fail(data.message)
  77 + return
  78 + }
  79 + let listData = data.data as commentListModel
  80 +
  81 + // success(listData)
  82 +
  83 + this.fetchCommentStatusAndConfigAuthIcon(listData).then((commentListModel) => {
  84 + console.log(TAG, 'fetchCommentStatusAndConfigAuthIcon完成')
  85 + success(commentListModel)
  86 + })
  87 +
  88 + }, (error: Error) => {
  89 + fail(error.message)
  90 + Logger.debug(TAG, error.toString())
  91 + })
  92 + })
48 } 93 }
49 94
50 /*获取热门评论*/ 95 /*获取热门评论*/
@@ -75,7 +120,7 @@ class CommentViewModel { @@ -75,7 +120,7 @@ class CommentViewModel {
75 }) 120 })
76 } 121 }
77 122
78 - /*点赞*/ 123 + /*评论点赞*/
79 commentLike(model: commentItemModel) { 124 commentLike(model: commentItemModel) {
80 125
81 return new Promise<void>((success, fail) => { 126 return new Promise<void>((success, fail) => {
@@ -116,6 +161,43 @@ class CommentViewModel { @@ -116,6 +161,43 @@ class CommentViewModel {
116 }) 161 })
117 } 162 }
118 163
  164 + /*发布评论*/
  165 + publishComment(model: publishCommentModel) {
  166 +
  167 + return new Promise<void>((success, fail) => {
  168 + let url = HttpUrlUtils.getPublishCommentUrl()
  169 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  170 + let bean: Record<string, string> = {};
  171 +
  172 + bean['targetId'] = model.targetId;
  173 + bean['targetRelId'] = model.targetRelId;
  174 + bean['commentType'] = model.commentType;
  175 + bean['rootCommentId'] = model.rootCommentId
  176 + bean['targetTitle'] = model.targetTitle
  177 + bean['targetRelType'] = model.targetRelType
  178 + bean['targetRelObjectId'] = model.targetRelObjectId
  179 + bean['commentPics'] = model.commentPics
  180 + bean['commentContent'] = model.commentContent
  181 + bean['keyArticle'] = model.keyArticle
  182 + bean['targetType'] = model.targetType
  183 + bean['parentId'] = model.parentId
  184 +
  185 + HttpRequest.post<ResponseDTO<commentStatusModel[]>>(url, bean, headers).then((data: ResponseDTO<commentStatusModel[]>) => {
  186 + if (data.code != 0) {
  187 + ToastUtils.showToast(data.message, 1000);
  188 + fail()
  189 + return
  190 + }
  191 + ToastUtils.showToast(data.message, 1000);
  192 + success()
  193 + }, (error: Error) => {
  194 + ToastUtils.showToast('评论失败', 1000);
  195 + fail()
  196 + Logger.debug(TAG, error.toString())
  197 + })
  198 + })
  199 + }
  200 +
119 /*多接口批查*/ 201 /*多接口批查*/
120 fetchCommentStatusAndConfigAuthIcon(model: commentListModel): Promise<commentListModel> { 202 fetchCommentStatusAndConfigAuthIcon(model: commentListModel): Promise<commentListModel> {
121 203
@@ -139,7 +221,7 @@ class CommentViewModel { @@ -139,7 +221,7 @@ class CommentViewModel {
139 221
140 222
141 //子评论 223 //子评论
142 - if (element.childComments) { 224 + if (element.childComments.length) {
143 for (const obj2 of element.childComments) { 225 for (const obj2 of element.childComments) {
144 if ((obj2.id + '').length > 0) { 226 if ((obj2.id + '').length > 0) {
145 commentIDs.push(obj2.id + '') 227 commentIDs.push(obj2.id + '')
@@ -179,13 +261,13 @@ class CommentViewModel { @@ -179,13 +261,13 @@ class CommentViewModel {
179 return 261 return
180 } 262 }
181 let listData = data.data as commentStatusModel[] 263 let listData = data.data as commentStatusModel[]
182 -//点赞 264 + //点赞
183 for (const element of listData) { 265 for (const element of listData) {
184 for (const commentModel of model.list) { 266 for (const commentModel of model.list) {
185 if (element.commentId == commentModel.id) { 267 if (element.commentId == commentModel.id) {
186 commentModel.api_status = element.status 268 commentModel.api_status = element.status
187 } 269 }
188 - if (commentModel.childComments) { 270 + if (commentModel.childComments.length) {
189 for (const childCommentModel of commentModel.childComments) { 271 for (const childCommentModel of commentModel.childComments) {
190 if (element.commentId == childCommentModel.id) { 272 if (element.commentId == childCommentModel.id) {
191 childCommentModel.api_status = element.status 273 childCommentModel.api_status = element.status
@@ -228,7 +310,7 @@ class CommentViewModel { @@ -228,7 +310,7 @@ class CommentViewModel {
228 if (element.userId == commentModel.fromUserId) { 310 if (element.userId == commentModel.fromUserId) {
229 commentModel.api_levelHead = element.levelHead 311 commentModel.api_levelHead = element.levelHead
230 } 312 }
231 - if (commentModel.childComments) { 313 + if (commentModel.childComments.length) {
232 for (const childCommentModel of commentModel.childComments) { 314 for (const childCommentModel of commentModel.childComments) {
233 if (element.userId == childCommentModel.fromUserId) { 315 if (element.userId == childCommentModel.fromUserId) {
234 childCommentModel.api_levelHead = element.levelHead 316 childCommentModel.api_levelHead = element.levelHead
@@ -274,7 +356,7 @@ class CommentViewModel { @@ -274,7 +356,7 @@ class CommentViewModel {
274 if (element.creatorId == commentModel.fromCreatorId) { 356 if (element.creatorId == commentModel.fromCreatorId) {
275 commentModel.api_authIcon = element.authIcon 357 commentModel.api_authIcon = element.authIcon
276 } 358 }
277 - if (commentModel.childComments) { 359 + if (commentModel.childComments.length) {
278 for (const childCommentModel of commentModel.childComments) { 360 for (const childCommentModel of commentModel.childComments) {
279 if (element.creatorId == childCommentModel.fromCreatorId) { 361 if (element.creatorId == childCommentModel.fromCreatorId) {
280 childCommentModel.api_authIcon = element.authIcon 362 childCommentModel.api_authIcon = element.authIcon
@@ -303,8 +385,7 @@ class CommentViewModel { @@ -303,8 +385,7 @@ class CommentViewModel {
303 385
304 } 386 }
305 387
306 -  
307 - commnetLikeChange(model:commentItemModel){ 388 + commnetLikeChange(model: commentItemModel) {
308 model.api_status = !model.api_status 389 model.api_status = !model.api_status
309 //点赞 390 //点赞
310 if (model.api_status) { 391 if (model.api_status) {
@@ -317,10 +398,97 @@ class CommentViewModel { @@ -317,10 +398,97 @@ class CommentViewModel {
317 model.likeNum = '0' 398 model.likeNum = '0'
318 } 399 }
319 } 400 }
  401 + // return model
  402 + }
  403 +
  404 + deepCopyCommentItemModel(model: commentItemModel) {
  405 + let newModel = new commentItemModel()
  406 +
  407 + newModel.authorLike = model.authorLike
  408 + newModel.avatarFrame = model.avatarFrame
  409 + newModel.checkStatus = model.checkStatus
  410 + newModel.childCommentNum = model.childCommentNum
  411 + newModel.childComments = model.childComments
  412 + // newModel.childCommentsLazyDataSource = model.childCommentsLazyDataSource
  413 + newModel.commentContent = model.commentContent
  414 + newModel.commentContentSensitive = model.commentContentSensitive
  415 + newModel.commentLevel = model.commentLevel
  416 + newModel.commentPics = model.commentPics
  417 + newModel.commentSensitive = model.commentSensitive
  418 + newModel.commentType = model.commentType
  419 + newModel.contentAuthor = model.contentAuthor
  420 + newModel.createTime = model.createTime
  421 + newModel.creatorFlag = model.creatorFlag
  422 + newModel.fromCreatorId = model.fromCreatorId
  423 + newModel.fromDeviceId = model.fromDeviceId
  424 + newModel.fromUserHeader = model.fromUserHeader
  425 + newModel.fromUserId = model.fromUserId
  426 + newModel.fromUserName = model.fromUserName
  427 + newModel.fromUserType = model.fromUserType
  428 + newModel.id = model.id
  429 + newModel.likeNum = model.likeNum.toString()
  430 +
  431 + if (Number.parseInt(newModel.likeNum) <= 0) {
  432 + newModel.likeNum = ''
  433 + }
  434 +
  435 + newModel.mySelf = model.mySelf
  436 + newModel.parentId = model.parentId
  437 + newModel.region = model.region
  438 + newModel.replyNum = model.replyNum
  439 + newModel.rootCommentId = model.rootCommentId
  440 + newModel.sensitiveExist = model.sensitiveExist
  441 + newModel.sensitiveShow = model.sensitiveShow
  442 + newModel.toUserContentAuthor = model.toUserContentAuthor
  443 + newModel.toUserId = model.toUserId
  444 + newModel.toUserName = model.toUserName
  445 + // newModel.isLoading = model.isLoading
  446 +
  447 +
  448 + if (model.toUserType != null) {
  449 + newModel.toUserType = model.toUserType.toString()
  450 + }
  451 + newModel.topFlag = model.topFlag
  452 + newModel.uuid = model.uuid
  453 + newModel.maxLine = model.maxLine
  454 + newModel.hasMore = model.hasMore
  455 + newModel.expanded = model.expanded
  456 + newModel.highQualityExpireTime = model.highQualityExpireTime
  457 + newModel.highQualityTime = model.highQualityTime
  458 + newModel.targetTitle = model.targetTitle
  459 + newModel.targetStatus = model.targetStatus
  460 + newModel.targetId = model.targetId
  461 + newModel.targetRelId = model.targetRelId
  462 + newModel.targetRelObjectId = model.targetRelObjectId
  463 + newModel.targetRelType = model.targetRelType
  464 + newModel.targetType = model.targetType
  465 + newModel.visitorComment = model.visitorComment
  466 + newModel.shareInfo = model.shareInfo
  467 + newModel.api_commentId = model.api_commentId
  468 + newModel.api_status = model.api_status
  469 + newModel.api_level = model.api_level
  470 + newModel.api_levelHead = model.api_levelHead
  471 + newModel.api_userId = model.api_userId
  472 + newModel.api_creatorId = model.api_creatorId
  473 + newModel.api_authIcon = model.api_authIcon
  474 + newModel.api_userType = model.api_userType
  475 +
  476 +
  477 + return newModel
  478 + }
  479 +
  480 + //判断用户类型显示头像
  481 + adjustUserType(userType: WDPublicUserType) {
  482 + if (userType != 1 && userType > 0) {
  483 + return true
  484 + }
  485 + return false
320 } 486 }
321 } 487 }
322 488
323 489
324 const commentViewModel = CommentViewModel.getInstance(); 490 const commentViewModel = CommentViewModel.getInstance();
325 491
326 -export default commentViewModel as CommentViewModel  
  492 +export default commentViewModel as CommentViewModel
  493 +
  494 +