Showing
1 changed file
with
122 additions
and
325 deletions
| @@ -12,71 +12,47 @@ import { | @@ -12,71 +12,47 @@ import { | ||
| 12 | import router from '@ohos.router'; | 12 | import router from '@ohos.router'; |
| 13 | import inputMethod from '@ohos.inputMethod'; | 13 | import inputMethod from '@ohos.inputMethod'; |
| 14 | import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel'; | 14 | import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel'; |
| 15 | -import { LikeComponent } from './LikeComponent'; | ||
| 16 | -import { CommentTabComponent, CommentIconComponent, } from '../comment/view/CommentTabComponent'; | 15 | +import { LikeComponent } from './LikeComponent'; |
| 16 | +import { CommentTabComponent, CommentIconComponent, } from '../comment/view/CommentTabComponent'; | ||
| 17 | import { publishCommentModel } from '../comment/model/PublishCommentModel' | 17 | import { publishCommentModel } from '../comment/model/PublishCommentModel' |
| 18 | - | ||
| 19 | -// import { CommentCustomDialog } from '../comment/view/CommentCustomDialog'; | ||
| 20 | import { HttpUrlUtils } from 'wdNetwork/Index'; | 18 | import { HttpUrlUtils } from 'wdNetwork/Index'; |
| 21 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | 19 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; |
| 22 | import { PageRepository } from '../../repository/PageRepository'; | 20 | import { PageRepository } from '../../repository/PageRepository'; |
| 23 | import { SpConstants } from 'wdConstant/Index'; | 21 | import { SpConstants } from 'wdConstant/Index'; |
| 24 | 22 | ||
| 25 | -export interface OperationItem { | ||
| 26 | - icon: Resource; | ||
| 27 | - icon_check?: Resource; | ||
| 28 | - text: string | Resource; | ||
| 29 | - num?: number; // 个数 | ||
| 30 | -} | ||
| 31 | - | ||
| 32 | const TAG = 'OperRowListView'; | 23 | const TAG = 'OperRowListView'; |
| 33 | 24 | ||
| 34 | -// @Preview | ||
| 35 | -@Entry | 25 | +/** |
| 26 | + * 稿件详情底部通栏组件:包含返回、评论、点赞、收藏、分享 | ||
| 27 | + * 上层传值: | ||
| 28 | + * 1、(必传) contentDetailData---稿件详情 | ||
| 29 | + * 2、(非必传) operationButtonList---组件展示条件,['comment', 'like', 'collect', 'share'],需要展示什么传什么 | ||
| 30 | + * comment--评论;like--点赞;collect--收藏;share--分享; | ||
| 31 | + * | ||
| 32 | + * 传值示例: | ||
| 33 | + OperRowListView({ | ||
| 34 | + contentDetailData: this.contentDetailData[0], | ||
| 35 | + operationButtonList: ['comment', 'like', 'collect', 'share'] | ||
| 36 | + }) | ||
| 37 | + */ | ||
| 38 | +@Preview | ||
| 36 | @Component | 39 | @Component |
| 37 | export struct OperRowListView { | 40 | export struct OperRowListView { |
| 38 | - // private contentDetailData: ContentDetailDTO = {} as ContentDetailDTO | ||
| 39 | - // @Prop contentDetailData: ContentDetailDTO | ||
| 40 | - @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO | ||
| 41 | - @State interactData: InteractDataDTO = {} as InteractDataDTO | 41 | + @Prop contentDetailData: ContentDetailDTO // 稿件详情 |
| 42 | + @State operationButtonList: string[] = ['comment', 'like', 'collect', 'share'] // 组件展示条件 | ||
| 43 | + // @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO | ||
| 44 | + @State interactData: InteractDataDTO = {} as InteractDataDTO | ||
| 42 | @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 | 45 | @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 |
| 43 | @State likeBean: Record<string, string> = {} | 46 | @State likeBean: Record<string, string> = {} |
| 44 | @State publishCommentModel: publishCommentModel = new publishCommentModel() | 47 | @State publishCommentModel: publishCommentModel = new publishCommentModel() |
| 45 | 48 | ||
| 46 | - @State operationList: OperationItem[] = [ | ||
| 47 | - { | ||
| 48 | - icon: $r('app.media.ic_comment'), | ||
| 49 | - text: "评论", | ||
| 50 | - }, | ||
| 51 | - { | ||
| 52 | - icon: $r('app.media.ic_like_uncheck'), | ||
| 53 | - icon_check: $r('app.media.ic_like_check'), | ||
| 54 | - text: "点赞", | ||
| 55 | - }, | ||
| 56 | - { | ||
| 57 | - icon: $r('app.media.ic_collect_uncheck'), | ||
| 58 | - icon_check: $r('app.media.ic_collect_check'), | ||
| 59 | - text: "收藏", | ||
| 60 | - }, | ||
| 61 | - { | ||
| 62 | - icon: $r('app.media.ic_share'), | ||
| 63 | - text: "分享" | ||
| 64 | - } | ||
| 65 | - ] | ||
| 66 | - | ||
| 67 | async aboutToAppear() { | 49 | async aboutToAppear() { |
| 68 | const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | 50 | const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') |
| 69 | if (user_id) { | 51 | if (user_id) { |
| 70 | this.getInteractDataStatus() | 52 | this.getInteractDataStatus() |
| 71 | } | 53 | } |
| 72 | - this.queryContentInteractCount() | 54 | + await this.queryContentInteractCount() |
| 73 | // 点赞需要数据 | 55 | // 点赞需要数据 |
| 74 | - // this.data['userName'] = '人民日报网友2kD2xW' | ||
| 75 | - // this.data['contentType'] = '8' //必须 | ||
| 76 | - // this.data['title'] = '开创两校交流先河!克罗地亚教育代表团访问同济大学' | ||
| 77 | - // this.data['userHeaderUrl'] = "" | ||
| 78 | - // this.data['channelId'] = "2059" //必须 | ||
| 79 | - // this.data['status'] = "1" //必须 | ||
| 80 | this.likeBean['contentId'] = this.contentDetailData.newsId + '' | 56 | this.likeBean['contentId'] = this.contentDetailData.newsId + '' |
| 81 | this.likeBean['userName'] = this.contentDetailData.userInfo?.userName + '' | 57 | this.likeBean['userName'] = this.contentDetailData.userInfo?.userName + '' |
| 82 | this.likeBean['contentType'] = this.contentDetailData.newsType + '' | 58 | this.likeBean['contentType'] = this.contentDetailData.newsType + '' |
| @@ -86,294 +62,137 @@ export struct OperRowListView { | @@ -86,294 +62,137 @@ export struct OperRowListView { | ||
| 86 | console.info(TAG, 'contentDetailData----', JSON.stringify(this.contentDetailData)) | 62 | console.info(TAG, 'contentDetailData----', JSON.stringify(this.contentDetailData)) |
| 87 | console.info(TAG, 'likeBean----', JSON.stringify(this.likeBean)) | 63 | console.info(TAG, 'likeBean----', JSON.stringify(this.likeBean)) |
| 88 | // 评论需要数据 | 64 | // 评论需要数据 |
| 89 | - this.publishCommentModel.targetId = this.contentDetailData.newsId + '' | ||
| 90 | - this.publishCommentModel.targetRelId = this.contentDetailData.reLInfo?.relId + '' | ||
| 91 | - this.publishCommentModel.targetTitle = this.contentDetailData.newsTitle + '' | ||
| 92 | - this.publishCommentModel.targetRelType = this.contentDetailData.reLInfo?.relType + '' | ||
| 93 | - this.publishCommentModel.targetRelObjectId = this.contentDetailData.reLInfo?.relObjectId + '' | ||
| 94 | - this.publishCommentModel.keyArticle = this.contentDetailData.keyArticle + '' | ||
| 95 | - this.publishCommentModel.targetType = this.contentDetailData.newsType + '' | ||
| 96 | - this.publishCommentModel.totalCommentNumer = '10' | 65 | + this.publishCommentModel.targetId = this.contentDetailData.newsId + '' |
| 66 | + this.publishCommentModel.targetRelId = this.contentDetailData.reLInfo?.relId + '' | ||
| 67 | + this.publishCommentModel.targetTitle = this.contentDetailData.newsTitle + '' | ||
| 68 | + this.publishCommentModel.targetRelType = this.contentDetailData.reLInfo?.relType + '' | ||
| 69 | + this.publishCommentModel.targetRelObjectId = this.contentDetailData.reLInfo?.relObjectId + '' | ||
| 70 | + this.publishCommentModel.keyArticle = this.contentDetailData.keyArticle + '' | ||
| 71 | + this.publishCommentModel.targetType = this.contentDetailData.newsType + '' | ||
| 97 | } | 72 | } |
| 98 | 73 | ||
| 99 | build() { | 74 | build() { |
| 100 | - Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems:ItemAlign.Center }){ | 75 | + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { |
| 101 | Row() { | 76 | Row() { |
| 102 | Column() { | 77 | Column() { |
| 103 | - // Image($r('app.media.icon_arrow_left_white')) | ||
| 104 | Image($r('app.media.icon_arrow_left')) | 78 | Image($r('app.media.icon_arrow_left')) |
| 105 | .width(24) | 79 | .width(24) |
| 106 | .height(24) | 80 | .height(24) |
| 107 | .aspectRatio(1) | 81 | .aspectRatio(1) |
| 108 | .interpolation(ImageInterpolation.High) | 82 | .interpolation(ImageInterpolation.High) |
| 109 | } | 83 | } |
| 110 | - .margin({ | ||
| 111 | - top: 0, | ||
| 112 | - left: 8, | ||
| 113 | - right: 8, | ||
| 114 | - bottom: 0 | ||
| 115 | - }) | ||
| 116 | - .alignItems(HorizontalAlign.Center) | ||
| 117 | .hoverEffect(HoverEffect.Scale) | 84 | .hoverEffect(HoverEffect.Scale) |
| 118 | .onClick(() => { | 85 | .onClick(() => { |
| 119 | router.back(); | 86 | router.back(); |
| 120 | }) | 87 | }) |
| 121 | - Column() { | ||
| 122 | - /*评论组件*/ | ||
| 123 | - /* CommentCustomDialog({ | ||
| 124 | - placeHolderText: '说两句' | ||
| 125 | - })*/ | ||
| 126 | - if (this.publishCommentModel?.targetId) { | ||
| 127 | - CommentTabComponent({publishCommentModel: this.publishCommentModel}) | ||
| 128 | - CommentIconComponent({publishCommentModel: this.publishCommentModel}) | 88 | + .width(42) |
| 89 | + | ||
| 90 | + ForEach(this.operationButtonList, (item: string, index: number) => { | ||
| 91 | + if (item == 'comment') { | ||
| 92 | + this.builderComment() | ||
| 93 | + } else if (item == 'like') { | ||
| 94 | + this.builderLike() | ||
| 95 | + } else if (item == 'collect') { | ||
| 96 | + this.builderCollect() | ||
| 97 | + } else if (item == 'share') { | ||
| 98 | + this.builderShare() | ||
| 99 | + } else { | ||
| 129 | } | 100 | } |
| 130 | - } | ||
| 131 | - /*TextInput({placeholder:'说两句...'}) | ||
| 132 | - .placeholderColor('#999999') | ||
| 133 | - .placeholderFont( | ||
| 134 | - { | ||
| 135 | - size: 12, | ||
| 136 | - weight: 400, | ||
| 137 | - family: 'PingFang SC-Regular' | ||
| 138 | - } | ||
| 139 | - ) | ||
| 140 | - .caretColor('#1A1A1A') | ||
| 141 | - .backgroundColor('#1A1A1A') | ||
| 142 | - .width('61.5%') | ||
| 143 | - .height(30) | ||
| 144 | - .borderRadius(0) | ||
| 145 | - .onClick(() => { | ||
| 146 | - this.buildInputMethod() | ||
| 147 | - })*/ | 101 | + }) |
| 148 | } | 102 | } |
| 149 | - // .width('45.5%') | ||
| 150 | - .alignItems(VerticalAlign.Center) | 103 | + .width('100%') |
| 151 | .justifyContent(FlexAlign.Start) | 104 | .justifyContent(FlexAlign.Start) |
| 152 | - Flex({ justifyContent: FlexAlign.SpaceAround, alignItems:ItemAlign.Center }) { | ||
| 153 | - ForEach(this.operationList, (item: OperationItem, index: number) => { | ||
| 154 | - this.buildOperationItem(item, index) | ||
| 155 | - }, (item: OperationItem) => JSON.stringify(item)) | ||
| 156 | - } | ||
| 157 | - .width('54.5%') | ||
| 158 | } | 105 | } |
| 159 | .width('100%') | 106 | .width('100%') |
| 160 | - .height(50) | ||
| 161 | - // .backgroundColor(Color.Black) | ||
| 162 | .backgroundColor(Color.White) | 107 | .backgroundColor(Color.White) |
| 163 | - .margin({ | ||
| 164 | - bottom: 20 | 108 | + .padding({ |
| 109 | + top: 10, | ||
| 110 | + bottom: 50 | ||
| 165 | }) | 111 | }) |
| 166 | } | 112 | } |
| 113 | + | ||
| 167 | /** | 114 | /** |
| 168 | - * 组件项 | ||
| 169 | - * | ||
| 170 | - * @param programmeBean item 组件项 | 115 | + * 评论组件 |
| 171 | */ | 116 | */ |
| 172 | @Builder | 117 | @Builder |
| 173 | - buildOperationItem(item: OperationItem, index: number) { | 118 | + builderComment() { |
| 174 | Column() { | 119 | Column() { |
| 175 | - if (item.text === '点赞') { | ||
| 176 | - /*点赞组件*/ | ||
| 177 | - if (this.likeBean?.contentId) { | ||
| 178 | - LikeComponent({ | ||
| 179 | - data: this.likeBean | ||
| 180 | - }) | ||
| 181 | - } | ||
| 182 | - | ||
| 183 | - /* RelativeContainer() { | ||
| 184 | - Row() { | ||
| 185 | - Image(this.newsStatusOfUser?.likeStatus == '1' ? item.icon_check : item.icon) | ||
| 186 | - .width(24) | ||
| 187 | - .height(24) | ||
| 188 | - .aspectRatio(1) | ||
| 189 | - .interpolation(ImageInterpolation.High) | ||
| 190 | - .onClick(() => { | ||
| 191 | - this.toggleLikeStatus() | ||
| 192 | - console.log('点赞_111', JSON.stringify(this.contentDetailData)) | ||
| 193 | - }) | ||
| 194 | - } | ||
| 195 | - .alignRules({ | ||
| 196 | - center: { anchor: '__container__', align: VerticalAlign.Center }, | ||
| 197 | - middle: { anchor: '__container__', align: HorizontalAlign.Center } | ||
| 198 | - }) | ||
| 199 | - .id(`e_row1_${index}`) | ||
| 200 | - if(this.interactData?.likeNum > 0) { | ||
| 201 | - Row() { | ||
| 202 | - Image($r('app.media.corner_mark')) | ||
| 203 | - .width(25) | ||
| 204 | - .height(12) | ||
| 205 | - .interpolation(ImageInterpolation.High) | ||
| 206 | - } | ||
| 207 | - .alignRules({ | ||
| 208 | - top: { anchor: `e_row1_${index}`, align: VerticalAlign.Top }, | ||
| 209 | - left: { anchor: `e_row1_${index}`, align: HorizontalAlign.Center } | ||
| 210 | - }) | ||
| 211 | - .id(`e_row2_${index}`) | ||
| 212 | - | ||
| 213 | - Row() { | ||
| 214 | - Text(`${this.interactData?.likeNum}`) | ||
| 215 | - .fontSize(8) | ||
| 216 | - .textAlign(TextAlign.Center) | ||
| 217 | - .fontColor(Color.White) | ||
| 218 | - .lineHeight(12) | ||
| 219 | - } | ||
| 220 | - .alignRules({ | ||
| 221 | - top: { anchor: `e_row2_${index}`, align: VerticalAlign.Top }, | ||
| 222 | - middle: { anchor: `e_row2_${index}`, align: HorizontalAlign.Center } | ||
| 223 | - }) | ||
| 224 | - .id(`e_row3_${index}`) | ||
| 225 | - } | ||
| 226 | - } | ||
| 227 | - .id(`e_icon_${index}`)*/ | ||
| 228 | - } else if (item.text === '收藏') { | ||
| 229 | - | ||
| 230 | - RelativeContainer() { | ||
| 231 | - Row() { | ||
| 232 | - Image(this.newsStatusOfUser?.collectStatus == 1 ? item.icon_check : item.icon) | ||
| 233 | - .width(24) | ||
| 234 | - .height(24) | ||
| 235 | - .aspectRatio(1) | ||
| 236 | - .interpolation(ImageInterpolation.High) | ||
| 237 | - .onClick(() => { | ||
| 238 | - this.toggleCollectStatus() | ||
| 239 | - }) | ||
| 240 | - } | ||
| 241 | - .alignRules({ | ||
| 242 | - center: { anchor: '__container__', align: VerticalAlign.Center }, | ||
| 243 | - middle: { anchor: '__container__', align: HorizontalAlign.Center } | ||
| 244 | - }) | ||
| 245 | - .id(`e_row1_${index}`) | ||
| 246 | - if(this.interactData?.collectNum > 0) { | ||
| 247 | - Row() { | ||
| 248 | - Image($r('app.media.corner_mark')) | ||
| 249 | - .width(25) | ||
| 250 | - .height(12) | ||
| 251 | - .interpolation(ImageInterpolation.High) | ||
| 252 | - } | ||
| 253 | - .alignRules({ | ||
| 254 | - top: { anchor: `e_row1_${index}`, align: VerticalAlign.Top }, | ||
| 255 | - left: { anchor: `e_row1_${index}`, align: HorizontalAlign.Center } | ||
| 256 | - }) | ||
| 257 | - .id(`e_row2_${index}`) | ||
| 258 | - | ||
| 259 | - Row() { | ||
| 260 | - Text(`${this.interactData?.collectNum}`) | ||
| 261 | - .fontSize(8) | ||
| 262 | - .textAlign(TextAlign.Center) | ||
| 263 | - .fontColor(Color.White) | ||
| 264 | - .lineHeight(12) | ||
| 265 | - } | ||
| 266 | - .alignRules({ | ||
| 267 | - top: { anchor: `e_row2_${index}`, align: VerticalAlign.Top }, | ||
| 268 | - middle: { anchor: `e_row2_${index}`, align: HorizontalAlign.Center } | ||
| 269 | - }) | ||
| 270 | - .id(`e_row3_${index}`) | ||
| 271 | - } | ||
| 272 | - } | ||
| 273 | - .id(`e_icon_${index}`) | ||
| 274 | - } else if (item.text === '评论') { | ||
| 275 | - /* RelativeContainer() { | ||
| 276 | - Row() { | ||
| 277 | - Image(item.icon) | ||
| 278 | - .width(24) | ||
| 279 | - .height(24) | ||
| 280 | - .aspectRatio(1) | ||
| 281 | - .interpolation(ImageInterpolation.High) | ||
| 282 | - .onClick((event: ClickEvent) => { | ||
| 283 | - ToastUtils.showToast('评论为公共方法,待开发', 1000); | ||
| 284 | - }) | ||
| 285 | - } | ||
| 286 | - .alignRules({ | ||
| 287 | - center: { anchor: '__container__', align: VerticalAlign.Center }, | ||
| 288 | - middle: { anchor: '__container__', align: HorizontalAlign.Center } | ||
| 289 | - }) | ||
| 290 | - .id(`e_row1_${index}`) | ||
| 291 | - if(this.interactData?.commentNum > 0) { | ||
| 292 | - Row() { | ||
| 293 | - Image($r('app.media.corner_mark')) | ||
| 294 | - .width(25) | ||
| 295 | - .height(12) | ||
| 296 | - .interpolation(ImageInterpolation.High) | ||
| 297 | - } | ||
| 298 | - .alignRules({ | ||
| 299 | - top: { anchor: `e_row1_${index}`, align: VerticalAlign.Top }, | ||
| 300 | - left: { anchor: `e_row1_${index}`, align: HorizontalAlign.Center } | ||
| 301 | - }) | ||
| 302 | - .id(`e_row2_${index}`) | ||
| 303 | - | ||
| 304 | - Row() { | ||
| 305 | - Text(`${this.interactData?.commentNum}`) | ||
| 306 | - .fontSize(8) | ||
| 307 | - .textAlign(TextAlign.Center) | ||
| 308 | - .fontColor(Color.White) | ||
| 309 | - .lineHeight(12) | ||
| 310 | - } | ||
| 311 | - .alignRules({ | ||
| 312 | - top: { anchor: `e_row2_${index}`, align: VerticalAlign.Top }, | ||
| 313 | - middle: { anchor: `e_row2_${index}`, align: HorizontalAlign.Center } | ||
| 314 | - }) | ||
| 315 | - .id(`e_row3_${index}`) | ||
| 316 | - } | ||
| 317 | - } | ||
| 318 | - .id(`e_icon_${index}`)*/ | ||
| 319 | - } else { | ||
| 320 | - RelativeContainer() { | ||
| 321 | - Row() { | ||
| 322 | - Image(item.icon) | ||
| 323 | - .width(24) | ||
| 324 | - .height(24) | ||
| 325 | - .aspectRatio(1) | ||
| 326 | - .interpolation(ImageInterpolation.High) | ||
| 327 | - .onClick((event: ClickEvent) => { | ||
| 328 | - ToastUtils.showToast('分享为公共方法,待开发', 1000); | ||
| 329 | - }) | ||
| 330 | - } | ||
| 331 | - .alignRules({ | ||
| 332 | - center: { anchor: '__container__', align: VerticalAlign.Center }, | ||
| 333 | - middle: { anchor: '__container__', align: HorizontalAlign.Center } | ||
| 334 | - }) | ||
| 335 | - .id(`e_row1_${index}`) | ||
| 336 | - } | ||
| 337 | - .id(`e_icon_${index}`) | 120 | + if (this.publishCommentModel?.targetId) { |
| 121 | + CommentTabComponent({ publishCommentModel: this.publishCommentModel }) | ||
| 338 | } | 122 | } |
| 123 | + } | ||
| 124 | + .flexGrow(1) | ||
| 339 | 125 | ||
| 126 | + Column() { | ||
| 127 | + if (this.publishCommentModel?.targetId) { | ||
| 128 | + CommentIconComponent({ publishCommentModel: this.publishCommentModel }) | ||
| 129 | + } | ||
| 340 | } | 130 | } |
| 341 | - .margin(5) | ||
| 342 | - .alignItems(HorizontalAlign.Center) | ||
| 343 | - .hoverEffect(HoverEffect.Scale) | 131 | + .width(46) |
| 344 | } | 132 | } |
| 345 | 133 | ||
| 346 | /** | 134 | /** |
| 347 | - * 输入法 | 135 | + * 点赞组件 |
| 348 | */ | 136 | */ |
| 137 | + @Builder | ||
| 138 | + builderLike() { | ||
| 139 | + Column() { | ||
| 140 | + if (this.likeBean?.contentId) { | ||
| 141 | + LikeComponent({ | ||
| 142 | + data: this.likeBean | ||
| 143 | + }) | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | + .width(42) | ||
| 147 | + } | ||
| 349 | 148 | ||
| 350 | - private buildInputMethod() { | ||
| 351 | - let im = inputMethod.getCurrentInputMethod(); | ||
| 352 | - let prop: InputMethodProperty = { | ||
| 353 | - packageName: im.packageName, | ||
| 354 | - methodId: im.methodId, | ||
| 355 | - name: im.name, | ||
| 356 | - id: im.id, | ||
| 357 | - extra: {} | 149 | + /** |
| 150 | + * 收藏组件 | ||
| 151 | + */ | ||
| 152 | + @Builder | ||
| 153 | + builderCollect() { | ||
| 154 | + Column() { | ||
| 155 | + Stack({ alignContent: Alignment.TopEnd }) { | ||
| 156 | + Image(this.newsStatusOfUser?.collectStatus == 1 ? $r('app.media.ic_collect_check') : $r('app.media.iv_live_comment_collect_un')) | ||
| 157 | + .width(24) | ||
| 158 | + .height(24) | ||
| 159 | + .interpolation(ImageInterpolation.High) | ||
| 160 | + /*Text(`${this.interactData?.collectNum}`) | ||
| 161 | + .fontSize(8) | ||
| 162 | + .fontColor(Color.White) | ||
| 163 | + .height(12) | ||
| 164 | + .margin({ left: 6 }) | ||
| 165 | + .backgroundImage($r('app.media.comment_icon_number')) | ||
| 166 | + .offset({ | ||
| 167 | + x: 12 | ||
| 168 | + })*/ | ||
| 169 | + } | ||
| 170 | + .onClick(() => { | ||
| 171 | + this.toggleCollectStatus() | ||
| 172 | + }) | ||
| 358 | } | 173 | } |
| 359 | - try{ | ||
| 360 | - inputMethod.switchInputMethod(prop, (err, result) => { | ||
| 361 | - if (err !== undefined) { | ||
| 362 | - console.error('Failed to switchInputMethod: ' + JSON.stringify(err)); | ||
| 363 | - return; | ||
| 364 | - } | ||
| 365 | - if (result) { | ||
| 366 | - console.info('Succeeded in switching inputmethod.'); | ||
| 367 | - } else { | ||
| 368 | - console.error('Failed to switchInputMethod.'); | ||
| 369 | - } | ||
| 370 | - }); | ||
| 371 | - } catch(err) { | ||
| 372 | - console.error('Failed to switchInputMethod: ' + JSON.stringify(err)); | 174 | + .width(42) |
| 175 | + } | ||
| 176 | + | ||
| 177 | + /** | ||
| 178 | + * 分享组件 | ||
| 179 | + */ | ||
| 180 | + @Builder | ||
| 181 | + builderShare() { | ||
| 182 | + Column() { | ||
| 183 | + Image($r('app.media.iv_live_comment_share')) | ||
| 184 | + .width(24) | ||
| 185 | + .height(24) | ||
| 186 | + .aspectRatio(1) | ||
| 187 | + .interpolation(ImageInterpolation.High) | ||
| 188 | + .onClick((event: ClickEvent) => { | ||
| 189 | + ToastUtils.showToast('分享为公共方法,待开发', 1000); | ||
| 190 | + }) | ||
| 373 | } | 191 | } |
| 192 | + .width(42) | ||
| 374 | } | 193 | } |
| 375 | 194 | ||
| 376 | - // 已登录->查询用户对作品点赞、收藏状态 | 195 | + // 已登录->查询用户对作品收藏状态 |
| 377 | private async getInteractDataStatus() { | 196 | private async getInteractDataStatus() { |
| 378 | try { | 197 | try { |
| 379 | const params: batchLikeAndCollectParams = { | 198 | const params: batchLikeAndCollectParams = { |
| @@ -384,44 +203,20 @@ export struct OperRowListView { | @@ -384,44 +203,20 @@ export struct OperRowListView { | ||
| 384 | } | 203 | } |
| 385 | ] | 204 | ] |
| 386 | } | 205 | } |
| 387 | - console.error(TAG, JSON.stringify(this.contentDetailData)) | 206 | + // console.info(TAG, '查询用户对作品收藏11', JSON.stringify(params)) |
| 388 | let data = await MultiPictureDetailViewModel.getInteractDataStatus(params) | 207 | let data = await MultiPictureDetailViewModel.getInteractDataStatus(params) |
| 389 | - console.error(TAG, '查询用户对作品点赞、收藏状态', JSON.stringify(data)) | 208 | + // console.info(TAG, '查询用户对作品收藏22', JSON.stringify(data)) |
| 390 | this.newsStatusOfUser = data[0]; | 209 | this.newsStatusOfUser = data[0]; |
| 391 | - Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`) | ||
| 392 | } catch (exception) { | 210 | } catch (exception) { |
| 393 | - console.error(TAG, JSON.stringify(exception)) | 211 | + // console.error(TAG, JSON.stringify(exception)) |
| 394 | } | 212 | } |
| 395 | } | 213 | } |
| 396 | 214 | ||
| 397 | /** | 215 | /** |
| 398 | - * 点赞、取消点赞 | ||
| 399 | - */ | ||
| 400 | - async toggleLikeStatus() { | ||
| 401 | - // 未登录,跳转登录 | ||
| 402 | - const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | ||
| 403 | - if (!user_id) { | ||
| 404 | - WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 405 | - return | ||
| 406 | - } | ||
| 407 | - const params: postExecuteLikeParams = { | ||
| 408 | - status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1', | ||
| 409 | - contentId: this.contentDetailData?.newsId + '', | ||
| 410 | - contentType: this.contentDetailData?.newsType + '', | ||
| 411 | - } | ||
| 412 | - PageRepository.postExecuteLike(params).then(res => { | ||
| 413 | - console.log(TAG, '点赞、取消点赞', 'toggleLikeStatus==',) | ||
| 414 | - if (this.newsStatusOfUser) { | ||
| 415 | - this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1' | ||
| 416 | - this.queryContentInteractCount() | ||
| 417 | - } | ||
| 418 | - | ||
| 419 | - }) | ||
| 420 | - } | ||
| 421 | - /** | ||
| 422 | * 收藏、取消收藏 | 216 | * 收藏、取消收藏 |
| 423 | */ | 217 | */ |
| 424 | async toggleCollectStatus() { | 218 | async toggleCollectStatus() { |
| 219 | + // console.log(TAG, '收藏--') | ||
| 425 | // 未登录,跳转登录 | 220 | // 未登录,跳转登录 |
| 426 | const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | 221 | const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') |
| 427 | if (!user_id) { | 222 | if (!user_id) { |
| @@ -437,7 +232,7 @@ export struct OperRowListView { | @@ -437,7 +232,7 @@ export struct OperRowListView { | ||
| 437 | 232 | ||
| 438 | } | 233 | } |
| 439 | PageRepository.postExecuteCollectRecord(params).then(res => { | 234 | PageRepository.postExecuteCollectRecord(params).then(res => { |
| 440 | - console.log(TAG, '收藏、取消收藏','toggleLikeStatus==',) | 235 | + // console.log(TAG, '收藏、取消收藏', 'toggleLikeStatus==',) |
| 441 | if (this.newsStatusOfUser) { | 236 | if (this.newsStatusOfUser) { |
| 442 | this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1 | 237 | this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1 |
| 443 | this.queryContentInteractCount() | 238 | this.queryContentInteractCount() |
| @@ -450,7 +245,7 @@ export struct OperRowListView { | @@ -450,7 +245,7 @@ export struct OperRowListView { | ||
| 450 | * 查询点赞、收藏数量 | 245 | * 查询点赞、收藏数量 |
| 451 | */ | 246 | */ |
| 452 | queryContentInteractCount() { | 247 | queryContentInteractCount() { |
| 453 | - console.error(TAG,'contentDetailData2222', JSON.stringify(this.contentDetailData)) | 248 | + // console.error(TAG, 'contentDetailData2222', JSON.stringify(this.contentDetailData)) |
| 454 | const params: contentListParams = { | 249 | const params: contentListParams = { |
| 455 | contentList: [{ | 250 | contentList: [{ |
| 456 | contentId: this.contentDetailData?.newsId + '', | 251 | contentId: this.contentDetailData?.newsId + '', |
| @@ -462,8 +257,10 @@ export struct OperRowListView { | @@ -462,8 +257,10 @@ export struct OperRowListView { | ||
| 462 | this.interactData.likeNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.likeNum) | 257 | this.interactData.likeNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.likeNum) |
| 463 | this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum) | 258 | this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum) |
| 464 | this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum) | 259 | this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum) |
| 260 | + // 评论组件需要数据 | ||
| 261 | + this.publishCommentModel.totalCommentNumer = this.interactData.commentNum + '' || '0' | ||
| 465 | } | 262 | } |
| 466 | - console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res)) | 263 | + // console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res)) |
| 467 | console.log(TAG, 'this.interactData', JSON.stringify(this.interactData)) | 264 | console.log(TAG, 'this.interactData', JSON.stringify(this.interactData)) |
| 468 | }) | 265 | }) |
| 469 | } | 266 | } |
-
Please register or login to post a comment