Showing
8 changed files
with
181 additions
and
5 deletions
| @@ -185,12 +185,19 @@ export class HttpUrlUtils { | @@ -185,12 +185,19 @@ export class HttpUrlUtils { | ||
| 185 | * 搜索联想词 | 185 | * 搜索联想词 |
| 186 | */ | 186 | */ |
| 187 | static readonly RELATED_SEARCH_CONTENT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/suggestions/"; | 187 | static readonly RELATED_SEARCH_CONTENT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/suggestions/"; |
| 188 | + | ||
| 188 | /** | 189 | /** |
| 189 | * 直播详情 | 190 | * 直播详情 |
| 190 | */ | 191 | */ |
| 191 | static readonly LIVE_DETAILS_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail"; | 192 | static readonly LIVE_DETAILS_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail"; |
| 192 | 193 | ||
| 193 | /** | 194 | /** |
| 195 | + | ||
| 196 | + * 搜索结果 显示tab 数 | ||
| 197 | + */ | ||
| 198 | + static readonly SEARCH_RESULT_COUNT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/count?keyword="; | ||
| 199 | + | ||
| 200 | + /** | ||
| 194 | * 早晚报列表 | 201 | * 早晚报列表 |
| 195 | * 根据页面id获取页面楼层列表 | 202 | * 根据页面id获取页面楼层列表 |
| 196 | * https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/pageInfo?pageId=28927 | 203 | * https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/pageInfo?pageId=28927 |
| @@ -581,6 +588,11 @@ export class HttpUrlUtils { | @@ -581,6 +588,11 @@ export class HttpUrlUtils { | ||
| 581 | return url | 588 | return url |
| 582 | } | 589 | } |
| 583 | 590 | ||
| 591 | + static getSearchResultCountDataUrl() { | ||
| 592 | + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_RESULT_COUNT_DATA_PATH | ||
| 593 | + return url | ||
| 594 | + } | ||
| 595 | + | ||
| 584 | // static getYcgCommonHeaders(): HashMap<string, string> { | 596 | // static getYcgCommonHeaders(): HashMap<string, string> { |
| 585 | // let headers: HashMap<string, string> = new HashMap<string, string>() | 597 | // let headers: HashMap<string, string> = new HashMap<string, string>() |
| 586 | // | 598 | // |
sight_harmony/features/wdComponent/src/main/ets/components/mine/follow/FollowSecondTabsComponent.ets
| @@ -53,6 +53,7 @@ export struct FollowSecondTabsComponent{ | @@ -53,6 +53,7 @@ export struct FollowSecondTabsComponent{ | ||
| 53 | .width('100%') | 53 | .width('100%') |
| 54 | }.width('100%') | 54 | }.width('100%') |
| 55 | .alignItems(VerticalAlign.Top) | 55 | .alignItems(VerticalAlign.Top) |
| 56 | + .backgroundColor('#0FF') | ||
| 56 | } | 57 | } |
| 57 | 58 | ||
| 58 | @Builder TabBuilder(index: number, item: FollowSecondListItem) { | 59 | @Builder TabBuilder(index: number, item: FollowSecondListItem) { |
| @@ -6,6 +6,7 @@ import { SearchRelatedItem } from '../../viewmodel/SearchRelatedItem' | @@ -6,6 +6,7 @@ import { SearchRelatedItem } from '../../viewmodel/SearchRelatedItem' | ||
| 6 | import { SearchHistoryComponent } from './SearchHistoryComponent' | 6 | import { SearchHistoryComponent } from './SearchHistoryComponent' |
| 7 | import { SearchHotsComponent } from './SearchHotsComponent' | 7 | import { SearchHotsComponent } from './SearchHotsComponent' |
| 8 | import { SearchRelatedComponent } from './SearchRelatedComponent' | 8 | import { SearchRelatedComponent } from './SearchRelatedComponent' |
| 9 | +import { SearchResultComponent } from './SearchResultComponent' | ||
| 9 | 10 | ||
| 10 | const TAG = "SearchComponent" | 11 | const TAG = "SearchComponent" |
| 11 | 12 | ||
| @@ -23,6 +24,7 @@ export struct SearchComponent { | @@ -23,6 +24,7 @@ export struct SearchComponent { | ||
| 23 | @State searchHistoryData: SearchHistoryItem[] = [] | 24 | @State searchHistoryData: SearchHistoryItem[] = [] |
| 24 | @State relatedSearchContentsData: SearchRelatedItem[] = [] | 25 | @State relatedSearchContentsData: SearchRelatedItem[] = [] |
| 25 | scroller: Scroller = new Scroller() | 26 | scroller: Scroller = new Scroller() |
| 27 | + @State count:string[] = [] | ||
| 26 | 28 | ||
| 27 | aboutToAppear() { | 29 | aboutToAppear() { |
| 28 | //获取提示滚动 | 30 | //获取提示滚动 |
| @@ -110,9 +112,7 @@ export struct SearchComponent { | @@ -110,9 +112,7 @@ export struct SearchComponent { | ||
| 110 | } else { | 112 | } else { |
| 111 | if (this.hasChooseSearch) { | 113 | if (this.hasChooseSearch) { |
| 112 | //搜索结果 | 114 | //搜索结果 |
| 113 | - | ||
| 114 | - //搜索结果为null(空布局 + 为你推荐) | ||
| 115 | - | 115 | + SearchResultComponent({count:this.count,searchText:this.searchText}) |
| 116 | } else { | 116 | } else { |
| 117 | //联想搜索 | 117 | //联想搜索 |
| 118 | SearchRelatedComponent({relatedSearchContentData:$relatedSearchContentsData,onGetSearchRes: (item): void => this.getSearchRelatedResData(item),searchText:this.searchText}) | 118 | SearchRelatedComponent({relatedSearchContentData:$relatedSearchContentsData,onGetSearchRes: (item): void => this.getSearchRelatedResData(item),searchText:this.searchText}) |
| @@ -145,10 +145,37 @@ export struct SearchComponent { | @@ -145,10 +145,37 @@ export struct SearchComponent { | ||
| 145 | this.relatedSearchContentsData = [] | 145 | this.relatedSearchContentsData = [] |
| 146 | 146 | ||
| 147 | //查询 操作 TODO | 147 | //查询 操作 TODO |
| 148 | + this.hasChooseSearch = true | ||
| 149 | + this.getSearchResultCountData() | ||
| 150 | + } | ||
| 148 | 151 | ||
| 152 | + getSearchResultCountData() { | ||
| 153 | + SearcherAboutDataModel.getSearchResultCountData(encodeURI(this.searchText),getContext(this)).then((value) => { | ||
| 154 | + if (value != null) { | ||
| 155 | + this.count = [] | ||
| 156 | + if(value.allTotal!=0){ | ||
| 157 | + this.count.push("全部") | ||
| 158 | + } | ||
| 159 | + if(value.cmsTotal!=0){ | ||
| 160 | + this.count.push("精选") | ||
| 161 | + } | ||
| 162 | + if(value.rmhTotal!=0){ | ||
| 163 | + this.count.push("人民号") | ||
| 164 | + } | ||
| 165 | + if(value.videoTotal!=0){ | ||
| 166 | + this.count.push("视频") | ||
| 167 | + } | ||
| 168 | + if(value.activityTotal!=0){ | ||
| 169 | + this.count.push("活动") | ||
| 170 | + } | ||
| 171 | + } | ||
| 172 | + }).catch((err: Error) => { | ||
| 173 | + console.log(TAG, JSON.stringify(err)) | ||
| 174 | + }) | ||
| 149 | } | 175 | } |
| 150 | 176 | ||
| 151 | 177 | ||
| 178 | + | ||
| 152 | /** | 179 | /** |
| 153 | * 点击联想搜索列表回调 | 180 | * 点击联想搜索列表回调 |
| 154 | * @param content | 181 | * @param content |
| @@ -227,6 +254,7 @@ export struct SearchComponent { | @@ -227,6 +254,7 @@ export struct SearchComponent { | ||
| 227 | .onClick(()=>{ | 254 | .onClick(()=>{ |
| 228 | this.searchText = "" | 255 | this.searchText = "" |
| 229 | this.hasInputContent = false | 256 | this.hasInputContent = false |
| 257 | + this.hasChooseSearch = false | ||
| 230 | }) | 258 | }) |
| 231 | } | 259 | } |
| 232 | }.padding({right:'30lpx'}) | 260 | }.padding({right:'30lpx'}) |
| 1 | -import SearcherAboutDataModel from '../../model/SearcherAboutDataModel' | ||
| 2 | -import { SearchHotContentItem } from '../../viewmodel/SearchHotContentItem' | ||
| 3 | import { SearchRelatedItem } from '../../viewmodel/SearchRelatedItem' | 1 | import { SearchRelatedItem } from '../../viewmodel/SearchRelatedItem' |
| 4 | 2 | ||
| 5 | const TAG = "SearchRelatedComponent" | 3 | const TAG = "SearchRelatedComponent" |
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultComponent.ets
0 → 100644
| 1 | + | ||
| 2 | +const TAG = "SearchResultComponent" | ||
| 3 | +/** | ||
| 4 | + * 搜索结果 | ||
| 5 | + * 搜索结果为null(空布局 + 为你推荐) | ||
| 6 | + */ | ||
| 7 | +@Component | ||
| 8 | +export struct SearchResultComponent{ | ||
| 9 | + @Prop count:string[] = [] | ||
| 10 | + @Prop searchText: string | ||
| 11 | + | ||
| 12 | + @State currentIndex: number = 0 | ||
| 13 | + private controller: TabsController = new TabsController() | ||
| 14 | + fontColor: string = '#999999' | ||
| 15 | + selectedFontColor: string = '#000000' | ||
| 16 | + | ||
| 17 | + build() { | ||
| 18 | + Column() { | ||
| 19 | + Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { | ||
| 20 | + ForEach(this.count, (item: string, index: number ) => { | ||
| 21 | + TabContent(){ | ||
| 22 | + Text(item) | ||
| 23 | + }.tabBar(this.TabBuilder(index,item)) | ||
| 24 | + }, (item: string, index: number) => index.toString()) | ||
| 25 | + } | ||
| 26 | + .vertical(false) | ||
| 27 | + .barMode(BarMode.Fixed) | ||
| 28 | + .barWidth('100%') | ||
| 29 | + .barHeight('84lpx') | ||
| 30 | + .animationDuration(0) | ||
| 31 | + .onChange((index: number) => { | ||
| 32 | + this.currentIndex = index | ||
| 33 | + }) | ||
| 34 | + .width('100%') | ||
| 35 | + .layoutWeight(1) | ||
| 36 | + }.width('100%') | ||
| 37 | + .margin({ top: '12lpx' }) | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + @Builder TabBuilder(index: number, item: string) { | ||
| 41 | + Stack(){ | ||
| 42 | + Text(item) | ||
| 43 | + .height('38lpx') | ||
| 44 | + .fontSize('33lpx') | ||
| 45 | + .fontWeight(this.currentIndex === index ? 600 : 400) | ||
| 46 | + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) | ||
| 47 | + .lineHeight('38lpx') | ||
| 48 | + | ||
| 49 | + if(this.currentIndex === index){ | ||
| 50 | + Divider() | ||
| 51 | + .width('31lpx') | ||
| 52 | + .height('4lpx') | ||
| 53 | + .color('#ED2800') | ||
| 54 | + .strokeWidth('4lpx') | ||
| 55 | + .margin({top:'50lpx'}) | ||
| 56 | + .id("divTag") | ||
| 57 | + } | ||
| 58 | + }.onClick(()=>{ | ||
| 59 | + this.currentIndex = index | ||
| 60 | + this.controller.changeIndex(this.currentIndex) | ||
| 61 | + }) | ||
| 62 | + .height('100%') | ||
| 63 | + .margin({right:'9lpx'}) | ||
| 64 | + .padding({left:'31lpx',right:index === this.count.length-1?"31lpx":"0lpx"}) | ||
| 65 | + } | ||
| 66 | +} |
| @@ -4,6 +4,7 @@ import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; | @@ -4,6 +4,7 @@ import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; | ||
| 4 | import HashMap from '@ohos.util.HashMap'; | 4 | import HashMap from '@ohos.util.HashMap'; |
| 5 | import { SearchHistoryItem } from '../viewmodel/SearchHistoryItem'; | 5 | import { SearchHistoryItem } from '../viewmodel/SearchHistoryItem'; |
| 6 | import { SearchHotContentItem } from '../viewmodel/SearchHotContentItem'; | 6 | import { SearchHotContentItem } from '../viewmodel/SearchHotContentItem'; |
| 7 | +import { SearchResultCountItem } from '../viewmodel/SearchResultCountItem'; | ||
| 7 | 8 | ||
| 8 | const TAG = "SearcherAboutDataModel" | 9 | const TAG = "SearcherAboutDataModel" |
| 9 | 10 | ||
| @@ -195,6 +196,43 @@ class SearcherAboutDataModel{ | @@ -195,6 +196,43 @@ class SearcherAboutDataModel{ | ||
| 195 | return compRes.data | 196 | return compRes.data |
| 196 | } | 197 | } |
| 197 | 198 | ||
| 199 | + /** | ||
| 200 | + * 搜索结果 展示tab数量 | ||
| 201 | + */ | ||
| 202 | + getSearchResultCountData(keyword:string,context: Context): Promise<SearchResultCountItem> { | ||
| 203 | + return new Promise<SearchResultCountItem>((success, error) => { | ||
| 204 | + Logger.info(TAG, `getSearchResultCountData start`); | ||
| 205 | + this.fetchSearchResultCountData(keyword).then((navResDTO: ResponseDTO<SearchResultCountItem>) => { | ||
| 206 | + if (!navResDTO || navResDTO.code != 0) { | ||
| 207 | + success(this.getSearchResultCountDataLocal(context)) | ||
| 208 | + return | ||
| 209 | + } | ||
| 210 | + Logger.info(TAG, "getSearchResultCountData then,SearchHintDataResDTO.timeStamp:" + navResDTO.timestamp); | ||
| 211 | + let navigationBean = navResDTO.data as SearchResultCountItem | ||
| 212 | + success(navigationBean); | ||
| 213 | + }).catch((err: Error) => { | ||
| 214 | + Logger.error(TAG, `getSearchResultCountData catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 215 | + success(this.getSearchResultCountDataLocal(context)) | ||
| 216 | + }) | ||
| 217 | + }) | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + fetchSearchResultCountData(keyword:string) { | ||
| 221 | + let url = HttpUrlUtils.getSearchResultCountDataUrl() + keyword | ||
| 222 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 223 | + return WDHttp.get<ResponseDTO<SearchResultCountItem>>(url, headers) | ||
| 224 | + }; | ||
| 225 | + | ||
| 226 | + async getSearchResultCountDataLocal(context: Context): Promise<SearchResultCountItem> { | ||
| 227 | + Logger.info(TAG, `getSearchResultCountDataLocal start`); | ||
| 228 | + let compRes: ResponseDTO<SearchResultCountItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<SearchResultCountItem>>(context,'search_result_count_data.json' ); | ||
| 229 | + if (!compRes || !compRes.data) { | ||
| 230 | + Logger.info(TAG, `getSearchResultCountDataLocal compRes is empty`); | ||
| 231 | + return new SearchResultCountItem() | ||
| 232 | + } | ||
| 233 | + Logger.info(TAG, `getSearchResultCountDataLocal compRes : ${JSON.stringify(compRes)}`); | ||
| 234 | + return compRes.data | ||
| 235 | + } | ||
| 198 | 236 | ||
| 199 | } | 237 | } |
| 200 | 238 |
| 1 | +{ | ||
| 2 | + "code": "0", | ||
| 3 | + "data": { | ||
| 4 | + "activityTotal": 0, | ||
| 5 | + "allTotal": 2791778, | ||
| 6 | + "cmsTotal": 240407, | ||
| 7 | + "keyword": "大家", | ||
| 8 | + "pageNum": 1, | ||
| 9 | + "pageSize": 1, | ||
| 10 | + "rmhTotal": 2551290, | ||
| 11 | + "totalCount": 0, | ||
| 12 | + "trueTotal": 0, | ||
| 13 | + "videoTotal": 16775 | ||
| 14 | + }, | ||
| 15 | + "message": "Success", | ||
| 16 | + "success": true, | ||
| 17 | + "timestamp": 1712889165817 | ||
| 18 | +} |
-
Please register or login to post a comment