Showing
3 changed files
with
22 additions
and
3 deletions
| 1 | import router from '@ohos.router' | 1 | import router from '@ohos.router' |
| 2 | -import { BreakpointSystem, NetworkUtil, StringUtils, ToastUtils } from 'wdKit' | 2 | +import { BreakpointSystem, DateTimeUtils, NetworkUtil, StringUtils, ToastUtils } from 'wdKit' |
| 3 | import { ParamType, TrackConstants, Tracking } from 'wdTracking/Index' | 3 | import { ParamType, TrackConstants, Tracking } from 'wdTracking/Index' |
| 4 | import SearcherAboutDataModel from '../../model/SearcherAboutDataModel' | 4 | import SearcherAboutDataModel from '../../model/SearcherAboutDataModel' |
| 5 | import { SearchHistoryItem } from '../../viewmodel/SearchHistoryItem' | 5 | import { SearchHistoryItem } from '../../viewmodel/SearchHistoryItem' |
| @@ -32,6 +32,7 @@ export struct SearchComponent { | @@ -32,6 +32,7 @@ export struct SearchComponent { | ||
| 32 | @State count:string[] = [] | 32 | @State count:string[] = [] |
| 33 | @State isGetRequest:boolean = false | 33 | @State isGetRequest:boolean = false |
| 34 | @Link fromTabName: string | 34 | @Link fromTabName: string |
| 35 | + @State sameSearch:number = 0 //再次搜索 | ||
| 35 | 36 | ||
| 36 | @StorageProp('currentBreakpoint') @Watch("currentChanged")currentBreakpoint: string = 'sm'; | 37 | @StorageProp('currentBreakpoint') @Watch("currentChanged")currentBreakpoint: string = 'sm'; |
| 37 | private breakpointSystem = new BreakpointSystem(); | 38 | private breakpointSystem = new BreakpointSystem(); |
| @@ -175,7 +176,7 @@ export struct SearchComponent { | @@ -175,7 +176,7 @@ export struct SearchComponent { | ||
| 175 | this.getSearchHistoryData() | 176 | this.getSearchHistoryData() |
| 176 | this.getSearchInputResData(this.searchText) | 177 | this.getSearchInputResData(this.searchText) |
| 177 | } | 178 | } |
| 178 | - },percent:this.percent}) | 179 | + },percent:this.percent,sameSearch:this.sameSearch}) |
| 179 | } else { | 180 | } else { |
| 180 | //联想搜索 | 181 | //联想搜索 |
| 181 | SearchRelatedComponent({relatedSearchContentData:$relatedSearchContentsData,onGetSearchRes: (item): void => this.getSearchRelatedResData(item),searchText:this.searchText,percent:this.percent}) | 182 | SearchRelatedComponent({relatedSearchContentData:$relatedSearchContentsData,onGetSearchRes: (item): void => this.getSearchRelatedResData(item),searchText:this.searchText,percent:this.percent}) |
| @@ -402,6 +403,7 @@ export struct SearchComponent { | @@ -402,6 +403,7 @@ export struct SearchComponent { | ||
| 402 | } | 403 | } |
| 403 | this.isGetRequest = true | 404 | this.isGetRequest = true |
| 404 | this.resetSearch() | 405 | this.resetSearch() |
| 406 | + this.sameSearch = DateTimeUtils.getTimeStamp() | ||
| 405 | }).catch((err: Error) => { | 407 | }).catch((err: Error) => { |
| 406 | console.log(TAG, JSON.stringify(err)) | 408 | console.log(TAG, JSON.stringify(err)) |
| 407 | this.isGetRequest = true | 409 | this.isGetRequest = true |
| @@ -29,6 +29,8 @@ export struct SearchResultComponent { | @@ -29,6 +29,8 @@ export struct SearchResultComponent { | ||
| 29 | onClickTryAgain?: () => void; | 29 | onClickTryAgain?: () => void; |
| 30 | @State isConnectNetwork : boolean = NetworkUtil.isNetConnected() | 30 | @State isConnectNetwork : boolean = NetworkUtil.isNetConnected() |
| 31 | @Prop percent:number = 1 | 31 | @Prop percent:number = 1 |
| 32 | + @Prop sameSearch:number = 0 | ||
| 33 | + | ||
| 32 | 34 | ||
| 33 | aboutToAppear(): void { | 35 | aboutToAppear(): void { |
| 34 | if (this.count.length === 0 && this.isGetRequest == true) { | 36 | if (this.count.length === 0 && this.isGetRequest == true) { |
| @@ -137,7 +139,7 @@ export struct SearchResultComponent { | @@ -137,7 +139,7 @@ export struct SearchResultComponent { | ||
| 137 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { | 139 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { |
| 138 | ForEach(this.count, (item: string, index: number) => { | 140 | ForEach(this.count, (item: string, index: number) => { |
| 139 | TabContent() { | 141 | TabContent() { |
| 140 | - SearchResultContentComponent({ keywords: this.searchText, searchType: item }) | 142 | + SearchResultContentComponent({ keywords: this.searchText, searchType: item ,sameSearch:this.sameSearch,isCurrentShow:this.currentIndex === index}) |
| 141 | }.tabBar(this.TabBuilder(index, item)) | 143 | }.tabBar(this.TabBuilder(index, item)) |
| 142 | .layoutWeight(1) | 144 | .layoutWeight(1) |
| 143 | }, (item: string, index: number) => index.toString()) | 145 | }, (item: string, index: number) => index.toString()) |
| @@ -51,7 +51,22 @@ export struct SearchResultContentComponent { | @@ -51,7 +51,22 @@ export struct SearchResultContentComponent { | ||
| 51 | @State moreWidth:number = 20 | 51 | @State moreWidth:number = 20 |
| 52 | @State listLeft: number = 0 | 52 | @State listLeft: number = 0 |
| 53 | @State isEnd: boolean = false | 53 | @State isEnd: boolean = false |
| 54 | + @Watch('updateData') @Prop sameSearch:number = 0 | ||
| 55 | + @Prop isCurrentShow:boolean = false; | ||
| 54 | 56 | ||
| 57 | + updateData(){ | ||
| 58 | + if(this.isCurrentShow){ | ||
| 59 | + this.data_rmh = [] | ||
| 60 | + | ||
| 61 | + this.data.clearAllData() | ||
| 62 | + | ||
| 63 | + this.curPageNum = 1 | ||
| 64 | + this.hasMore = true | ||
| 65 | + this.isLoading = false | ||
| 66 | + this.getNewSearchResultData() | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + } | ||
| 55 | 70 | ||
| 56 | aboutToAppear(): void { | 71 | aboutToAppear(): void { |
| 57 | if (this.searchType == "全部") { | 72 | if (this.searchType == "全部") { |
-
Please register or login to post a comment