Showing
8 changed files
with
478 additions
and
5 deletions
| @@ -236,6 +236,10 @@ export class HttpUrlUtils { | @@ -236,6 +236,10 @@ export class HttpUrlUtils { | ||
| 236 | * 预约状态 | 236 | * 预约状态 |
| 237 | */ | 237 | */ |
| 238 | static readonly LIVE_APPOINTMENT_BATCH_PATH: string = "/api/live-center-message/zh/c/live/subscribe/user/batch"; | 238 | static readonly LIVE_APPOINTMENT_BATCH_PATH: string = "/api/live-center-message/zh/c/live/subscribe/user/batch"; |
| 239 | + /** | ||
| 240 | + * 游客 评论列表 | ||
| 241 | + */ | ||
| 242 | + static readonly VISITOR_COMMENT_LIST_DATA_PATH: string = "/api/rmrb-comment/comment/zh/c/visitorCommentList"; | ||
| 239 | 243 | ||
| 240 | /** | 244 | /** |
| 241 | * 查询是否被禁言 | 245 | * 查询是否被禁言 |
| @@ -868,4 +872,9 @@ export class HttpUrlUtils { | @@ -868,4 +872,9 @@ export class HttpUrlUtils { | ||
| 868 | let url = HttpUrlUtils.getHost() + "/api/rmrb-contact/contact/zh/c/push/device" | 872 | let url = HttpUrlUtils.getHost() + "/api/rmrb-contact/contact/zh/c/push/device" |
| 869 | return url | 873 | return url |
| 870 | } | 874 | } |
| 875 | + | ||
| 876 | + static getVisitorCommentListDataUrl() { | ||
| 877 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.VISITOR_COMMENT_LIST_DATA_PATH | ||
| 878 | + return url | ||
| 879 | + } | ||
| 871 | } | 880 | } |
| @@ -91,6 +91,8 @@ export class WDRouterPage { | @@ -91,6 +91,8 @@ export class WDRouterPage { | ||
| 91 | static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview"); | 91 | static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview"); |
| 92 | //我的主页 | 92 | //我的主页 |
| 93 | static mineHomePage = new WDRouterPage("wdComponent", "ets/pages/MineHomePage"); | 93 | static mineHomePage = new WDRouterPage("wdComponent", "ets/pages/MineHomePage"); |
| 94 | + //游客评论列表 | ||
| 95 | + static visitorCommentPage = new WDRouterPage("wdComponent", "ets/pages/VisitorCommentPage"); | ||
| 94 | // 隐私设置页 | 96 | // 隐私设置页 |
| 95 | static privacySettingPage = new WDRouterPage("wdComponent", "ets/components/page/PrivacySettingPage"); | 97 | static privacySettingPage = new WDRouterPage("wdComponent", "ets/components/page/PrivacySettingPage"); |
| 96 | // 关于页 | 98 | // 关于页 |
| @@ -23,7 +23,7 @@ export default struct MinePagePersonFunctionUI { | @@ -23,7 +23,7 @@ export default struct MinePagePersonFunctionUI { | ||
| 23 | switch (item.msg){ | 23 | switch (item.msg){ |
| 24 | case "评论":{ | 24 | case "评论":{ |
| 25 | if(!this.isLogin){ | 25 | if(!this.isLogin){ |
| 26 | - WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | 26 | + WDRouterRule.jumpWithPage(WDRouterPage.visitorCommentPage) |
| 27 | return | 27 | return |
| 28 | }else { | 28 | }else { |
| 29 | let params: Record<string, string> = {'comment': "1"}; | 29 | let params: Record<string, string> = {'comment': "1"}; |
sight_harmony/features/wdComponent/src/main/ets/components/mine/home/VisitorCommentComponent.ets
0 → 100644
| 1 | +import { ContentDTO } from 'wdBean/Index' | ||
| 2 | +import { StringUtils, UserDataLocal } from 'wdKit/Index' | ||
| 3 | +import MinePageDatasModel from '../../../model/MinePageDatasModel' | ||
| 4 | +import { CommentLikeOperationRequestItem } from '../../../viewmodel/CommentLikeOperationRequestItem' | ||
| 5 | +import { CommentListItem } from '../../../viewmodel/CommentListItem' | ||
| 6 | +import measure from '@ohos.measure' | ||
| 7 | + | ||
| 8 | +@Component | ||
| 9 | +export struct VisitorCommentComponent { | ||
| 10 | + @ObjectLink data: CommentListItem | ||
| 11 | + isLastItem: boolean = false | ||
| 12 | + @State isExpand: boolean = false; | ||
| 13 | + @State isExpandParent: boolean = false; | ||
| 14 | + @State isOverLines: boolean = false | ||
| 15 | + @State isOverLinesParent: boolean = false | ||
| 16 | + | ||
| 17 | + build() { | ||
| 18 | + Column() { | ||
| 19 | + Row() { | ||
| 20 | + if (this.isExpand) { | ||
| 21 | + Text() { | ||
| 22 | + Span(this.data.commentContent) | ||
| 23 | + } | ||
| 24 | + .textStyle() | ||
| 25 | + } else { | ||
| 26 | + Text() { | ||
| 27 | + Span(this.clipText(this.data.commentContent, 31, 5, 630, 0)) | ||
| 28 | + if (this.isOverLines) { | ||
| 29 | + Span('...展开') | ||
| 30 | + .fontColor($r('app.color.color_999999')) | ||
| 31 | + .onClick(() => { | ||
| 32 | + this.isExpand = true | ||
| 33 | + }) | ||
| 34 | + } | ||
| 35 | + }.maxLines(5) | ||
| 36 | + .wordBreak(WordBreak.BREAK_ALL) | ||
| 37 | + .textStyle() | ||
| 38 | + } | ||
| 39 | + }.padding({ left: '31lpx', right: '31lpx' }) | ||
| 40 | + .width('100%') | ||
| 41 | + | ||
| 42 | + Column() { | ||
| 43 | + if (StringUtils.isNotEmpty(this.data.parentCommentContent)) { | ||
| 44 | + //父评论 | ||
| 45 | + Row() { | ||
| 46 | + if (this.isExpandParent) { | ||
| 47 | + Text() { | ||
| 48 | + Span(`@${this.data.parentCommentUserName}:`) | ||
| 49 | + .fontColor($r('app.color.color_000000')) | ||
| 50 | + .fontWeight('500lpx') | ||
| 51 | + .fontSize('27lpx') | ||
| 52 | + .lineHeight('40lpx') | ||
| 53 | + Span(this.data.parentCommentContent) | ||
| 54 | + .fontColor($r('app.color.color_000000')) | ||
| 55 | + .fontWeight('400lpx') | ||
| 56 | + .fontSize('27lpx') | ||
| 57 | + .lineHeight('40lpx') | ||
| 58 | + } | ||
| 59 | + .width('100%') | ||
| 60 | + .textAlign(TextAlign.Start) | ||
| 61 | + } else { | ||
| 62 | + Text() { | ||
| 63 | + Span(`@${this.data.parentCommentUserName}:`) | ||
| 64 | + .fontColor($r('app.color.color_000000')) | ||
| 65 | + .fontWeight('500lpx') | ||
| 66 | + .fontSize('27lpx') | ||
| 67 | + .lineHeight('40lpx') | ||
| 68 | + | ||
| 69 | + Span(this.clipText(this.data.parentCommentContent, 31, 5, 630, 1)) | ||
| 70 | + .fontColor($r('app.color.color_000000')) | ||
| 71 | + .fontWeight('400lpx') | ||
| 72 | + .fontSize('27lpx') | ||
| 73 | + .lineHeight('40lpx') | ||
| 74 | + if (this.isOverLinesParent) { | ||
| 75 | + Span('...展开') | ||
| 76 | + .fontColor($r('app.color.color_999999')) | ||
| 77 | + .onClick(() => { | ||
| 78 | + this.isExpandParent = true | ||
| 79 | + }) | ||
| 80 | + } | ||
| 81 | + }.maxLines(5) | ||
| 82 | + .wordBreak(WordBreak.BREAK_ALL) | ||
| 83 | + .textAlign(TextAlign.Start) | ||
| 84 | + .width('100%') | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + .width('100%') | ||
| 88 | + .padding({ top: '23lpx', bottom: '15lpx', right: '23lpx' }) | ||
| 89 | + | ||
| 90 | + Divider() | ||
| 91 | + .width('100%') | ||
| 92 | + .height('1lpx') | ||
| 93 | + .strokeWidth('1lpx') | ||
| 94 | + .backgroundColor($r('app.color.color_EDEDED')) | ||
| 95 | + .margin({ top: '4lpx', bottom: '4lpx' }) | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + Column() { | ||
| 99 | + Row() { | ||
| 100 | + Row() { | ||
| 101 | + Image($r('app.media.comment_link_icon')) | ||
| 102 | + .objectFit(ImageFit.Auto) | ||
| 103 | + .width('31lpx') | ||
| 104 | + .height('31lpx') | ||
| 105 | + .margin({ right: '10lpx' }) | ||
| 106 | + | ||
| 107 | + Column() { | ||
| 108 | + Row() { | ||
| 109 | + Text(`${this.data.targetTitle}`) | ||
| 110 | + .fontWeight('400lpx') | ||
| 111 | + .fontColor($r('app.color.color_666666')) | ||
| 112 | + .lineHeight('38lpx') | ||
| 113 | + .fontSize('27lpx') | ||
| 114 | + .layoutWeight(1) | ||
| 115 | + .maxLines(1) | ||
| 116 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 117 | + }.width('100%') | ||
| 118 | + } | ||
| 119 | + .layoutWeight(1) | ||
| 120 | + .alignItems(HorizontalAlign.Start) | ||
| 121 | + }.layoutWeight(1) | ||
| 122 | + | ||
| 123 | + Image($r('app.media.arrow_icon_right')) | ||
| 124 | + .margin({ right: '4lpx' }) | ||
| 125 | + .width('23lpx') | ||
| 126 | + .height('23lpx') | ||
| 127 | + .margin({right:'23lpx'}) | ||
| 128 | + } | ||
| 129 | + .width('100%') | ||
| 130 | + .height('69lpx') | ||
| 131 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 132 | + | ||
| 133 | + }.height('69lpx') | ||
| 134 | + .justifyContent(FlexAlign.Center) | ||
| 135 | + } | ||
| 136 | + .margin({ top: '19lpx', bottom: '31lpx', left: '31lpx', right: '31lpx' }) | ||
| 137 | + .padding({ left: '23lpx' }) | ||
| 138 | + .width('662lpx') | ||
| 139 | + .backgroundColor($r('app.color.color_F5F5F5')) | ||
| 140 | + | ||
| 141 | + if (!this.isLastItem) { | ||
| 142 | + Divider().width('100%') | ||
| 143 | + .height('12lpx') | ||
| 144 | + .strokeWidth('12lpx') | ||
| 145 | + .color($r('app.color.color_F5F5F5')) | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + .justifyContent(FlexAlign.Center) | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + commentLikeOperation() { | ||
| 152 | + let item = new CommentLikeOperationRequestItem(this.data.targetId, this.data.id + "", this.data.targetType + "", UserDataLocal.getUserName(), UserDataLocal.getUserHeaderUrl(), this.data.like_status === 0 ? 1 : 0) | ||
| 153 | + MinePageDatasModel.getCommentLikeOperation(item, getContext(this)).then((value) => { | ||
| 154 | + if (value != null) { | ||
| 155 | + if (value.code === 0 || value.code.toString() === "0") { | ||
| 156 | + this.data.like_status = this.data.like_status === 0 ? 1 : 0 | ||
| 157 | + this.data.likeNum = this.data.like_status === 0 ? this.data.likeNum - 1 : this.data.likeNum + 1 | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + }) | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + /** | ||
| 164 | + * 截断文本 | ||
| 165 | + * @author liuzhendong(猩猩G) | ||
| 166 | + * @param {string} str 要截断的文本 '啊啊啊啊啊' | ||
| 167 | + * @param {number} fontSize 字体大小(px) | ||
| 168 | + * @param {number} maxLines 最大行数 3 | ||
| 169 | + * @param {number} textWidth 文本宽度(px) vp 需要转换vp2px() | ||
| 170 | + * @returns {string} clipStr 截断后的文本 '啊啊' | ||
| 171 | + * @param {type} 0 我的评论 1 父评论 | ||
| 172 | + */ | ||
| 173 | + clipText(str: string, fontSize: number, maxLines: number, textWidth: number, type: number): string { | ||
| 174 | + let strArr: string[] = str.split("") | ||
| 175 | + let truncateContent: string = '啊啊啊啊啊' // ...比正常文字宽度更小,这里使用啊啊啊(任意三个文字)代替计算 | ||
| 176 | + let measureTruncateWidth: number = measure.measureText({ | ||
| 177 | + textContent: truncateContent, | ||
| 178 | + fontSize: px2fp(fontSize), | ||
| 179 | + wordBreak:WordBreak.BREAK_ALL | ||
| 180 | + }) | ||
| 181 | + if(type === 1){ | ||
| 182 | + measureTruncateWidth = measureTruncateWidth + measure.measureText({ | ||
| 183 | + textContent: `@${this.data.parentCommentUserName}:`, | ||
| 184 | + fontSize: px2fp(fontSize), | ||
| 185 | + wordBreak:WordBreak.BREAK_ALL | ||
| 186 | + }) | ||
| 187 | + } | ||
| 188 | + let clipStr: string = '' | ||
| 189 | + for (let i = 0; i < strArr.length; i++) { | ||
| 190 | + if (measure.measureText({ | ||
| 191 | + textContent: clipStr, | ||
| 192 | + fontSize: px2fp(fontSize), | ||
| 193 | + wordBreak:WordBreak.BREAK_ALL | ||
| 194 | + }) >= textWidth * maxLines - measureTruncateWidth) { | ||
| 195 | + if (type === 0) { | ||
| 196 | + this.isOverLines = true | ||
| 197 | + } else { | ||
| 198 | + this.isOverLinesParent = true | ||
| 199 | + } | ||
| 200 | + break; | ||
| 201 | + } | ||
| 202 | + clipStr += strArr[i] | ||
| 203 | + } | ||
| 204 | + return clipStr | ||
| 205 | + } | ||
| 206 | +} | ||
| 207 | + | ||
| 208 | +@Extend(Text) | ||
| 209 | +function textStyle() { | ||
| 210 | + .width('630lpx') | ||
| 211 | + .fontSize('31lpx') | ||
| 212 | + .fontWeight('400lpx') | ||
| 213 | + .fontColor($r('app.color.color_222222')) | ||
| 214 | + .lineHeight('46lpx') | ||
| 215 | +} | ||
| 216 | + | ||
| 217 | +function getParams(item: CommentListItem) : ContentDTO{ | ||
| 218 | + let contentDTO = new ContentDTO(); | ||
| 219 | + | ||
| 220 | + // contentDTO.objectType = item.targetType + "" | ||
| 221 | + // contentDTO.objectId = item.targetId + "" | ||
| 222 | + // contentDTO.newsTitle = item.targetTitle | ||
| 223 | + // contentDTO.channelId = | ||
| 224 | + // contentDTO.rmhPlatform = | ||
| 225 | + | ||
| 226 | + contentDTO.objectId = item.targetId; | ||
| 227 | + contentDTO.relType = item.targetRelType + ""; | ||
| 228 | + contentDTO.relId = item.targetRelId; | ||
| 229 | + contentDTO.objectType = item.targetType + ""; | ||
| 230 | + contentDTO.newsTitle = item.targetTitle | ||
| 231 | + | ||
| 232 | + return contentDTO | ||
| 233 | +} |
| @@ -29,10 +29,10 @@ export struct CustomTitleUI { | @@ -29,10 +29,10 @@ export struct CustomTitleUI { | ||
| 29 | Text(this.titleName) | 29 | Text(this.titleName) |
| 30 | .maxLines(1) | 30 | .maxLines(1) |
| 31 | .id("title") | 31 | .id("title") |
| 32 | - .fontSize(`${this.calcHeight(30)}lpx`) | 32 | + .fontSize(`${this.calcHeight(35)}lpx`) |
| 33 | .fontWeight(400) | 33 | .fontWeight(400) |
| 34 | .fontColor($r('app.color.color_222222')) | 34 | .fontColor($r('app.color.color_222222')) |
| 35 | - .lineHeight(`${this.calcHeight(43)}lpx`) | 35 | + .lineHeight(`${this.calcHeight(50)}lpx`) |
| 36 | .alignRules({ | 36 | .alignRules({ |
| 37 | center: {anchor: "__container__", align: VerticalAlign.Center}, | 37 | center: {anchor: "__container__", align: VerticalAlign.Center}, |
| 38 | middle: {anchor: "__container__", align: HorizontalAlign.Center} | 38 | middle: {anchor: "__container__", align: HorizontalAlign.Center} |
| @@ -4,7 +4,7 @@ import MinePageCreatorFunctionsItem from '../viewmodel/MinePageCreatorFunctionsI | @@ -4,7 +4,7 @@ import MinePageCreatorFunctionsItem from '../viewmodel/MinePageCreatorFunctionsI | ||
| 4 | import MinePageMoreFunctionModel from '../viewmodel/MinePageMoreFunctionModel'; | 4 | import MinePageMoreFunctionModel from '../viewmodel/MinePageMoreFunctionModel'; |
| 5 | import { HttpBizUtil, HttpUrlUtils, HttpUtils, ResponseDTO, WDHttp } from 'wdNetwork'; | 5 | import { HttpBizUtil, HttpUrlUtils, HttpUtils, ResponseDTO, WDHttp } from 'wdNetwork'; |
| 6 | import { MineAppointmentListItem } from '../viewmodel/MineAppointmentListItem'; | 6 | import { MineAppointmentListItem } from '../viewmodel/MineAppointmentListItem'; |
| 7 | -import { Logger, StringUtils, EmitterUtils, EmitterEventId, SPHelper } from 'wdKit'; | 7 | +import { Logger, StringUtils, EmitterUtils, EmitterEventId, SPHelper, DeviceUtil, DateTimeUtils } from 'wdKit'; |
| 8 | import { MineFollowListDetailItem } from '../viewmodel/MineFollowListDetailItem'; | 8 | import { MineFollowListDetailItem } from '../viewmodel/MineFollowListDetailItem'; |
| 9 | import { FollowListDetailRequestItem } from '../viewmodel/FollowListDetailRequestItem'; | 9 | import { FollowListDetailRequestItem } from '../viewmodel/FollowListDetailRequestItem'; |
| 10 | import { FollowListItem } from '../viewmodel/FollowListItem'; | 10 | import { FollowListItem } from '../viewmodel/FollowListItem'; |
| @@ -918,6 +918,37 @@ class MinePageDatasModel{ | @@ -918,6 +918,37 @@ class MinePageDatasModel{ | ||
| 918 | return rmhInfo | 918 | return rmhInfo |
| 919 | } | 919 | } |
| 920 | 920 | ||
| 921 | + /** | ||
| 922 | + * 游客评论列表 | ||
| 923 | + * @param pageSize | ||
| 924 | + * @param pageNum | ||
| 925 | + * @returns | ||
| 926 | + */ | ||
| 927 | + fetchVisitorCommentListData(pageNum:string,visitorFirstTime:string) { | ||
| 928 | + let time = encodeURI(DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)) | ||
| 929 | + let deviceId = DeviceUtil.clientId() | ||
| 930 | + let url = HttpUrlUtils.getVisitorCommentListDataUrl()+ `?pageSize=${20}&pageNum=${pageNum}&visitorFirstTime=${visitorFirstTime}&time=${time}&deviceId=${deviceId}` | ||
| 931 | + return WDHttp.get<ResponseDTO<MineCommentListDetailItem>>(url) | ||
| 932 | + }; | ||
| 933 | + | ||
| 934 | + visitorCommentListData(pageNum:string,visitorFirstTime:string): Promise<MineCommentListDetailItem> { | ||
| 935 | + return new Promise<MineCommentListDetailItem>((success, error) => { | ||
| 936 | + Logger.info(TAG, `visitorCommentListData start`); | ||
| 937 | + this.fetchVisitorCommentListData(pageNum,visitorFirstTime).then((navResDTO: ResponseDTO<MineCommentListDetailItem>) => { | ||
| 938 | + if (!navResDTO || navResDTO.code != 0) { | ||
| 939 | + error(null) | ||
| 940 | + return | ||
| 941 | + } | ||
| 942 | + Logger.info(TAG, "visitorCommentListData then,visitorCommentListData.timeStamp:" + navResDTO.timestamp); | ||
| 943 | + let navigationBean = navResDTO.data as MineCommentListDetailItem | ||
| 944 | + success(navigationBean); | ||
| 945 | + }).catch((err: Error) => { | ||
| 946 | + Logger.error(TAG, `visitorCommentListData catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 947 | + error(null) | ||
| 948 | + }) | ||
| 949 | + }) | ||
| 950 | + } | ||
| 951 | + | ||
| 921 | } | 952 | } |
| 922 | 953 | ||
| 923 | const minePageDatasModel = MinePageDatasModel.getInstance() | 954 | const minePageDatasModel = MinePageDatasModel.getInstance() |
| 1 | +import { TAG } from '@ohos/hypium/src/main/Constant'; | ||
| 2 | +import { ContentDTO } from 'wdBean/Index'; | ||
| 3 | +import { SpConstants } from 'wdConstant/Index' | ||
| 4 | +import { DateTimeUtils, LazyDataSource, NetworkUtil, SPHelper, StringUtils} from 'wdKit/Index' | ||
| 5 | +import { ProcessUtils } from 'wdRouter/Index'; | ||
| 6 | +import { VisitorCommentComponent } from '../components/mine/home/VisitorCommentComponent'; | ||
| 7 | +import { CustomPullToRefresh } from '../components/reusable/CustomPullToRefresh'; | ||
| 8 | +import { CustomTitleUI } from '../components/reusable/CustomTitleUI'; | ||
| 9 | +import { ListHasNoMoreDataUI } from '../components/reusable/ListHasNoMoreDataUI'; | ||
| 10 | +import { EmptyComponent } from '../components/view/EmptyComponent'; | ||
| 11 | +import MinePageDatasModel from '../model/MinePageDatasModel'; | ||
| 12 | +import { CommentListItem } from '../viewmodel/CommentListItem'; | ||
| 13 | + | ||
| 14 | +@Entry | ||
| 15 | +@Component | ||
| 16 | +struct VisitorCommentPage { | ||
| 17 | + @State data: LazyDataSource<CommentListItem> = new LazyDataSource(); | ||
| 18 | + @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | ||
| 19 | + @State count: number = 0; | ||
| 20 | + @State isLoading: boolean = false | ||
| 21 | + @State hasMore: boolean = true | ||
| 22 | + curPageNum: number = 1; | ||
| 23 | + @State isGetRequest: boolean = false | ||
| 24 | + private scroller: Scroller = new Scroller(); | ||
| 25 | + @State isConnectNetwork : boolean = NetworkUtil.isNetConnected() | ||
| 26 | + @State commentTime:string = "" | ||
| 27 | + | ||
| 28 | + aboutToAppear(): void { | ||
| 29 | + this.commentTime = SPHelper.default.getSync(SpConstants.FIRSTCOMMENTTIME, "") as string | ||
| 30 | + if (StringUtils.isNotEmpty(this.commentTime)) { | ||
| 31 | + this.getNewPageData(this.commentTime) | ||
| 32 | + }else{ | ||
| 33 | + this.isGetRequest = true | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + build() { | ||
| 38 | + Column() { | ||
| 39 | + //标题栏目 | ||
| 40 | + CustomTitleUI({ titleName: "评论列表" }) | ||
| 41 | + if (this.count == 0) { | ||
| 42 | + if (this.isGetRequest == true) { | ||
| 43 | + if(this.isConnectNetwork){ | ||
| 44 | + EmptyComponent({ emptyType: 10 }) | ||
| 45 | + .height('100%') | ||
| 46 | + .width('100%') | ||
| 47 | + }else{ | ||
| 48 | + EmptyComponent({ emptyType: 1,emptyHeight:"100%" ,retry: () => { | ||
| 49 | + this.isConnectNetwork = NetworkUtil.isNetConnected() | ||
| 50 | + if(this.isConnectNetwork){ | ||
| 51 | + this.curPageNum = 1; | ||
| 52 | + this.hasMore = true | ||
| 53 | + this.isGetRequest = false | ||
| 54 | + this.data.clear() | ||
| 55 | + | ||
| 56 | + if (!this.isLoading) { | ||
| 57 | + this.getNewPageData(this.commentTime) | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + }}) | ||
| 61 | + .layoutWeight(1) | ||
| 62 | + .width('100%') | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + } else { | ||
| 66 | + Stack(){ | ||
| 67 | + Row() | ||
| 68 | + .width("100%") | ||
| 69 | + .height("100%") | ||
| 70 | + .backgroundColor($r('app.color.white')) | ||
| 71 | + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) | ||
| 72 | + CustomPullToRefresh({ | ||
| 73 | + alldata:this.data, | ||
| 74 | + scroller:this.scroller, | ||
| 75 | + customList:()=>{ | ||
| 76 | + this.ListLayout() | ||
| 77 | + }, | ||
| 78 | + onRefresh:(resolve)=>{ | ||
| 79 | + this.curPageNum = 1; | ||
| 80 | + this.hasMore = true | ||
| 81 | + this.isGetRequest = false | ||
| 82 | + this.data.clear() | ||
| 83 | + | ||
| 84 | + if (!this.isLoading){ | ||
| 85 | + this.getNewPageData(this.commentTime) | ||
| 86 | + if(resolve) resolve('刷新成功') | ||
| 87 | + } | ||
| 88 | + }, | ||
| 89 | + onLoadMore:(resolve)=> { | ||
| 90 | + if (!this.isLoading) { | ||
| 91 | + this.isLoading = true | ||
| 92 | + this.getNewPageData(this.commentTime) | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + }) | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + .backgroundColor($r('app.color.color_transparent')) | ||
| 100 | + .height('100%') | ||
| 101 | + .width('100%') | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + @Builder ListLayout(){ | ||
| 105 | + List({ space:6,scroller: this.scroller }) { | ||
| 106 | + LazyForEach(this.data, (item: CommentListItem, index: number) => { | ||
| 107 | + ListItem() { | ||
| 108 | + VisitorCommentComponent({ | ||
| 109 | + data: item, | ||
| 110 | + isLastItem: index === this.data.totalCount() - 1 | ||
| 111 | + }) | ||
| 112 | + } | ||
| 113 | + .onClick(() => { | ||
| 114 | + let content = getParams(item) | ||
| 115 | + ProcessUtils.processPage(content) | ||
| 116 | + }) | ||
| 117 | + }, (item: CommentListItem, index: number) => index.toString()) | ||
| 118 | + | ||
| 119 | + //没有更多数据 显示提示 | ||
| 120 | + if (!this.hasMore) { | ||
| 121 | + ListItem() { | ||
| 122 | + ListHasNoMoreDataUI() | ||
| 123 | + }.padding({bottom:px2vp(this.bottomSafeHeight) + 20}) | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + .cachedCount(4) | ||
| 127 | + .scrollBar(BarState.Off) | ||
| 128 | + .edgeEffect(EdgeEffect.None) | ||
| 129 | + .margin({ top: '23lpx'}) | ||
| 130 | + .layoutWeight(1) | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + getNewPageData(commentTime:string) { | ||
| 134 | + this.isLoading = true | ||
| 135 | + if (this.hasMore) { | ||
| 136 | + MinePageDatasModel.visitorCommentListData( `${this.curPageNum}`, encodeURI(commentTime)).then((value) => { | ||
| 137 | + if (!this.data || value.list.length == 0) { | ||
| 138 | + this.hasMore = false | ||
| 139 | + } else { | ||
| 140 | + value.list.forEach((item) => { | ||
| 141 | + let commentContent = item.commentContent | ||
| 142 | + if (item.sensitiveShow === 0 && item.sensitiveExist === 1) { | ||
| 143 | + commentContent = item.commentContentSensitive | ||
| 144 | + } | ||
| 145 | + let parentCommentContent = "" | ||
| 146 | + if (item.parentCommentVo != null) { | ||
| 147 | + parentCommentContent = item.parentCommentVo.commentContent | ||
| 148 | + } | ||
| 149 | + let parentCommentUserName = "" | ||
| 150 | + if (item.parentCommentVo != null) { | ||
| 151 | + parentCommentUserName = item.parentCommentVo.fromUserName | ||
| 152 | + } | ||
| 153 | + let publishTime = | ||
| 154 | + DateTimeUtils.getCommentTime(DateTimeUtils.parseDate(item.createTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)) | ||
| 155 | + | ||
| 156 | + this.data.push(new CommentListItem(item.fromUserHeader, item.fromUserName, item.targetTitle, publishTime, | ||
| 157 | + commentContent, item.likeNum, 0, item.id, item.targetId, item.targetType, item.targetRelId, | ||
| 158 | + item.targetRelObjectId, item.targetRelType, item.targetStatus, item.checkStatus, parentCommentContent, | ||
| 159 | + parentCommentUserName)) | ||
| 160 | + | ||
| 161 | + }) | ||
| 162 | + this.data.notifyDataReload() | ||
| 163 | + this.count = this.data.totalCount() | ||
| 164 | + if (this.data.totalCount() < value.totalCount) { | ||
| 165 | + this.curPageNum++ | ||
| 166 | + } else { | ||
| 167 | + this.hasMore = false | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + this.isGetRequest = true | ||
| 171 | + this.isLoading = false | ||
| 172 | + }).catch((err: Error) => { | ||
| 173 | + console.log(TAG, JSON.stringify(err)) | ||
| 174 | + this.isGetRequest = true | ||
| 175 | + this.isLoading = false | ||
| 176 | + }) | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | +} | ||
| 180 | + | ||
| 181 | +function getParams(item: CommentListItem) : ContentDTO{ | ||
| 182 | + let contentDTO = new ContentDTO(); | ||
| 183 | + | ||
| 184 | + // contentDTO.objectType = item.targetType + "" | ||
| 185 | + // contentDTO.objectId = item.targetId + "" | ||
| 186 | + // contentDTO.newsTitle = item.targetTitle | ||
| 187 | + // contentDTO.channelId = | ||
| 188 | + // contentDTO.rmhPlatform = | ||
| 189 | + | ||
| 190 | + contentDTO.objectId = item.targetId; | ||
| 191 | + contentDTO.relType = item.targetRelType + ""; | ||
| 192 | + contentDTO.relId = item.targetRelId; | ||
| 193 | + contentDTO.objectType = item.targetType + ""; | ||
| 194 | + contentDTO.newsTitle = item.targetTitle | ||
| 195 | + | ||
| 196 | + return contentDTO | ||
| 197 | +} |
| @@ -26,6 +26,7 @@ | @@ -26,6 +26,7 @@ | ||
| 26 | "pages/MineMessagePage", | 26 | "pages/MineMessagePage", |
| 27 | "components/page/InteractMessagePage", | 27 | "components/page/InteractMessagePage", |
| 28 | "pages/ShowHomePageHeaderPage", | 28 | "pages/ShowHomePageHeaderPage", |
| 29 | - "pages/SubscribeMessagePage" | 29 | + "pages/SubscribeMessagePage", |
| 30 | + "pages/VisitorCommentPage" | ||
| 30 | ] | 31 | ] |
| 31 | } | 32 | } |
-
Please register or login to post a comment