yangchenggong1_wd

desc:点击展开更多相似

@@ -85,6 +85,8 @@ export class ContentDTO implements BaseDTO { @@ -85,6 +85,8 @@ export class ContentDTO implements BaseDTO {
85 // 链接类型: 0:无链接;1:内链(文章);2:外链 85 // 链接类型: 0:无链接;1:内链(文章);2:外链
86 openType: string = ''; 86 openType: string = '';
87 extra: string = '' 87 extra: string = ''
  88 + sameContentList:ContentDTO[] = []
  89 + sameContentListJson:string = ""
88 /* 90 /*
89 本地辅助字段 91 本地辅助字段
90 */ 92 */
1 /** 1 /**
2 * More_Comp 2 * More_Comp
3 */ 3 */
  4 +import { ContentDTO } from 'wdBean/Index';
  5 +
4 const TAG: string = 'Card9Component'; 6 const TAG: string = 'Card9Component';
5 7
6 @Entry 8 @Entry
7 @Component 9 @Component
8 export struct MoreComponent { 10 export struct MoreComponent {
  11 + @State contentDTO: ContentDTO = new ContentDTO();
9 12
10 build() { 13 build() {
11 Row() { 14 Row() {
@@ -20,12 +20,16 @@ import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem' @@ -20,12 +20,16 @@ import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem'
20 import { FollowListStatusRequestItem } from '../../viewmodel/FollowListStatusRequestItem' 20 import { FollowListStatusRequestItem } from '../../viewmodel/FollowListStatusRequestItem'
21 import { QueryListIsFollowedItem } from '../../viewmodel/QueryListIsFollowedItem' 21 import { QueryListIsFollowedItem } from '../../viewmodel/QueryListIsFollowedItem'
22 import { SearchResultContentData } from '../../viewmodel/SearchResultContentData' 22 import { SearchResultContentData } from '../../viewmodel/SearchResultContentData'
23 -import { SearchResultContentItem, SearchRmhDescription } from '../../viewmodel/SearchResultContentItem' 23 +import {
  24 + SearchDescription,
  25 + SearchResultContentItem, SearchRmhDescription } from '../../viewmodel/SearchResultContentItem'
24 import { CardParser } from '../CardParser' 26 import { CardParser } from '../CardParser'
25 import { FollowChildComponent } from '../mine/follow/FollowChildComponent' 27 import { FollowChildComponent } from '../mine/follow/FollowChildComponent'
26 import { ListHasNoMoreDataUI } from '../reusable/ListHasNoMoreDataUI' 28 import { ListHasNoMoreDataUI } from '../reusable/ListHasNoMoreDataUI'
27 import { ActivityItemComponent } from './ActivityItemComponent' 29 import { ActivityItemComponent } from './ActivityItemComponent'
28 import { SearchCreatorComponent } from './SearchCreatorComponent' 30 import { SearchCreatorComponent } from './SearchCreatorComponent'
  31 +import { JSON } from '@kit.ArkTS'
  32 +import { MoreComponent } from '../cardview/MoreComponent'
29 33
30 const TAG = "SearchResultContentComponent" 34 const TAG = "SearchResultContentComponent"
31 35
@@ -34,6 +38,7 @@ export struct SearchResultContentComponent { @@ -34,6 +38,7 @@ export struct SearchResultContentComponent {
34 @State keywords: string = "" 38 @State keywords: string = ""
35 @State searchType: string = "" 39 @State searchType: string = ""
36 @State data: LazyDataSource<ContentDTO> = new LazyDataSource(); 40 @State data: LazyDataSource<ContentDTO> = new LazyDataSource();
  41 + tempList : ContentDTO[] = []
37 @State data_rmh: SearchRmhDescription[] = [] 42 @State data_rmh: SearchRmhDescription[] = []
38 @State count: number = -1; 43 @State count: number = -1;
39 @State isLoading: boolean = false 44 @State isLoading: boolean = false
@@ -62,7 +67,7 @@ export struct SearchResultContentComponent { @@ -62,7 +67,7 @@ export struct SearchResultContentComponent {
62 getNewSearchResultData() { 67 getNewSearchResultData() {
63 this.isLoading = true 68 this.isLoading = true
64 if (this.hasMore) { 69 if (this.hasMore) {
65 - SearcherAboutDataModel.getSearchResultListData("15", `${this.curPageNum}`, this.searchType, this.keywords, 70 + SearcherAboutDataModel.getSearchResultListData("20", `${this.curPageNum}`, this.searchType, this.keywords,
66 getContext(this)).then((value) => { 71 getContext(this)).then((value) => {
67 console.log('SearcherAboutDataModel', JSON.stringify(value)) 72 console.log('SearcherAboutDataModel', JSON.stringify(value))
68 if (!this.data || value.list.length == 0) { 73 if (!this.data || value.list.length == 0) {
@@ -183,9 +188,8 @@ export struct SearchResultContentComponent { @@ -183,9 +188,8 @@ export struct SearchResultContentComponent {
183 resultData.list.forEach((value:SearchResultContentItem) => { 188 resultData.list.forEach((value:SearchResultContentItem) => {
184 creatorIdList.push(value.data.creatorId) 189 creatorIdList.push(value.data.creatorId)
185 }) 190 })
  191 + let isRemain : boolean = false
186 SearcherAboutDataModel.getCreatorDetailListData({creatorIdList:creatorIdList}).then((rem) => { 192 SearcherAboutDataModel.getCreatorDetailListData({creatorIdList:creatorIdList}).then((rem) => {
187 -  
188 -  
189 resultData.list.forEach((value) => { 193 resultData.list.forEach((value) => {
190 let photos: FullColumnImgUrlDTO[] = [] 194 let photos: FullColumnImgUrlDTO[] = []
191 // if (value.data.appStyle === 4) { 195 // if (value.data.appStyle === 4) {
@@ -196,42 +200,98 @@ export struct SearchResultContentComponent { @@ -196,42 +200,98 @@ export struct SearchResultContentComponent {
196 // } 200 // }
197 let contentDTO = this.dataTransform(rem,value, photos); 201 let contentDTO = this.dataTransform(rem,value, photos);
198 if(value.data.type != "13"){ 202 if(value.data.type != "13"){
199 - this.data.push(contentDTO) 203 + this.tempList.push(contentDTO)
  204 + if(value.data.sameContentList != null && value.data.sameContentList.length > 0) {
  205 + let contentDTO2 = new ContentDTO();
  206 + contentDTO2.sameContentListJson = JSON.stringify(value.data.sameContentList)
  207 + isRemain = true
  208 + this.tempList.push(contentDTO2)
  209 + }
200 } 210 }
201 }) 211 })
202 -  
203 - 212 + if(!isRemain){
  213 + this.tempList.forEach((value) => {
  214 + this.data.push(value)
  215 + })
  216 + this.tempList = []
  217 + this.data.notifyDataReload()
  218 + this.count = this.data.totalCount()
  219 + if (this.count < resultData.totalCount) {
  220 + this.curPageNum++
  221 + } else {
  222 + this.hasMore = false
  223 + }
  224 + this.isLoading = false
  225 + }else{
  226 + this.dealSameContent(resultData.totalCount)
  227 + }
204 }).catch((err: Error) => { 228 }).catch((err: Error) => {
205 console.log(TAG, JSON.stringify(err)) 229 console.log(TAG, JSON.stringify(err))
206 }) 230 })
207 -  
208 -  
209 - this.data.notifyDataReload()  
210 - this.count = this.data.totalCount()  
211 - if (this.data.totalCount() < resultData.totalCount) {  
212 - this.curPageNum++  
213 - } else {  
214 - this.hasMore = false  
215 - } 231 + }).catch((err: Error) => {
  232 + console.log(TAG, "请求失败")
216 this.isLoading = false 233 this.isLoading = false
  234 + this.count = this.count === -1 ? 0 : this.count
  235 + })
  236 + }
217 237
218 - if (this.count === 0 && resultData.list.length > 0) {  
219 - this.count = -1  
220 - if (!this.isLoading) {  
221 - //加载分页数据  
222 - this.getNewSearchResultData() 238 + async dealSameContent(count:number){
  239 + this.tempList.forEach(async (tempValue) => {
  240 + if(StringUtils.isNotEmpty(tempValue.sameContentListJson)){
  241 + let data: contentListParams = {
  242 + contentList: []
223 } 243 }
224 - } else if (this.count <= 10 && resultData.list.length > 0) {  
225 - if (!this.isLoading) {  
226 - //加载分页数据  
227 - this.getNewSearchResultData() 244 + let resultData : SearchDescription[] = JSON.parse(tempValue.sameContentListJson) as SearchDescription[]
  245 + if(resultData!=null){
  246 + resultData.forEach((item) => {
  247 + data.contentList.push({
  248 + contentId: item.id + '',
  249 + contentType: Number.parseInt(item.type)
  250 + })
  251 + })
  252 +
  253 + let newValue = await SearcherAboutDataModel.getInteractListData(data, getContext(this))
  254 + newValue.forEach((item) => {
  255 + resultData.forEach((data) => {
  256 + if (item.contentId == data.id) {
  257 + data.collectNum = item.collectNum + ""
  258 + data.commentNum = item.commentNum + ""
  259 + data.likeNum = item.likeNum + ""
  260 + data.readNum = item.readNum + ""
  261 + data.shareNum = item.shareNum + ""
  262 + }
  263 + })
  264 + })
  265 + let creatorIdList: string[] = []
  266 + resultData.forEach((value:SearchDescription) => {
  267 + creatorIdList.push(value.creatorId)
  268 + })
  269 + let rem = await SearcherAboutDataModel.getCreatorDetailListData({creatorIdList:creatorIdList})
  270 + resultData.forEach((value) => {
  271 + let photos: FullColumnImgUrlDTO[] = []
  272 + value.appStyleImages.split("&&").forEach((value) => {
  273 + const resizeParams = this.extractResizeParams(value)
  274 + photos.push({ fullUrl: value,weight:resizeParams.width,height:resizeParams.height, } as FullColumnImgUrlDTO)
  275 + })
  276 + let contentDTO = this.dataTransform2(rem,value, photos);
  277 + tempValue.sameContentList.push(contentDTO)
  278 + })
228 } 279 }
229 } 280 }
230 - }).catch((err: Error) => {  
231 - console.log(TAG, "请求失败")  
232 - this.isLoading = false  
233 - this.count = this.count === -1 ? 0 : this.count  
234 }) 281 })
  282 +
  283 + this.tempList.forEach((value) => {
  284 + this.data.push(value)
  285 + })
  286 + this.tempList = []
  287 + this.data.notifyDataReload()
  288 + this.count = this.data.totalCount()
  289 + if (this.count < count) {
  290 + this.curPageNum++
  291 + } else {
  292 + this.hasMore = false
  293 + }
  294 + this.isLoading = false
235 } 295 }
236 296
237 build() { 297 build() {
@@ -258,6 +318,8 @@ export struct SearchResultContentComponent { @@ -258,6 +318,8 @@ export struct SearchResultContentComponent {
258 Column() { 318 Column() {
259 if (this.searchType == "activity") { 319 if (this.searchType == "activity") {
260 ActivityItemComponent({ contentDTO: item }) 320 ActivityItemComponent({ contentDTO: item })
  321 + }else if(item.sameContentList != null && item.sameContentList.length > 0){
  322 + MoreComponent({ contentDTO: item })
261 } else { 323 } else {
262 CardParser({compDTO:new CompDTO, contentDTO: item }) 324 CardParser({compDTO:new CompDTO, contentDTO: item })
263 } 325 }
@@ -284,7 +346,6 @@ export struct SearchResultContentComponent { @@ -284,7 +346,6 @@ export struct SearchResultContentComponent {
284 .onReachEnd(() => { 346 .onReachEnd(() => {
285 console.log(TAG, "触底了"); 347 console.log(TAG, "触底了");
286 if (!this.isLoading) { 348 if (!this.isLoading) {
287 - //加载分页数据  
288 this.getNewSearchResultData() 349 this.getNewSearchResultData()
289 } 350 }
290 }) 351 })
@@ -476,10 +537,94 @@ export struct SearchResultContentComponent { @@ -476,10 +537,94 @@ export struct SearchResultContentComponent {
476 contentDTO.shareFlag = value.data.shareFlag 537 contentDTO.shareFlag = value.data.shareFlag
477 contentDTO.contentText = value.data.contentText 538 contentDTO.contentText = value.data.contentText
478 return contentDTO; 539 return contentDTO;
  540 + }
479 541
  542 + private dataTransform2(rem:CreatorDetailResponseItem[],value: SearchDescription, photos: FullColumnImgUrlDTO[]): ContentDTO {
  543 + let rmhInfo = this.getRmhInfo2(rem,value)
  544 + console.log('获取photos',JSON.stringify(photos))
  545 + console.log('获取value2',JSON.stringify(value))
  546 + let contentDTO = new ContentDTO();
  547 + contentDTO.appStyle = value.appStyle + ""
  548 + contentDTO.cityCode = value.cityCode
  549 + contentDTO.coverSize = ""
  550 + contentDTO.coverType = value.type == "5" ? 1 : -1
  551 + contentDTO.coverUrl =
  552 + this.searchType == "activity" ? value.zhChannelPageImg : value.appStyleImages.split("&&")[0];
  553 + contentDTO.description = value.description
  554 + contentDTO.districtCode = value.districtCode
  555 + contentDTO.endTime = value.endTime
  556 + contentDTO.hImageUrl = ""
  557 + contentDTO.heatValue = ""
  558 + contentDTO.innerUrl = ""
  559 + contentDTO.landscape = Number.parseInt(value.landscape)
  560 + contentDTO.linkUrl = value.linkUrl
  561 + contentDTO.openLikes = Number.parseInt(value.openLikes)
  562 + contentDTO.openUrl = ""
  563 + contentDTO.pageId = value.pageId
  564 + contentDTO.programAuth = ""
  565 + contentDTO.programId = ""
  566 + contentDTO.programName = ""
  567 + contentDTO.programSource = -1
  568 + contentDTO.programType = Number.parseInt(value.status)
  569 + contentDTO.provinceCode = value.provinceCode
  570 + contentDTO.showTitleEd = value.showTitleEd
  571 + contentDTO.showTitleIng = value.showTitleIng
  572 + contentDTO.showTitleNo = value.showTitleNo
  573 + contentDTO.startTime = value.startTime
  574 + contentDTO.subType = ""
  575 + contentDTO.subtitle = ""
  576 + contentDTO.title = value.title
  577 + contentDTO.vImageUrl = ""
  578 + contentDTO.screenType = ""
  579 + contentDTO.source = StringUtils.isEmpty(value.creatorName) ? value.sourceName : value.creatorName
  580 + contentDTO.objectId = value.id
  581 + contentDTO.objectType = value.type
  582 + contentDTO.channelId = value.channelId
  583 + contentDTO.relId = value.relId
  584 + contentDTO.relType = value.relType
  585 + contentDTO.newsTitle = value.titleLiteral;
  586 + contentDTO.publishTime =
  587 + StringUtils.isNotEmpty(value.firstPublishTime) ? value.firstPublishTime : value.publishTime
  588 + contentDTO.visitorComment = -1
  589 + contentDTO.fullColumnImgUrls = photos
  590 + contentDTO.newsSummary = ""
  591 + contentDTO.hasMore = -1
  592 + contentDTO.slideShows = []
  593 + contentDTO.voiceInfo = {} as VoiceInfoDTO
  594 + contentDTO.tagWord = -1
  595 + contentDTO.isSelect = true
  596 + contentDTO.rmhInfo = {} as RmhInfoDTO
  597 + contentDTO.photoNum = -1
  598 + contentDTO.liveInfo = {} as LiveInfoDTO;
  599 + contentDTO.videoInfo = {
  600 + videoDuration: Number.parseInt(value.duration)
  601 + } as VideoInfoDTO;
  602 +
  603 + let interact = new InteractDataDTO()
  604 + interact.collectNum = value.collectNum
  605 + interact.commentNum = value.commentNum
  606 + interact.contentId = value.id
  607 + interact.contentType = Number.parseInt(value.type)
  608 + interact.likeNum = value.likeNum
  609 + interact.readNum = Number.parseInt(value.readNum)
  610 + interact.shareNum = Number.parseInt(value.shareNum)
  611 + contentDTO.interactData = interact
  612 + contentDTO.corner = ''
  613 + contentDTO.rmhPlatform = 0
  614 + contentDTO.newTags = ''
  615 + contentDTO.isSearch = true
  616 + contentDTO.publishTimestamp = ""
  617 + contentDTO.bottomNavId = '';
  618 + contentDTO.openType = '';
  619 + contentDTO.extra = '';
  620 + contentDTO.titleShow = value.type == "5" ? 1 : 0;
  621 + contentDTO.rmhInfo = rmhInfo
  622 + contentDTO.shareFlag = value.shareFlag
  623 + contentDTO.contentText = value.contentText
  624 + return contentDTO;
  625 + }
480 626
481 627
482 - }  
483 // 搜索数据转化rmhInfo 628 // 搜索数据转化rmhInfo
484 private getRmhInfo(rem:CreatorDetailResponseItem[],value:SearchResultContentItem){ 629 private getRmhInfo(rem:CreatorDetailResponseItem[],value:SearchResultContentItem){
485 let obj = value.data 630 let obj = value.data
@@ -535,6 +680,65 @@ export struct SearchResultContentComponent { @@ -535,6 +680,65 @@ export struct SearchResultContentComponent {
535 } 680 }
536 return rmhInfo 681 return rmhInfo
537 } 682 }
  683 +
  684 + // 搜索数据转化rmhInfo
  685 + private getRmhInfo2(rem:CreatorDetailResponseItem[],value:SearchDescription){
  686 + let obj = value
  687 + let rmhInfo:RmhInfoDTO = {
  688 + rmhHeadUrl:obj.headerPhotoUrl,
  689 + rmhName:obj.creatorName,
  690 + rmhId:obj.creatorId,
  691 + authIcon:obj.authIcon,
  692 + authTitle: obj.authTitle,
  693 + authTitle2: '',
  694 + banControl: 0,
  695 + cnIsAttention: 0,
  696 + cnAttention: 0,
  697 + cnlsComment: 0,
  698 + cnlsLike: 0,
  699 + cnMainControl: 0,
  700 + cnShareControl: 0,
  701 + cnIsComment: 0,
  702 + cnIsLike:0,
  703 + posterShareControl: 0,
  704 + rmhDesc: obj.introduction,
  705 + userId: obj.userId,
  706 + userType: obj.userType,
  707 + honoraryIcon:''
  708 + }
  709 + if(rem.length>0){
  710 + rem.forEach(item=>{
  711 + if(item.creatorId === obj.creatorId){
  712 + rmhInfo = {
  713 + rmhHeadUrl:item.headPhotoUrl,
  714 + rmhName:item.userName,
  715 + rmhId:item.creatorId,
  716 + authIcon:item.authIcon,
  717 + authTitle: item.authTitle,
  718 + authTitle2: '',
  719 + banControl: 0,
  720 + cnIsAttention:item.isAttention,
  721 + cnAttention: 0,
  722 + cnlsComment: 0,
  723 + cnlsLike: 0,
  724 + cnMainControl: 0,
  725 + cnShareControl: 0,
  726 + cnIsComment: 0,
  727 + cnIsLike:0,
  728 + posterShareControl: 0,
  729 + rmhDesc: item.introduction,
  730 + userId: item.userId,
  731 + userType: item.userType,
  732 + honoraryIcon:''
  733 + }
  734 + }
  735 + })
  736 + }
  737 + return rmhInfo
  738 + }
  739 +
  740 +
  741 +
538 private extractResizeParams(url: string) { 742 private extractResizeParams(url: string) {
539 const heightRegex = /h_(\d+)/; // 匹配高度参数,如h_450 743 const heightRegex = /h_(\d+)/; // 匹配高度参数,如h_450
540 const widthRegex = /w_(\d+)/; // 匹配宽度参数,如w_800 744 const widthRegex = /w_(\d+)/; // 匹配宽度参数,如w_800
@@ -5,7 +5,7 @@ export class SearchResultContentItem{ @@ -5,7 +5,7 @@ export class SearchResultContentItem{
5 resultType:string = "" 5 resultType:string = ""
6 } 6 }
7 7
8 -class SearchDescription{ 8 +export class SearchDescription{
9 likeEnable: string = "" 9 likeEnable: string = ""
10 previewUri: string = "" 10 previewUri: string = ""
11 firstFrameImageBucket: string = "" 11 firstFrameImageBucket: string = ""
@@ -178,7 +178,7 @@ class SearchDescription{ @@ -178,7 +178,7 @@ class SearchDescription{
178 likeNum: string= "" 178 likeNum: string= ""
179 readNum: string= "" 179 readNum: string= ""
180 shareNum: string= "" 180 shareNum: string= ""
181 - 181 + sameContentList:SearchDescription[] = []
182 } 182 }
183 183
184 @Observed 184 @Observed