Showing
4 changed files
with
16 additions
and
115 deletions
| @@ -25,6 +25,7 @@ export struct SearchComponent { | @@ -25,6 +25,7 @@ export struct SearchComponent { | ||
| 25 | @State relatedSearchContentsData: SearchRelatedItem[] = [] | 25 | @State relatedSearchContentsData: SearchRelatedItem[] = [] |
| 26 | scroller: Scroller = new Scroller() | 26 | scroller: Scroller = new Scroller() |
| 27 | @State count:string[] = [] | 27 | @State count:string[] = [] |
| 28 | + @State isGetRequest:boolean = false; | ||
| 28 | 29 | ||
| 29 | aboutToAppear() { | 30 | aboutToAppear() { |
| 30 | //获取提示滚动 | 31 | //获取提示滚动 |
| @@ -112,7 +113,7 @@ export struct SearchComponent { | @@ -112,7 +113,7 @@ export struct SearchComponent { | ||
| 112 | } else { | 113 | } else { |
| 113 | if (this.hasChooseSearch) { | 114 | if (this.hasChooseSearch) { |
| 114 | //搜索结果 | 115 | //搜索结果 |
| 115 | - SearchResultComponent({count:this.count,searchText:this.searchText,isInit:true}) | 116 | + SearchResultComponent({count:this.count,searchText:this.searchText,isGetRequest:this.isGetRequest}) |
| 116 | } else { | 117 | } else { |
| 117 | //联想搜索 | 118 | //联想搜索 |
| 118 | SearchRelatedComponent({relatedSearchContentData:$relatedSearchContentsData,onGetSearchRes: (item): void => this.getSearchRelatedResData(item),searchText:this.searchText}) | 119 | SearchRelatedComponent({relatedSearchContentData:$relatedSearchContentsData,onGetSearchRes: (item): void => this.getSearchRelatedResData(item),searchText:this.searchText}) |
| @@ -287,8 +288,10 @@ export struct SearchComponent { | @@ -287,8 +288,10 @@ export struct SearchComponent { | ||
| 287 | this.count.push("活动") | 288 | this.count.push("活动") |
| 288 | } | 289 | } |
| 289 | } | 290 | } |
| 291 | + this.isGetRequest = true | ||
| 290 | }).catch((err: Error) => { | 292 | }).catch((err: Error) => { |
| 291 | console.log(TAG, JSON.stringify(err)) | 293 | console.log(TAG, JSON.stringify(err)) |
| 294 | + this.isGetRequest = true | ||
| 292 | }) | 295 | }) |
| 293 | } | 296 | } |
| 294 | } | 297 | } |
| @@ -17,7 +17,7 @@ const TAG = "SearchResultComponent" | @@ -17,7 +17,7 @@ const TAG = "SearchResultComponent" | ||
| 17 | export struct SearchResultComponent { | 17 | export struct SearchResultComponent { |
| 18 | @Prop count: string[] | 18 | @Prop count: string[] |
| 19 | @Prop searchText: string | 19 | @Prop searchText: string |
| 20 | - @State isInit:boolean = false; | 20 | + @Prop isGetRequest:boolean = false; |
| 21 | @State currentIndex: number = 0 | 21 | @State currentIndex: number = 0 |
| 22 | private controller: TabsController = new TabsController() | 22 | private controller: TabsController = new TabsController() |
| 23 | fontColor: string = '#999999' | 23 | fontColor: string = '#999999' |
| @@ -28,7 +28,7 @@ export struct SearchResultComponent { | @@ -28,7 +28,7 @@ export struct SearchResultComponent { | ||
| 28 | scroller: Scroller = new Scroller() | 28 | scroller: Scroller = new Scroller() |
| 29 | 29 | ||
| 30 | aboutToAppear(): void { | 30 | aboutToAppear(): void { |
| 31 | - if (this.count.length === 0 && this.isInit == true) { | 31 | + if (this.count.length === 0 && this.isGetRequest == true) { |
| 32 | this.getSuggestData() | 32 | this.getSuggestData() |
| 33 | } | 33 | } |
| 34 | } | 34 | } |
| @@ -40,18 +40,7 @@ export struct SearchResultComponent { | @@ -40,18 +40,7 @@ export struct SearchResultComponent { | ||
| 40 | 40 | ||
| 41 | SearcherAboutDataModel.getSearchSuggestData(request, getContext(this)).then((value) => { | 41 | SearcherAboutDataModel.getSearchSuggestData(request, getContext(this)).then((value) => { |
| 42 | value.forEach((item) => { | 42 | value.forEach((item) => { |
| 43 | - this.data.push({ | ||
| 44 | - appStyle: item.appStyle, | ||
| 45 | - channelId: item.channelId + "", | ||
| 46 | - coverType: item.coverType, | ||
| 47 | - coverUrl: item.coverUrl, | ||
| 48 | - newsTitle: item.newsTitle, | ||
| 49 | - objectId: item.objectId, | ||
| 50 | - publishTime: item.publishTime, | ||
| 51 | - relId: item.relId + "", | ||
| 52 | - relType: item.relType + "", | ||
| 53 | - source: item.source, | ||
| 54 | - } as ContentDTO) | 43 | + this.data.push(item) |
| 55 | }) | 44 | }) |
| 56 | this.data.notifyDataReload() | 45 | this.data.notifyDataReload() |
| 57 | this.suggest_count = this.data.totalCount() | 46 | this.suggest_count = this.data.totalCount() |
| @@ -61,7 +50,7 @@ export struct SearchResultComponent { | @@ -61,7 +50,7 @@ export struct SearchResultComponent { | ||
| 61 | 50 | ||
| 62 | build() { | 51 | build() { |
| 63 | Column() { | 52 | Column() { |
| 64 | - if (this.count != null && this.count.length === 0 && this.isInit == true) { | 53 | + if (this.count != null && this.count.length === 0 && this.isGetRequest == true) { |
| 65 | List() { | 54 | List() { |
| 66 | ListItem() { | 55 | ListItem() { |
| 67 | //缺省图 | 56 | //缺省图 |
| @@ -6,10 +6,9 @@ import { SearchHistoryItem } from '../viewmodel/SearchHistoryItem'; | @@ -6,10 +6,9 @@ import { SearchHistoryItem } from '../viewmodel/SearchHistoryItem'; | ||
| 6 | import { SearchHotContentItem } from '../viewmodel/SearchHotContentItem'; | 6 | import { SearchHotContentItem } from '../viewmodel/SearchHotContentItem'; |
| 7 | import { SearchResultCountItem } from '../viewmodel/SearchResultCountItem'; | 7 | import { SearchResultCountItem } from '../viewmodel/SearchResultCountItem'; |
| 8 | import { SearchResultContentData } from '../viewmodel/SearchResultContentData'; | 8 | import { SearchResultContentData } from '../viewmodel/SearchResultContentData'; |
| 9 | -import { contentListParams, InteractDataDTO } from 'wdBean/Index'; | 9 | +import { ContentDTO, contentListParams, InteractDataDTO } from 'wdBean/Index'; |
| 10 | import { CreatorDetailRequestItem } from '../viewmodel/CreatorDetailRequestItem'; | 10 | import { CreatorDetailRequestItem } from '../viewmodel/CreatorDetailRequestItem'; |
| 11 | import { CreatorDetailResponseItem } from '../viewmodel/CreatorDetailResponseItem'; | 11 | import { CreatorDetailResponseItem } from '../viewmodel/CreatorDetailResponseItem'; |
| 12 | -import { SearchSuggestData } from '../viewmodel/SearchSuggestData'; | ||
| 13 | import { SearchSuggestRequestItem } from '../viewmodel/SearchSuggestRequestItem'; | 12 | import { SearchSuggestRequestItem } from '../viewmodel/SearchSuggestRequestItem'; |
| 14 | 13 | ||
| 15 | const TAG = "SearcherAboutDataModel" | 14 | const TAG = "SearcherAboutDataModel" |
| @@ -354,17 +353,17 @@ class SearcherAboutDataModel{ | @@ -354,17 +353,17 @@ class SearcherAboutDataModel{ | ||
| 354 | /** | 353 | /** |
| 355 | * 搜索推荐 展示列表 | 354 | * 搜索推荐 展示列表 |
| 356 | */ | 355 | */ |
| 357 | - getSearchSuggestData(object:SearchSuggestRequestItem,context: Context): Promise<SearchSuggestData[]> { | ||
| 358 | - return new Promise<SearchSuggestData[]>((success, error) => { | 356 | + getSearchSuggestData(object:SearchSuggestRequestItem,context: Context): Promise<ContentDTO[]> { |
| 357 | + return new Promise<ContentDTO[]>((success, error) => { | ||
| 359 | Logger.info(TAG, `getSearchSuggestData start`); | 358 | Logger.info(TAG, `getSearchSuggestData start`); |
| 360 | - this.fetchSearchSuggestData(object).then((navResDTO: ResponseDTO<SearchSuggestData[]>) => { | 359 | + this.fetchSearchSuggestData(object).then((navResDTO: ResponseDTO<ContentDTO[]>) => { |
| 361 | if (!navResDTO || navResDTO.code != 0 /*|| navResDTO.data == null*/) { | 360 | if (!navResDTO || navResDTO.code != 0 /*|| navResDTO.data == null*/) { |
| 362 | // success(this.getSearchSuggestDataLocal(context)) | 361 | // success(this.getSearchSuggestDataLocal(context)) |
| 363 | success([]) | 362 | success([]) |
| 364 | return | 363 | return |
| 365 | } | 364 | } |
| 366 | Logger.info(TAG, "getSearchSuggestData then,SearchResultListResDTO.timeStamp:" + navResDTO.timestamp); | 365 | Logger.info(TAG, "getSearchSuggestData then,SearchResultListResDTO.timeStamp:" + navResDTO.timestamp); |
| 367 | - let navigationBean = navResDTO.data as SearchSuggestData[] | 366 | + let navigationBean = navResDTO.data as ContentDTO[] |
| 368 | success(navigationBean); | 367 | success(navigationBean); |
| 369 | }).catch((err: Error) => { | 368 | }).catch((err: Error) => { |
| 370 | Logger.error(TAG, `getSearchSuggestData catch, error.name : ${err.name}, error.message:${err.message}`); | 369 | Logger.error(TAG, `getSearchSuggestData catch, error.name : ${err.name}, error.message:${err.message}`); |
| @@ -377,12 +376,12 @@ class SearcherAboutDataModel{ | @@ -377,12 +376,12 @@ class SearcherAboutDataModel{ | ||
| 377 | fetchSearchSuggestData(object:SearchSuggestRequestItem) { | 376 | fetchSearchSuggestData(object:SearchSuggestRequestItem) { |
| 378 | let url = HttpUrlUtils.getSearchSuggestDataUrl() | 377 | let url = HttpUrlUtils.getSearchSuggestDataUrl() |
| 379 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 378 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 380 | - return WDHttp.post<ResponseDTO<SearchSuggestData[]>>(url,object, headers) | 379 | + return WDHttp.post<ResponseDTO<ContentDTO[]>>(url,object, headers) |
| 381 | }; | 380 | }; |
| 382 | 381 | ||
| 383 | - async getSearchSuggestDataLocal(context: Context): Promise<SearchSuggestData[]> { | 382 | + async getSearchSuggestDataLocal(context: Context): Promise<ContentDTO[]> { |
| 384 | Logger.info(TAG, `getInteractListDataLocal start`); | 383 | Logger.info(TAG, `getInteractListDataLocal start`); |
| 385 | - let compRes: ResponseDTO<SearchSuggestData[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<SearchSuggestData[]>>(context,'search_suggest_data.json' ); | 384 | + let compRes: ResponseDTO<ContentDTO[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<ContentDTO[]>>(context,'search_suggest_data.json' ); |
| 386 | if (!compRes || !compRes.data) { | 385 | if (!compRes || !compRes.data) { |
| 387 | Logger.info(TAG, `getInteractListDataLocal compRes is empty`); | 386 | Logger.info(TAG, `getInteractListDataLocal compRes is empty`); |
| 388 | return [] | 387 | return [] |
| 1 | -@Observed | ||
| 2 | -export class SearchSuggestData{ | ||
| 3 | - // activityExt: null | ||
| 4 | - appStyle: string = "" | ||
| 5 | - // askInfo: null | ||
| 6 | - axisColor: string = "" | ||
| 7 | - // bestNoticer: null | ||
| 8 | - // bottomNavId: null | ||
| 9 | - cardItemId: string = "" | ||
| 10 | - channelId: number = -1 | ||
| 11 | - // commentInfo: null | ||
| 12 | - corner: string = "" | ||
| 13 | - coverSize: string = "" | ||
| 14 | - coverType: number = -1 | ||
| 15 | - coverUrl: string = "" | ||
| 16 | - expIds: string = "" | ||
| 17 | - extra: string = "" | ||
| 18 | - fullColumnImgUrls: Array<FullColumnImgUrls> = [] | ||
| 19 | - // hasMore: null | ||
| 20 | - itemId: string = "" | ||
| 21 | - itemType: string = "" | ||
| 22 | - itemTypeCode: string = "" | ||
| 23 | - keyArticle: number = -1 | ||
| 24 | - // landscape: null | ||
| 25 | - // likeStyle: null | ||
| 26 | - linkUrl: string = "" | ||
| 27 | - // liveInfo: null | ||
| 28 | - menuShow: number = -1 | ||
| 29 | - newTags: string = "" | ||
| 30 | - newsAuthor: string = "" | ||
| 31 | - newsSubTitle: string = "" | ||
| 32 | - newsSummary: string = "" | ||
| 33 | - newsTitle: string = "" | ||
| 34 | - newsTitleColor: string = "" | ||
| 35 | - objectId: string = "" | ||
| 36 | - objectLevel: string = "" | ||
| 37 | - objectType: string = "" | ||
| 38 | - // openComment: null | ||
| 39 | - // openLikes: null | ||
| 40 | - pageId: string = "" | ||
| 41 | - // photoNum: null | ||
| 42 | - // position: null | ||
| 43 | - // productNum: null | ||
| 44 | - publishTime: string = "" | ||
| 45 | - // pushTime: null | ||
| 46 | - // pushUnqueId: null | ||
| 47 | - readFlag: number = -1 | ||
| 48 | - recommend: number = -1 | ||
| 49 | - relId: number = -1 | ||
| 50 | - relObjectId: string = "" | ||
| 51 | - relType: number = -1 | ||
| 52 | - // rmhInfo: null | ||
| 53 | - rmhPlatform: number = -1 | ||
| 54 | - sceneId: string = "" | ||
| 55 | - // shareInfo: null | ||
| 56 | - // slideShows: Array< unknown > | ||
| 57 | - // sortValue: null | ||
| 58 | - source: string = "" | ||
| 59 | - subObjectType: string = "" | ||
| 60 | - subSceneId: string = "" | ||
| 61 | - // tagIds: Array< unknown > | ||
| 62 | - // tagWord: null | ||
| 63 | - // titleShow: null | ||
| 64 | - // titleShowPolicy: null | ||
| 65 | - // topicTemplate: null | ||
| 66 | - traceId: string = "" | ||
| 67 | - traceInfo: string = "" | ||
| 68 | - // userInfo: null | ||
| 69 | - videoInfo: VideoInfo = new VideoInfo() | ||
| 70 | - visitorComment: number = -1 | ||
| 71 | - // voiceInfo: null | ||
| 72 | -} | ||
| 73 | - | ||
| 74 | -class FullColumnImgUrls{ | ||
| 75 | - // format: null | ||
| 76 | - fullUrl: string = "" | ||
| 77 | - height: number = -1 | ||
| 78 | - landscape: number = -1 | ||
| 79 | - size: number = -1 | ||
| 80 | - url: string = "" | ||
| 81 | - weight: number = -1 | ||
| 82 | -} | ||
| 83 | - | ||
| 84 | -class VideoInfo{ | ||
| 85 | - firstFrameImageUri: string = "" | ||
| 86 | - videoDuration: number = -1 | ||
| 87 | - videoLandscape: number = -1 | ||
| 88 | - videoUrl: string = "" | ||
| 89 | -} | ||
| 90 | - |
-
Please register or login to post a comment