zhaojunkai

人民号-相关交互元素缺失修复,新增分享显示/隐藏逻辑

@@ -10,6 +10,7 @@ import { BaseDTO } from '../component/BaseDTO'; @@ -10,6 +10,7 @@ import { BaseDTO } from '../component/BaseDTO';
10 10
11 @Observed 11 @Observed
12 export class ContentDTO implements BaseDTO { 12 export class ContentDTO implements BaseDTO {
  13 + shareFlag?:string='0';
13 appStyle: string = ''; 14 appStyle: string = '';
14 cityCode: string = ''; 15 cityCode: string = '';
15 coverSize: string = ''; 16 coverSize: string = '';
@@ -34,19 +34,22 @@ export struct CarderInteraction { @@ -34,19 +34,22 @@ export struct CarderInteraction {
34 34
35 build() { 35 build() {
36 Row() { 36 Row() {
37 - Row() {  
38 - Image($r('app.media.CarderInteraction_share'))  
39 - .width(18)  
40 - .height(18)  
41 - Text('分享')  
42 - .margin({ left: 4 })  
43 - .fontSize(14)  
44 - .fontColor('#666666') 37 + if(this.contentDTO.shareFlag === '1'){
  38 + Row() {
  39 + Image($r('app.media.CarderInteraction_share'))
  40 + .width(18)
  41 + .height(18)
  42 + Text('分享')
  43 + .margin({ left: 4 })
  44 + .fontSize(14)
  45 + .fontColor('#666666')
  46 + }
  47 + .justifyContent(FlexAlign.Center)
  48 + .onClick(() => {
  49 + WDShare.shareContent(this.contentDetailData)
  50 + })
45 } 51 }
46 - .justifyContent(FlexAlign.Center)  
47 - .onClick(() => {  
48 - WDShare.shareContent(this.contentDetailData)  
49 - }) 52 +
50 53
51 Row() { 54 Row() {
52 Image($r('app.media.CarderInteraction_comment')) 55 Image($r('app.media.CarderInteraction_comment'))
@@ -66,11 +69,11 @@ export struct CarderInteraction { @@ -66,11 +69,11 @@ export struct CarderInteraction {
66 } 69 }
67 .width('100%') 70 .width('100%')
68 .margin({ top: 11 }) 71 .margin({ top: 11 })
69 - .padding({  
70 - left: 21,  
71 - right: 21  
72 - })  
73 - .justifyContent(FlexAlign.SpaceBetween) 72 + // .padding({
  73 + // left: 21,
  74 + // right: 21
  75 + // })
  76 + .justifyContent(FlexAlign.SpaceAround)
74 .alignItems(VerticalAlign.Center) 77 .alignItems(VerticalAlign.Center)
75 } 78 }
76 79
@@ -14,6 +14,7 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' @@ -14,6 +14,7 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
14 import MinePageDatasModel from '../../model/MinePageDatasModel' 14 import MinePageDatasModel from '../../model/MinePageDatasModel'
15 import SearcherAboutDataModel from '../../model/SearcherAboutDataModel' 15 import SearcherAboutDataModel from '../../model/SearcherAboutDataModel'
16 import { CreatorDetailRequestItem } from '../../viewmodel/CreatorDetailRequestItem' 16 import { CreatorDetailRequestItem } from '../../viewmodel/CreatorDetailRequestItem'
  17 +import { CreatorDetailResponseItem } from '../../viewmodel/CreatorDetailResponseItem';
17 import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem' 18 import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem'
18 import { FollowListStatusRequestItem } from '../../viewmodel/FollowListStatusRequestItem' 19 import { FollowListStatusRequestItem } from '../../viewmodel/FollowListStatusRequestItem'
19 import { QueryListIsFollowedItem } from '../../viewmodel/QueryListIsFollowedItem' 20 import { QueryListIsFollowedItem } from '../../viewmodel/QueryListIsFollowedItem'
@@ -62,6 +63,7 @@ export struct SearchResultContentComponent { @@ -62,6 +63,7 @@ export struct SearchResultContentComponent {
62 if (this.hasMore) { 63 if (this.hasMore) {
63 SearcherAboutDataModel.getSearchResultListData("15", `${this.curPageNum}`, this.searchType, this.keywords, 64 SearcherAboutDataModel.getSearchResultListData("15", `${this.curPageNum}`, this.searchType, this.keywords,
64 getContext(this)).then((value) => { 65 getContext(this)).then((value) => {
  66 +
65 if (!this.data || value.list.length == 0) { 67 if (!this.data || value.list.length == 0) {
66 this.hasMore = false 68 this.hasMore = false
67 this.isLoading = false 69 this.isLoading = false
@@ -69,7 +71,6 @@ export struct SearchResultContentComponent { @@ -69,7 +71,6 @@ export struct SearchResultContentComponent {
69 } else { 71 } else {
70 if (value.list[0].dataList != null) { 72 if (value.list[0].dataList != null) {
71 let data_temp: SearchRmhDescription[] = [] 73 let data_temp: SearchRmhDescription[] = []
72 -  
73 data_temp = value.list[0].dataList 74 data_temp = value.list[0].dataList
74 75
75 //TODO 查询创作者详情接口 76 //TODO 查询创作者详情接口
@@ -118,7 +119,6 @@ export struct SearchResultContentComponent { @@ -118,7 +119,6 @@ export struct SearchResultContentComponent {
118 data_temp.forEach((data) => { 119 data_temp.forEach((data) => {
119 this.data_rmh.push(data) 120 this.data_rmh.push(data)
120 }) 121 })
121 -  
122 //只有一条创作者,获取 创作者信息 122 //只有一条创作者,获取 创作者信息
123 if (this.data_rmh.length === 1) { 123 if (this.data_rmh.length === 1) {
124 if(StringUtils.isNotEmpty(UserDataLocal.getUserId())){ 124 if(StringUtils.isNotEmpty(UserDataLocal.getUserId())){
@@ -175,21 +175,34 @@ export struct SearchResultContentComponent { @@ -175,21 +175,34 @@ export struct SearchResultContentComponent {
175 } 175 }
176 }) 176 })
177 }) 177 })
  178 + // 批量号主信息
  179 + let creatorIdList: string[] = []
  180 + resultData.list.forEach((value:SearchResultContentItem) => {
  181 + creatorIdList.push(value.data.creatorId)
  182 + })
  183 + SearcherAboutDataModel.getCreatorDetailListData({creatorIdList:creatorIdList}).then((rem) => {
178 184
179 - resultData.list.forEach((value) => {  
180 - let photos: FullColumnImgUrlDTO[] = []  
181 - if (value.data.appStyle === 4) {  
182 - value.data.appStyleImages.split("&&").forEach((value) => {  
183 - photos.push({ url: value } as FullColumnImgUrlDTO)  
184 - })  
185 - }  
186 185
187 - let contentDTO = this.dataTransform(value, photos);  
188 - if(value.data.type != "13"){  
189 - this.data.push(contentDTO)  
190 - } 186 + resultData.list.forEach((value) => {
  187 + let photos: FullColumnImgUrlDTO[] = []
  188 + // if (value.data.appStyle === 4) {
  189 + value.data.appStyleImages.split("&&").forEach((value) => {
  190 + const resizeParams = this.extractResizeParams(value)
  191 + photos.push({ fullUrl: value,weight:resizeParams.width,height:resizeParams.height, } as FullColumnImgUrlDTO)
  192 + })
  193 + // }
  194 + let contentDTO = this.dataTransform(rem,value, photos);
  195 + if(value.data.type != "13"){
  196 + this.data.push(contentDTO)
  197 + }
  198 + })
  199 +
191 200
  201 + }).catch((err: Error) => {
  202 + console.log(TAG, JSON.stringify(err))
192 }) 203 })
  204 +
  205 +
193 this.data.notifyDataReload() 206 this.data.notifyDataReload()
194 this.count = this.data.totalCount() 207 this.count = this.data.totalCount()
195 if (this.data.totalCount() < resultData.totalCount) { 208 if (this.data.totalCount() < resultData.totalCount) {
@@ -377,84 +390,171 @@ export struct SearchResultContentComponent { @@ -377,84 +390,171 @@ export struct SearchResultContentComponent {
377 .strokeWidth('12lpx') 390 .strokeWidth('12lpx')
378 } 391 }
379 392
380 - private dataTransform(value: SearchResultContentItem, photos: FullColumnImgUrlDTO[]): ContentDTO {  
381 - let contentDTO = new ContentDTO();  
382 - contentDTO.appStyle = value.data.appStyle + ""  
383 - contentDTO.cityCode = value.data.cityCode  
384 - contentDTO.coverSize = ""  
385 - contentDTO.coverType = value.data.type == "5" ? 1 : -1  
386 - contentDTO.coverUrl =  
387 - this.searchType == "activity" ? value.data.zhChannelPageImg : value.data.appStyleImages.split("&&")[0];  
388 - contentDTO.description = value.data.description  
389 - contentDTO.districtCode = value.data.districtCode  
390 - contentDTO.endTime = value.data.endTime  
391 - contentDTO.hImageUrl = ""  
392 - contentDTO.heatValue = ""  
393 - contentDTO.innerUrl = ""  
394 - contentDTO.landscape = Number.parseInt(value.data.landscape)  
395 - contentDTO.linkUrl = value.data.linkUrl  
396 - contentDTO.openLikes = Number.parseInt(value.data.openLikes)  
397 - contentDTO.openUrl = ""  
398 - contentDTO.pageId = value.data.pageId  
399 - contentDTO.programAuth = ""  
400 - contentDTO.programId = ""  
401 - contentDTO.programName = ""  
402 - contentDTO.programSource = -1  
403 - contentDTO.programType = Number.parseInt(value.data.status)  
404 - contentDTO.provinceCode = value.data.provinceCode  
405 - contentDTO.showTitleEd = value.data.showTitleEd  
406 - contentDTO.showTitleIng = value.data.showTitleIng  
407 - contentDTO.showTitleNo = value.data.showTitleNo  
408 - contentDTO.startTime = value.data.startTime  
409 - contentDTO.subType = ""  
410 - contentDTO.subtitle = ""  
411 - contentDTO.title = value.data.title  
412 - contentDTO.vImageUrl = ""  
413 - contentDTO.screenType = ""  
414 - contentDTO.source = StringUtils.isEmpty(value.data.creatorName) ? value.data.sourceName : value.data.creatorName  
415 - contentDTO.objectId = value.data.id  
416 - contentDTO.objectType = value.data.type  
417 - contentDTO.channelId = value.data.channelId  
418 - contentDTO.relId = value.data.relId  
419 - contentDTO.relType = value.data.relType  
420 - contentDTO.newsTitle = value.data.titleLiteral;  
421 - contentDTO.publishTime =  
422 - StringUtils.isNotEmpty(value.data.firstPublishTime) ? value.data.firstPublishTime : value.data.publishTime  
423 - contentDTO.visitorComment = -1  
424 - contentDTO.fullColumnImgUrls = photos  
425 - contentDTO.newsSummary = ""  
426 - contentDTO.hasMore = -1  
427 - contentDTO.slideShows = []  
428 - contentDTO.voiceInfo = {} as VoiceInfoDTO  
429 - contentDTO.tagWord = -1  
430 - contentDTO.isSelect = true  
431 - contentDTO.rmhInfo = {} as RmhInfoDTO  
432 - contentDTO.photoNum = -1  
433 - contentDTO.liveInfo = {} as LiveInfoDTO;  
434 - contentDTO.videoInfo = {  
435 - videoDuration: Number.parseInt(value.data.duration)  
436 - } as VideoInfoDTO;  
437 -  
438 - let interact = new InteractDataDTO()  
439 - interact.collectNum = value.data.collectNum  
440 - interact.commentNum = value.data.commentNum  
441 - interact.contentId = value.data.id  
442 - interact.contentType = Number.parseInt(value.data.type)  
443 - interact.likeNum = value.data.likeNum  
444 - interact.readNum = Number.parseInt(value.data.readNum)  
445 - interact.shareNum = Number.parseInt(value.data.shareNum)  
446 - contentDTO.interactData = interact  
447 - contentDTO.corner = ''  
448 - contentDTO.rmhPlatform = 0  
449 - contentDTO.newTags = ''  
450 - contentDTO.isSearch = true  
451 - contentDTO.publishTimestamp = ""  
452 - contentDTO.bottomNavId = '';  
453 - contentDTO.openType = '';  
454 - contentDTO.extra = '';  
455 - contentDTO.titleShow = value.data.type == "5" ? 1 : 0;  
456 - contentDTO.contentText = value.data.contentText;  
457 -  
458 - return contentDTO; 393 + private dataTransform(rem:CreatorDetailResponseItem[],value: SearchResultContentItem, photos: FullColumnImgUrlDTO[]): ContentDTO {
  394 + let rmhInfo = this.getRmhInfo(rem,value)
  395 + console.log('获取photos',JSON.stringify(photos))
  396 + console.log('获取value2',JSON.stringify(value))
  397 + let contentDTO = new ContentDTO();
  398 + contentDTO.appStyle = value.data.appStyle + ""
  399 + contentDTO.cityCode = value.data.cityCode
  400 + contentDTO.coverSize = ""
  401 + contentDTO.coverType = value.data.type == "5" ? 1 : -1
  402 + contentDTO.coverUrl =
  403 + this.searchType == "activity" ? value.data.zhChannelPageImg : value.data.appStyleImages.split("&&")[0];
  404 + contentDTO.description = value.data.description
  405 + contentDTO.districtCode = value.data.districtCode
  406 + contentDTO.endTime = value.data.endTime
  407 + contentDTO.hImageUrl = ""
  408 + contentDTO.heatValue = ""
  409 + contentDTO.innerUrl = ""
  410 + contentDTO.landscape = Number.parseInt(value.data.landscape)
  411 + contentDTO.linkUrl = value.data.linkUrl
  412 + contentDTO.openLikes = Number.parseInt(value.data.openLikes)
  413 + contentDTO.openUrl = ""
  414 + contentDTO.pageId = value.data.pageId
  415 + contentDTO.programAuth = ""
  416 + contentDTO.programId = ""
  417 + contentDTO.programName = ""
  418 + contentDTO.programSource = -1
  419 + contentDTO.programType = Number.parseInt(value.data.status)
  420 + contentDTO.provinceCode = value.data.provinceCode
  421 + contentDTO.showTitleEd = value.data.showTitleEd
  422 + contentDTO.showTitleIng = value.data.showTitleIng
  423 + contentDTO.showTitleNo = value.data.showTitleNo
  424 + contentDTO.startTime = value.data.startTime
  425 + contentDTO.subType = ""
  426 + contentDTO.subtitle = ""
  427 + contentDTO.title = value.data.title
  428 + contentDTO.vImageUrl = ""
  429 + contentDTO.screenType = ""
  430 + contentDTO.source = StringUtils.isEmpty(value.data.creatorName) ? value.data.sourceName : value.data.creatorName
  431 + contentDTO.objectId = value.data.id
  432 + contentDTO.objectType = value.data.type
  433 + contentDTO.channelId = value.data.channelId
  434 + contentDTO.relId = value.data.relId
  435 + contentDTO.relType = value.data.relType
  436 + contentDTO.newsTitle = value.data.titleLiteral;
  437 + contentDTO.publishTime =
  438 + StringUtils.isNotEmpty(value.data.firstPublishTime) ? value.data.firstPublishTime : value.data.publishTime
  439 + contentDTO.visitorComment = -1
  440 + contentDTO.fullColumnImgUrls = photos
  441 + contentDTO.newsSummary = ""
  442 + contentDTO.hasMore = -1
  443 + contentDTO.slideShows = []
  444 + contentDTO.voiceInfo = {} as VoiceInfoDTO
  445 + contentDTO.tagWord = -1
  446 + contentDTO.isSelect = true
  447 + contentDTO.rmhInfo = {} as RmhInfoDTO
  448 + contentDTO.photoNum = -1
  449 + contentDTO.liveInfo = {} as LiveInfoDTO;
  450 + contentDTO.videoInfo = {
  451 + videoDuration: Number.parseInt(value.data.duration)
  452 + } as VideoInfoDTO;
  453 +
  454 + let interact = new InteractDataDTO()
  455 + interact.collectNum = value.data.collectNum
  456 + interact.commentNum = value.data.commentNum
  457 + interact.contentId = value.data.id
  458 + interact.contentType = Number.parseInt(value.data.type)
  459 + interact.likeNum = value.data.likeNum
  460 + interact.readNum = Number.parseInt(value.data.readNum)
  461 + interact.shareNum = Number.parseInt(value.data.shareNum)
  462 + contentDTO.interactData = interact
  463 + contentDTO.corner = ''
  464 + contentDTO.rmhPlatform = 0
  465 + contentDTO.newTags = ''
  466 + contentDTO.isSearch = true
  467 + contentDTO.publishTimestamp = ""
  468 + contentDTO.bottomNavId = '';
  469 + contentDTO.openType = '';
  470 + contentDTO.extra = '';
  471 + contentDTO.titleShow = value.data.type == "5" ? 1 : 0;
  472 + contentDTO.rmhInfo = rmhInfo
  473 + contentDTO.shareFlag = value.data.shareFlag
  474 + return contentDTO;
  475 +
  476 +
  477 +
  478 + }
  479 + // 搜索数据转化rmhInfo
  480 + private getRmhInfo(rem:CreatorDetailResponseItem[],value:SearchResultContentItem){
  481 + let obj = value.data
  482 + let rmhInfo:RmhInfoDTO = {
  483 + rmhHeadUrl:obj.headerPhotoUrl,
  484 + rmhName:obj.creatorName,
  485 + rmhId:obj.creatorId,
  486 + authIcon:obj.authIcon,
  487 + authTitle: obj.authTitle,
  488 + authTitle2: '',
  489 + banControl: 0,
  490 + cnIsAttention: 0,
  491 + cnAttention: 0,
  492 + cnlsComment: 0,
  493 + cnlsLike: 0,
  494 + cnMainControl: 0,
  495 + cnShareControl: 0,
  496 + cnIsComment: 0,
  497 + cnIsLike:0,
  498 + posterShareControl: 0,
  499 + rmhDesc: obj.introduction,
  500 + userId: obj.userId,
  501 + userType: obj.userType,
  502 + honoraryIcon:''
  503 + }
  504 + if(rem.length>0){
  505 + rem.forEach(item=>{
  506 + if(item.creatorId === obj.creatorId){
  507 + rmhInfo = {
  508 + rmhHeadUrl:item.headPhotoUrl,
  509 + rmhName:item.userName,
  510 + rmhId:item.creatorId,
  511 + authIcon:item.authIcon,
  512 + authTitle: item.authTitle,
  513 + authTitle2: '',
  514 + banControl: 0,
  515 + cnIsAttention:item.isAttention,
  516 + cnAttention: 0,
  517 + cnlsComment: 0,
  518 + cnlsLike: 0,
  519 + cnMainControl: 0,
  520 + cnShareControl: 0,
  521 + cnIsComment: 0,
  522 + cnIsLike:0,
  523 + posterShareControl: 0,
  524 + rmhDesc: item.introduction,
  525 + userId: item.userId,
  526 + userType: item.userType,
  527 + honoraryIcon:''
  528 + }
  529 + }
  530 + })
  531 + }
  532 + return rmhInfo
  533 + }
  534 + private extractResizeParams(url: string) {
  535 + const heightRegex = /h_(\d+)/; // 匹配高度参数,如h_450
  536 + const widthRegex = /w_(\d+)/; // 匹配宽度参数,如w_800
  537 + const heightMatch = url.match(heightRegex);
  538 + const widthMatch = url.match(widthRegex);
  539 + let height = heightMatch ? `h_${heightMatch[1]}` : undefined
  540 + let width = widthMatch ? `w_${widthMatch[1]}` : undefined
  541 + let h:number =0
  542 + let w:number =0
  543 + if(height){
  544 + h = Number(height.split('_')[1])
  545 + }
  546 + if(width){
  547 + w = Number(width.split('_')[1])
  548 + }
  549 + interface Obj{
  550 + width:number;
  551 + height:number
  552 + }
  553 + let obj:Obj = {
  554 + width:w,
  555 + height:h
  556 + }
  557 + return obj
459 } 558 }
  559 +
460 } 560 }