yumaochao

Merge remote-tracking branch 'origin/main'

1 -import { Logger } from 'wdKit'; 1 +import { AccountManagerUtils, Logger } from 'wdKit';
2 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; 2 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
3 -import { ContentDetailDTO } from 'wdBean'; 3 +import { ContentDetailDTO,batchLikeAndCollectResult,batchLikeAndCollectParams,postBatchAttentionStatusParams,
  4 + PhotoListBean,
  5 + ContentDTO, } from 'wdBean';
4 import media from '@ohos.multimedia.media'; 6 import media from '@ohos.multimedia.media';
5 import { OperRowListView } from './view/OperRowListView'; 7 import { OperRowListView } from './view/OperRowListView';
6 import { WDPlayerController } from 'wdPlayer/Index'; 8 import { WDPlayerController } from 'wdPlayer/Index';
  9 +import { ContentConstants } from '../constants/ContentConstants';
  10 +import { ProcessUtils } from '../utils/ProcessUtils';
7 11
8 const TAG = 'DynamicDetailComponent' 12 const TAG = 'DynamicDetailComponent'
9 @Preview 13 @Preview
@@ -19,8 +23,11 @@ export struct DynamicDetailComponent { @@ -19,8 +23,11 @@ export struct DynamicDetailComponent {
19 /** 23 /**
20 * 默认未关注 点击去关注 24 * 默认未关注 点击去关注
21 */ 25 */
22 - private followStatus: boolean = false; 26 + private followStatus: String = '0';
  27 + @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
23 28
  29 + //跳转
  30 + private mJumpInfo: ContentDTO = {} as ContentDTO;
24 31
25 async aboutToAppear() { 32 async aboutToAppear() {
26 await this.getContentDetailData() 33 await this.getContentDetailData()
@@ -85,7 +92,7 @@ export struct DynamicDetailComponent { @@ -85,7 +92,7 @@ export struct DynamicDetailComponent {
85 .fontWeight(FontWeight.Medium) 92 .fontWeight(FontWeight.Medium)
86 .margin({ left: $r('app.float.margin_5') }) 93 .margin({ left: $r('app.float.margin_5') })
87 } 94 }
88 - if (!this.followStatus) { 95 + if (this.followStatus == '0') {
89 Text('关注') 96 Text('关注')
90 .width(60) 97 .width(60)
91 .height($r('app.float.margin_48')) 98 .height($r('app.float.margin_48'))
@@ -121,6 +128,31 @@ export struct DynamicDetailComponent { @@ -121,6 +128,31 @@ export struct DynamicDetailComponent {
121 .margin({ top: $r('app.float.margin_6') 128 .margin({ top: $r('app.float.margin_6')
122 ,left: $r('app.float.margin_16') 129 ,left: $r('app.float.margin_16')
123 ,right: $r('app.float.margin_16') }) 130 ,right: $r('app.float.margin_16') })
  131 + if(this.contentDetailData.photoList!= null && this.contentDetailData.photoList.length>0){
  132 + //附件内容:图片/视频
  133 + if(this.contentDetailData.newsType+"" == ContentConstants.TYPE_FOURTEEN){
  134 + GridRow({
  135 + columns: { sm: this.contentDetailData.photoList.length
  136 + , md: this.contentDetailData.photoList.length == 1?1:
  137 + this.contentDetailData.photoList.length == 4?2:
  138 + 3 },
  139 + breakpoints: { value: ['320vp', '520vp', '840vp'] }
  140 + }) {
  141 + ForEach(this.contentDetailData.photoList, (item: PhotoListBean, index: number) => {
  142 + GridCol() {
  143 + this.buildItemCard(this.contentDetailData.photoList[index],this.contentDetailData.photoList.length, index);
  144 + }
  145 + })
  146 + }
  147 + }else{
  148 + //附件内容:视频,只有一个
  149 + ForEach(this.contentDetailData.photoList, (item: PhotoListBean, index: number) => {
  150 + GridCol() {
  151 + this.buildItemCard(this.contentDetailData.photoList[index],this.contentDetailData.photoList.length, index);
  152 + }
  153 + })
  154 + }
  155 + }
124 //特别声明 156 //特别声明
125 Text("特别声明:本文为人民日报新媒体平台“人民号”作者上传并发布,仅代表作者观点。人民日报仅提供信息发布平台。") 157 Text("特别声明:本文为人民日报新媒体平台“人民号”作者上传并发布,仅代表作者观点。人民日报仅提供信息发布平台。")
126 .fontColor($r('app.color.color_CCCCCC')) 158 .fontColor($r('app.color.color_CCCCCC'))
@@ -160,17 +192,253 @@ export struct DynamicDetailComponent { @@ -160,17 +192,253 @@ export struct DynamicDetailComponent {
160 .margin({ left: $r('app.float.margin_2')}) 192 .margin({ left: $r('app.float.margin_2')})
161 } 193 }
162 //评论组件/底部组件 194 //评论组件/底部组件
  195 +
163 } 196 }
164 } 197 }
165 .backgroundColor('#FFFFFFFF') 198 .backgroundColor('#FFFFFFFF')
166 } 199 }
  200 + /**
  201 + * 请求(动态)详情页数据
  202 + * */
167 private async getContentDetailData() { 203 private async getContentDetailData() {
168 try { 204 try {
169 let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) 205 let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType)
170 this.contentDetailData = data[0]; 206 this.contentDetailData = data[0];
  207 + this.makeJumpInfo
171 console.log('动态详情',JSON.stringify(this.contentDetailData)) 208 console.log('动态详情',JSON.stringify(this.contentDetailData))
172 } catch (exception) { 209 } catch (exception) {
173 console.log('请求失败',JSON.stringify(exception)) 210 console.log('请求失败',JSON.stringify(exception))
174 } 211 }
  212 + this.getBatchAttentionStatus
  213 + this.getInteractDataStatus
  214 + }
  215 +
  216 + // 查询当前登录用户点赞状态
  217 + private async getInteractDataStatus() {
  218 + //未登录
  219 + if(!AccountManagerUtils.isLoginSync() || this.contentDetailData?.openLikes != 1){
  220 + return
  221 + }
  222 + try {
  223 + const params: batchLikeAndCollectParams = {
  224 + contentList: [
  225 + {
  226 + contentId: this.contentDetailData?.newsId + '',
  227 + contentType: this.contentDetailData?.newsType + '',
  228 + }
  229 + ]
  230 + }
  231 + console.error(TAG, JSON.stringify(this.contentDetailData))
  232 + let data = await MultiPictureDetailViewModel.getInteractDataStatus(params)
  233 + console.error(TAG, '查询用户对作品点赞、收藏状态', JSON.stringify(data))
  234 + this.newsStatusOfUser = data[0];
  235 + Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`)
  236 + } catch (exception) {
  237 + console.error(TAG, JSON.stringify(exception))
  238 + }
  239 + }
  240 +
  241 + /**
  242 + * 查询当前登录用户是否关注作品号主
  243 + * */
  244 + private async getBatchAttentionStatus() {
  245 + try {
  246 + const params: postBatchAttentionStatusParams = {
  247 + creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }]
  248 + }
  249 + let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params)
  250 + this.followStatus = data[0]?.status;
  251 + Logger.info(TAG, `followStatus:${JSON.stringify(this.followStatus)}`)
  252 + } catch (exception) {
  253 +
  254 + }
  255 + }
  256 + @Builder
  257 + setItemImageStyle(picPath: string,topLeft: number,topRight: number,bottomLeft: number,bottomRight: number){
  258 + //四角圆角
  259 + Image(picPath)
  260 + .width(44).aspectRatio(1 / 1).margin(16).borderRadius({topLeft: topLeft, topRight: topRight, bottomLeft: bottomLeft, bottomRight: bottomRight})
  261 + }
  262 + /**
  263 + * 组件项
  264 + *
  265 + * @param programmeBean item 组件项, 上面icon,下面标题
  266 + */
  267 + @Builder
  268 + buildItemCard(item: PhotoListBean,len: number,index: number) {
  269 + Column() {
  270 + this.setItemImageRoundCorner(len, item, index)
  271 + Flex({ direction: FlexDirection.Row }) {
  272 + Image($r('app.media.icon_long_pic'))
  273 + .width(14)
  274 + .height(14)
  275 + .margin({right: 4})
  276 + Text('长图')
  277 + .fontSize(12)
  278 + .fontWeight(400)
  279 + .fontColor(0xffffff)
  280 + .fontFamily('PingFang SC')
  281 + }
  282 + .width(48)
  283 + .padding({bottom: 9})
  284 + }
  285 + .width('100%')
  286 + .onClick((event: ClickEvent) => {
  287 + if(this.contentDetailData.newsType+"" == ContentConstants.TYPE_FOURTEEN){
  288 + //fixme 跳转到查看图片页面(带页脚/下载按钮)
  289 + // this.mJumpInfo.objectType = ContentConstants.TYPE_
  290 + ProcessUtils.processPage(this.mJumpInfo)
  291 + }else{
  292 + //fixme 跳转到播放视频页面(点播)
  293 + this.mJumpInfo.objectType = ContentConstants.TYPE_VOD
  294 + ProcessUtils.processPage(this.mJumpInfo)
  295 + }
  296 + })
  297 + }
  298 +
  299 + //创建跳转信息
  300 + makeJumpInfo(){
  301 + this.mJumpInfo.pageId = 'dynamicDetailPage';
  302 + // this.mJumpInfo.from = 'dynamicDetailPage';
  303 + this.mJumpInfo.objectId = this.contentDetailData.newsId+"";
  304 + this.mJumpInfo.relType = this.contentDetailData.reLInfo?.relType+"";
  305 + this.mJumpInfo.relId = this.contentDetailData.reLInfo?.relId+"";
  306 + }
  307 +
  308 + //设置图片圆角
  309 + @Builder
  310 + setItemImageRoundCorner(len: number, item: PhotoListBean, index: number) {
  311 + if (len == 1) {
  312 + //四角圆角
  313 + this.setItemImageStyle(item.picPath, 4, 4, 4, 4);
  314 + } else if (len == 2) {
  315 + if (index == 0) {
  316 + //左边圆角
  317 + this.setItemImageStyle(item.picPath, 4, 0, 4, 0);
  318 + } else {
  319 + //右边圆角
  320 + this.setItemImageStyle(item.picPath, 0, 4, 0, 4);
  321 + }
  322 + } else if (3 == len) {
  323 + if (index == 0) {
  324 + //左边圆角
  325 + this.setItemImageStyle(item.picPath, 4, 0, 4, 0);
  326 + } else if (index == 1) {
  327 + //直角
  328 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  329 + } else {
  330 + //右边圆角
  331 + this.setItemImageStyle(item.picPath, 0, 4, 0, 4);
  332 + }
  333 + } else if (4 == len) {
  334 + if (index == 0) {
  335 + //左边圆角
  336 + this.setItemImageStyle(item.picPath, 4, 0, 4, 0);
  337 + } else if (index == 1) {
  338 + //右边圆角
  339 + this.setItemImageStyle(item.picPath, 0, 4, 0, 4);
  340 + } else if (index = 2) {
  341 + //左边圆角
  342 + this.setItemImageStyle(item.picPath, 4, 0, 4, 0);
  343 + } else {
  344 + //右边圆角
  345 + this.setItemImageStyle(item.picPath, 0, 4, 0, 4);
  346 + }
  347 + } else if (5 == len) {
  348 + if (index == 0) {
  349 + this.setItemImageStyle(item.picPath, 4, 0, 0, 0);
  350 + } else if (index == 1) {
  351 + //直角
  352 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  353 + } else if (index = 2) {
  354 + this.setItemImageStyle(item.picPath, 4, 4, 4, 4);
  355 + } else if (index = 3) {
  356 + this.setItemImageStyle(item.picPath, 0, 0, 4, 0);
  357 + } else {
  358 + this.setItemImageStyle(item.picPath, 0, 0, 0, 4);
  359 + }
  360 + } else if (6 == len) {
  361 + if (index == 0) {
  362 + this.setItemImageStyle(item.picPath, 4, 0, 0, 0);
  363 + } else if (index == 1) {
  364 + //直角
  365 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  366 + } else if (index = 2) {
  367 + this.setItemImageStyle(item.picPath, 0, 4, 0, 0);
  368 + } else if (index = 3) {
  369 + this.setItemImageStyle(item.picPath, 0, 0, 4, 0);
  370 + } else if (index = 4) {
  371 + //直角
  372 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  373 + } else {
  374 + //右边圆角
  375 + this.setItemImageStyle(item.picPath, 0, 0, 0, 4);
  376 + }
  377 + } else if (7 == len) {
  378 + if (index == 0) {
  379 + this.setItemImageStyle(item.picPath, 4, 0, 0, 0);
  380 + } else if (index == 1) {
  381 + //直角
  382 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  383 + } else if (index = 2) {
  384 + this.setItemImageStyle(item.picPath, 0, 4, 0, 0);
  385 + } else if (index = 3) {
  386 + //直角
  387 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  388 + } else if (index = 4) {
  389 + //直角
  390 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  391 + } else if (index = 5) {
  392 + this.setItemImageStyle(item.picPath, 0, 0, 0, 4);
  393 + } else {
  394 + this.setItemImageStyle(item.picPath, 0, 0, 4, 4);
  395 + }
  396 + } else if (8 == len) {
  397 + if (index == 0) {
  398 + this.setItemImageStyle(item.picPath, 4, 0, 0, 0);
  399 + } else if (index == 1) {
  400 + //直角
  401 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  402 + } else if (index = 2) {
  403 + this.setItemImageStyle(item.picPath, 0, 4, 0, 0);
  404 + } else if (index = 3) {
  405 + //直角
  406 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  407 + } else if (index = 4) {
  408 + //直角
  409 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  410 + } else if (index = 5) {
  411 + this.setItemImageStyle(item.picPath, 0, 0, 0, 4);
  412 + } else if (index = 6) {
  413 + this.setItemImageStyle(item.picPath, 0, 0, 4, 0);
  414 + } else {
  415 + this.setItemImageStyle(item.picPath, 0, 0, 0, 4);
  416 + }
  417 + } else {
  418 + if (index == 0) {
  419 + this.setItemImageStyle(item.picPath, 4, 0, 0, 0);
  420 + } else if (index == 1) {
  421 + //直角
  422 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  423 + } else if (index == 2) {
  424 + this.setItemImageStyle(item.picPath, 0, 4, 0, 0);
  425 + } else if (index == 3) {
  426 + //直角
  427 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  428 + } else if (index == 4) {
  429 + //直角
  430 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  431 + } else if (index == 5) {
  432 + //直角
  433 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  434 + } else if (index == 6) {
  435 + this.setItemImageStyle(item.picPath, 0, 0, 4, 0);
  436 + } else if (index == 7) {
  437 + //直角
  438 + this.setItemImageStyle(item.picPath, 0, 0, 0, 0);
  439 + } else {
  440 + this.setItemImageStyle(item.picPath, 0, 0, 0, 4);
  441 + }
  442 + }
175 } 443 }
176 } 444 }
@@ -56,6 +56,9 @@ export struct ZhGridLayout03 { @@ -56,6 +56,9 @@ export struct ZhGridLayout03 {
56 .textOverflow({ overflow: TextOverflow.Ellipsis }) 56 .textOverflow({ overflow: TextOverflow.Ellipsis })
57 } 57 }
58 .width('100%') 58 .width('100%')
  59 + .onClick((event: ClickEvent) => {
  60 + ProcessUtils.processPage(item)
  61 + })
59 } 62 }
60 } 63 }
61 64