zhenghy
@@ -47,6 +47,10 @@ export class HttpUrlUtils { @@ -47,6 +47,10 @@ export class HttpUrlUtils {
47 */ 47 */
48 static readonly INTERACT_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/content/interactData"; 48 static readonly INTERACT_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/content/interactData";
49 /** 49 /**
  50 + * 查询各类型内容动态数据接口V2:其他场景的均调用V2---api缓存1-2s
  51 + */
  52 + static readonly INTERACT_V2_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/v2/content/interactData";
  53 + /**
50 * 查询视频频道推荐楼层 54 * 查询视频频道推荐楼层
51 */ 55 */
52 static readonly DISPLAY_REC_COMPINFO: string = "/api/rmrb-bff-display-zh/display/zh/c/rec/compInfo"; 56 static readonly DISPLAY_REC_COMPINFO: string = "/api/rmrb-bff-display-zh/display/zh/c/rec/compInfo";
1 -import { AccountManagerUtils, Logger, DateTimeUtils, SPHelper } from 'wdKit'; 1 +import { AccountManagerUtils, Logger, DateTimeUtils, SPHelper, NumberFormatterUtils } from 'wdKit';
2 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; 2 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
3 import { ContentDetailDTO,postBatchAttentionStatusParams, 3 import { ContentDetailDTO,postBatchAttentionStatusParams,
4 PhotoListBean, 4 PhotoListBean,
5 ContentDTO, 5 ContentDTO,
6 - RmhInfoDTO, } from 'wdBean'; 6 + batchLikeAndCollectResult,
  7 + RmhInfoDTO,
  8 + InteractDataDTO, } from 'wdBean';
7 import media from '@ohos.multimedia.media'; 9 import media from '@ohos.multimedia.media';
8 import { OperRowListView } from './view/OperRowListView'; 10 import { OperRowListView } from './view/OperRowListView';
9 import { WDPlayerController } from 'wdPlayer/Index'; 11 import { WDPlayerController } from 'wdPlayer/Index';
10 import { 12 import {
11 batchLikeAndCollectParams, 13 batchLikeAndCollectParams,
12 - batchLikeAndCollectResult,  
13 ContentDetailRequest, 14 ContentDetailRequest,
14 contentListParams, 15 contentListParams,
15 postExecuteCollectRecordParams, 16 postExecuteCollectRecordParams,
@@ -32,25 +33,23 @@ export struct DynamicDetailComponent { @@ -32,25 +33,23 @@ export struct DynamicDetailComponent {
32 private relId: string = '' 33 private relId: string = ''
33 private contentId: string = '' 34 private contentId: string = ''
34 private relType: string = '' 35 private relType: string = ''
35 - //出参 fixme 模拟数据用json转换 36 +
  37 + //出参
36 @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO 38 @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
37 - //变量 39 + //UI
38 scroller: Scroller = new Scroller(); 40 scroller: Scroller = new Scroller();
  41 +
  42 + //点赞 收藏 评论 数量
  43 + @State interactDataDTO: InteractDataDTO = {} as InteractDataDTO
39 /** 44 /**
40 - * 默认未关注 点击去关注 45 + * 关注状态:默认未关注 点击去关注
41 */ 46 */
42 @State followStatus: String = '0'; 47 @State followStatus: String = '0';
43 - @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态  
44 48
  49 + @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined// 点赞、收藏状态
45 //跳转 50 //跳转
46 private mJumpInfo: ContentDTO = {} as ContentDTO; 51 private mJumpInfo: ContentDTO = {} as ContentDTO;
47 52
48 - // 获取当前所有的display对象  
49 - promise: Promise<Array<display.Display>> = display.getAllDisplays()  
50 -  
51 - // 屏幕宽度(单位px)  
52 - @State screenWidth: number = 0;  
53 -  
54 async aboutToAppear() { 53 async aboutToAppear() {
55 await this.getContentDetailData() 54 await this.getContentDetailData()
56 } 55 }
@@ -327,17 +326,30 @@ export struct DynamicDetailComponent { @@ -327,17 +326,30 @@ export struct DynamicDetailComponent {
327 .margin({ top: $r('app.float.margin_24')}) 326 .margin({ top: $r('app.float.margin_24')})
328 //点赞 327 //点赞
329 Row(){ 328 Row(){
330 - Image($r('app.media.icon_like_selected_redheart')) 329 + Blank().layoutWeight(1)
  330 + Image(this.newsStatusOfUser?.likeStatus == '1'?
  331 + $r('app.media.icon_like_selected_redheart')
  332 + :$r('app.media.icon_like_unselect_grey_redheart'))
331 .width($r('app.float.margin_24')) 333 .width($r('app.float.margin_24'))
332 .height($r('app.float.margin_24')) 334 .height($r('app.float.margin_24'))
333 .objectFit(ImageFit.Cover) 335 .objectFit(ImageFit.Cover)
334 - Text("2.6万") 336 + Text(NumberFormatterUtils.formatNumberWithWan(this.interactDataDTO?.likeNum))
335 .fontColor($r('app.color.color_999999')) 337 .fontColor($r('app.color.color_999999'))
336 .fontSize($r('app.float.font_size_16')) 338 .fontSize($r('app.float.font_size_16'))
337 .lineHeight($r('app.float.margin_20')) 339 .lineHeight($r('app.float.margin_20'))
338 .margin({ left: $r('app.float.margin_2')}) 340 .margin({ left: $r('app.float.margin_2')})
  341 + Blank().layoutWeight(1)
339 } 342 }
  343 + .width($r('app.float.margin_154'))
  344 + .height($r('app.float.margin_40'))
340 .margin({top:$r('app.float.margin_16')}) 345 .margin({top:$r('app.float.margin_16')})
  346 + .borderWidth($r('app.float.margin_1'))
  347 + .borderColor($r('app.color.color_EDEDED'))
  348 + .borderRadius($r('app.float.margin_20'))
  349 + .onClick((event: ClickEvent) => {
  350 + //点赞操作
  351 + this.toggleLikeStatus()
  352 + })
341 Blank().layoutWeight(1) 353 Blank().layoutWeight(1)
342 //fixme 评论组件 354 //fixme 评论组件
343 } 355 }
@@ -405,27 +417,30 @@ export struct DynamicDetailComponent { @@ -405,27 +417,30 @@ export struct DynamicDetailComponent {
405 this.getBatchAttentionStatus() 417 this.getBatchAttentionStatus()
406 this.getInteractDataStatus() 418 this.getInteractDataStatus()
407 this.makeJumpInfo() 419 this.makeJumpInfo()
  420 + this.interactDataV2()
408 } 421 }
409 422
410 - // 查询当前登录用户点赞状态 423 +
  424 + private async interactDataV2() {
  425 + this.interactDataDTO = await MultiPictureDetailViewModel.interactDataV2(
  426 + this.contentDetailData?.newsId+'',this.contentDetailData?.newsType+'',this.contentDetailData.reLInfo == null ?'':this.contentDetailData.reLInfo?.relId,this.contentDetailData.rmhPlatform)
  427 + }
  428 +
  429 + // 已登录->查询用户对作品点赞、收藏状态
411 private async getInteractDataStatus() { 430 private async getInteractDataStatus() {
412 - //未登录  
413 - if(!AccountManagerUtils.isLoginSync() || this.contentDetailData?.openLikes != 1){  
414 - return  
415 - }  
416 try { 431 try {
417 const params: batchLikeAndCollectParams = { 432 const params: batchLikeAndCollectParams = {
418 contentList: [ 433 contentList: [
419 { 434 {
420 - contentId: this.contentDetailData?.newsId + '',  
421 - contentType: this.contentDetailData?.newsType + '', 435 + contentId: this.contentDetailData[0]?.newsId + '',
  436 + contentType: this.contentDetailData[0]?.newsType + '',
422 } 437 }
423 ] 438 ]
424 } 439 }
425 console.error(TAG, JSON.stringify(this.contentDetailData)) 440 console.error(TAG, JSON.stringify(this.contentDetailData))
426 let data = await MultiPictureDetailViewModel.getInteractDataStatus(params) 441 let data = await MultiPictureDetailViewModel.getInteractDataStatus(params)
427 console.error(TAG, '查询用户对作品点赞、收藏状态', JSON.stringify(data)) 442 console.error(TAG, '查询用户对作品点赞、收藏状态', JSON.stringify(data))
428 - // this.newsStatusOfUser = data[0]; 443 + this.newsStatusOfUser = data[0];
429 Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`) 444 Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`)
430 } catch (exception) { 445 } catch (exception) {
431 console.error(TAG, JSON.stringify(exception)) 446 console.error(TAG, JSON.stringify(exception))
@@ -524,6 +539,37 @@ export struct DynamicDetailComponent { @@ -524,6 +539,37 @@ export struct DynamicDetailComponent {
524 } 539 }
525 }) 540 })
526 } 541 }
  542 +
  543 + /**
  544 + * 点赞、取消点赞
  545 + */
  546 + async toggleLikeStatus() {
  547 + // 未登录,跳转登录
  548 + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
  549 + if (!user_id) {
  550 + WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
  551 + return
  552 + }
  553 + const params: postExecuteLikeParams = {
  554 + status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1',
  555 + contentId: this.contentDetailData?.newsId + '',
  556 + contentType: this.contentDetailData?.newsType + '',
  557 + }
  558 + ContentDetailRequest.postExecuteLike(params).then(res => {
  559 +
  560 + if (this.newsStatusOfUser) {
  561 + this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1'
  562 + if (this.newsStatusOfUser.likeStatus === '1') {
  563 + this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) + 1
  564 + } else {
  565 + this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) - 1
  566 + }
  567 + console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactDataDTO?.likeNum)
  568 + // this.queryContentInteractCount()
  569 + }
  570 +
  571 + })
  572 + }
527 } 573 }
528 574
529 interface radiusType { 575 interface radiusType {
@@ -28,7 +28,7 @@ export struct Card5Component { @@ -28,7 +28,7 @@ export struct Card5Component {
28 .width(CommonConstants.FULL_WIDTH) 28 .width(CommonConstants.FULL_WIDTH)
29 .autoResize(true) 29 .autoResize(true)
30 .borderRadius($r('app.float.image_border_radius')) 30 .borderRadius($r('app.float.image_border_radius'))
31 - if (this.titleShowPolicy === 1 && this.contentDTO.newsTitle) { 31 + if ((this.titleShowPolicy === 1 || this.contentDTO.titleShow === 1) && this.contentDTO.newsTitle) {
32 Row() 32 Row()
33 .width(CommonConstants.FULL_WIDTH) 33 .width(CommonConstants.FULL_WIDTH)
34 .height(59) 34 .height(59)
@@ -78,8 +78,13 @@ export struct ZhSingleRow02 { @@ -78,8 +78,13 @@ export struct ZhSingleRow02 {
78 right: $r('app.float.card_comp_pagePadding_lf'), 78 right: $r('app.float.card_comp_pagePadding_lf'),
79 }) 79 })
80 .onClick(() => { 80 .onClick(() => {
81 - let params = {'index': "1"} as Record<string, string>;  
82 - WDRouterRule.jumpWithPage(WDRouterPage.followListPage, params) 81 + if (this.compDTO?.objectType === '11') {
  82 + ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string)
  83 + } else if (this.compDTO?.objectType === '5') {
  84 + ProcessUtils._gotoSpecialTopic(this.compDTO.linkUrl)
  85 + } else if (this.compDTO?.objectType === '6') {
  86 + ProcessUtils._gotoDefaultWeb(this.compDTO.linkUrl)
  87 + }
83 }) 88 })
84 } 89 }
85 .justifyContent(FlexAlign.SpaceBetween) 90 .justifyContent(FlexAlign.SpaceBetween)
@@ -137,7 +137,7 @@ struct EditUserInfoPage { @@ -137,7 +137,7 @@ struct EditUserInfoPage {
137 TextPickerDialog.show({ 137 TextPickerDialog.show({
138 range:['男','女'], 138 range:['男','女'],
139 canLoop:false, 139 canLoop:false,
140 - selected:0, 140 + selected:this.currentUserInfo.userExtend.sex === 0?1:0,
141 onAccept:(value:TextPickerResult) => { 141 onAccept:(value:TextPickerResult) => {
142 this.currentUserInfo.userExtend.sex = value.index == 0?1:0; 142 this.currentUserInfo.userExtend.sex = value.index == 0?1:0;
143 this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_sex 143 this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_sex
@@ -52,22 +52,34 @@ struct EditUserIntroductionPage { @@ -52,22 +52,34 @@ struct EditUserIntroductionPage {
52 .margin(30) 52 .margin(30)
53 .onClick(()=>{ 53 .onClick(()=>{
54 this.updateEditModel() 54 this.updateEditModel()
55 - let params: editModelParams = {  
56 - introduction: this.introduction  
57 - }  
58 - router.back({  
59 - url:'',  
60 - params:params  
61 - })  
62 }) 55 })
63 } 56 }
64 } 57 }
65 58
66 59
67 updateEditModel(){ 60 updateEditModel(){
  61 + if (this.params.editContent === this.introduction) {
  62 + this.goBack()
  63 + return
  64 + }
  65 +
68 let currentUserInfo:editModel = new editModel() 66 let currentUserInfo:editModel = new editModel()
69 currentUserInfo.userExtend.introduction = this.introduction 67 currentUserInfo.userExtend.introduction = this.introduction
70 currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_intro 68 currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_intro
71 - EditInfoViewModel.updateUserInfo(currentUserInfo) 69 + EditInfoViewModel.updateUserInfo(currentUserInfo).then(()=>{
  70 + this.goBack()
  71 + }).catch(()=>{
  72 + this.goBack()
  73 + })
  74 + }
  75 +
  76 + goBack(){
  77 + let params: editModelParams = {
  78 + introduction: this.introduction
  79 + }
  80 + router.back({
  81 + url:'',
  82 + params:params
  83 + })
72 } 84 }
73 } 85 }
@@ -60,17 +60,28 @@ struct EditUserNikeNamePage { @@ -60,17 +60,28 @@ struct EditUserNikeNamePage {
60 } 60 }
61 61
62 async updateEditModel(){ 62 async updateEditModel(){
  63 + if (this.params.editContent === this.nikeName) {
  64 + this.goBack()
  65 + return
  66 + }
  67 +
63 let currentUserInfo:editModel = new editModel() 68 let currentUserInfo:editModel = new editModel()
64 currentUserInfo.userName = await encryptMessage(this.nikeName); 69 currentUserInfo.userName = await encryptMessage(this.nikeName);
65 currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_nickname 70 currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_nickname
66 EditInfoViewModel.updateUserInfo(currentUserInfo).then(()=>{ 71 EditInfoViewModel.updateUserInfo(currentUserInfo).then(()=>{
67 - let params: editModelParams = {  
68 - userName: this.nikeName  
69 - }  
70 - router.back({  
71 - url:'',  
72 - params:params  
73 - }) 72 + this.goBack()
  73 + }).catch(()=>{
  74 + this.goBack()
74 }) 75 })
75 } 76 }
  77 +
  78 + goBack(){
  79 + let params: editModelParams = {
  80 + userName: this.nikeName
  81 + }
  82 + router.back({
  83 + url:'',
  84 + params:params
  85 + })
  86 + }
76 } 87 }
1 import HashMap from '@ohos.util.HashMap'; 1 import HashMap from '@ohos.util.HashMap';
2 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; 2 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
3 -import { DateTimeUtils, Logger } from 'wdKit'; 3 +import { DateTimeUtils, Logger, StringUtils } from 'wdKit';
4 import { 4 import {
5 batchLikeAndCollectResult, 5 batchLikeAndCollectResult,
6 CompInfoBean, 6 CompInfoBean,
@@ -128,6 +128,19 @@ export class PageRepository { @@ -128,6 +128,19 @@ export class PageRepository {
128 return url; 128 return url;
129 } 129 }
130 130
  131 + static getInteractDataV2Url(contentId: string, contentType: string, contentRelId: string,rmhPlatform:number) {
  132 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_V2_DATA_PATH;
  133 + url = url + "?contentId=" + contentId
  134 + + "&contentType=" + contentType
  135 + if(!StringUtils.isEmpty(contentRelId)){
  136 + url = url + "&contentRelId=" + contentRelId;
  137 + }
  138 + url = url + "&rmhPlatform=" + rmhPlatform;
  139 + url = url + "&detail=" + '1';
  140 + Logger.info(TAG, "getInteractDataV2Url url = " + url)
  141 + return url;
  142 + }
  143 +
131 static getInteractDataUrl() { 144 static getInteractDataUrl() {
132 let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH; 145 let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH;
133 Logger.info(TAG, "getInteractDataUrl url = " + url) 146 Logger.info(TAG, "getInteractDataUrl url = " + url)
@@ -253,6 +266,12 @@ export class PageRepository { @@ -253,6 +266,12 @@ export class PageRepository {
253 return WDHttp.get<ResponseDTO<ContentDetailDTO[]>>(url, headers) 266 return WDHttp.get<ResponseDTO<ContentDetailDTO[]>>(url, headers)
254 }; 267 };
255 268
  269 + static fetchInteractDataV2(contentId: string, contentType: string, contentRelId: string,rmhPlatform:number) {
  270 + let url = PageRepository.getInteractDataV2Url(contentId, contentType, contentRelId,rmhPlatform)
  271 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  272 + return WDHttp.get<ResponseDTO<InteractDataDTO>>(url, headers)
  273 + };
  274 +
256 static fetchInteractData(param: object) { 275 static fetchInteractData(param: object) {
257 let url = PageRepository.getInteractDataUrl() 276 let url = PageRepository.getInteractDataUrl()
258 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); 277 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
@@ -5,7 +5,8 @@ import { ContentDetailDTO, @@ -5,7 +5,8 @@ import { ContentDetailDTO,
5 batchLikeAndCollectResult, 5 batchLikeAndCollectResult,
6 postBatchAttentionStatusParams, 6 postBatchAttentionStatusParams,
7 postBatchAttentionStatusResult, 7 postBatchAttentionStatusResult,
8 - postInteractBrowsOperateParams 8 + postInteractBrowsOperateParams,
  9 + InteractDataDTO
9 } from 'wdBean'; 10 } from 'wdBean';
10 import { PageRepository } from '../repository/PageRepository'; 11 import { PageRepository } from '../repository/PageRepository';
11 12
@@ -106,4 +107,28 @@ export class MultiPictureDetailViewModel { @@ -106,4 +107,28 @@ export class MultiPictureDetailViewModel {
106 }) 107 })
107 } 108 }
108 109
  110 + //查询点赞数量
  111 + static async interactDataV2(contentId: string, contentType: string, contentRelId: string,rmhPlatform:number): Promise<InteractDataDTO> {
  112 + return new Promise<InteractDataDTO>((success, error) => {
  113 + Logger.info(TAG, `interactDataV2 start`);
  114 + PageRepository.fetchInteractDataV2(contentId, contentType, contentRelId,rmhPlatform).then((resDTO: ResponseDTO<InteractDataDTO>) => {
  115 + if (!resDTO || !resDTO.data) {
  116 + Logger.error(TAG, 'interactDataV2 is empty');
  117 + error('resDTO is empty');
  118 + return
  119 + }
  120 + if (resDTO.code != 0) {
  121 + Logger.error(TAG, `interactDataV2 then code:${resDTO.code}, message:${resDTO.message}`);
  122 + error('resDTO Response Code is failure');
  123 + return
  124 + }
  125 + Logger.info(TAG, "interactDataV2 then,navResDTO.timestamp:" + resDTO.timestamp);
  126 + success(resDTO.data);
  127 + }).catch((err: Error) => {
  128 + Logger.error(TAG, `interactDataV2 catch, error.name : ${err.name}, error.message:${err.message}`);
  129 + error(err);
  130 + })
  131 + })
  132 + }
  133 +
109 } 134 }
@@ -117,6 +117,10 @@ @@ -117,6 +117,10 @@
117 "value": "28vp" 117 "value": "28vp"
118 }, 118 },
119 { 119 {
  120 + "name": "margin_40",
  121 + "value": "40vp"
  122 + },
  123 + {
120 "name": "margin_48", 124 "name": "margin_48",
121 "value": "48vp" 125 "value": "48vp"
122 }, 126 },
@@ -129,6 +133,10 @@ @@ -129,6 +133,10 @@
129 "value": "60vp" 133 "value": "60vp"
130 }, 134 },
131 { 135 {
  136 + "name": "margin_154",
  137 + "value": "154vp"
  138 + },
  139 + {
132 "name": "single_row_03_img_height", 140 "name": "single_row_03_img_height",
133 "value": "88vp" 141 "value": "88vp"
134 }, 142 },
@@ -185,6 +193,10 @@ @@ -185,6 +193,10 @@
185 "value": "24vp" 193 "value": "24vp"
186 }, 194 },
187 { 195 {
  196 + "name": "margin_1",
  197 + "value": "1vp"
  198 + },
  199 + {
188 "name": "margin_6", 200 "name": "margin_6",
189 "value": "6vp" 201 "value": "6vp"
190 }, 202 },