Showing
1 changed file
with
16 additions
and
5 deletions
| 1 | import router from '@ohos.router' | 1 | import router from '@ohos.router' |
| 2 | -import { StringUtils, ToastUtils } from 'wdKit' | 2 | +import { NetworkUtil, StringUtils, ToastUtils } from 'wdKit' |
| 3 | import SearcherAboutDataModel from '../../model/SearcherAboutDataModel' | 3 | import SearcherAboutDataModel from '../../model/SearcherAboutDataModel' |
| 4 | import { SearchHistoryItem } from '../../viewmodel/SearchHistoryItem' | 4 | import { SearchHistoryItem } from '../../viewmodel/SearchHistoryItem' |
| 5 | import { SearchRelatedItem } from '../../viewmodel/SearchRelatedItem' | 5 | import { SearchRelatedItem } from '../../viewmodel/SearchRelatedItem' |
| 6 | +import { EmptyComponent } from '../view/EmptyComponent' | ||
| 6 | import { SearchHistoryComponent } from './SearchHistoryComponent' | 7 | import { SearchHistoryComponent } from './SearchHistoryComponent' |
| 7 | import { SearchHotsComponent } from './SearchHotsComponent' | 8 | import { SearchHotsComponent } from './SearchHotsComponent' |
| 8 | import { SearchRelatedComponent } from './SearchRelatedComponent' | 9 | import { SearchRelatedComponent } from './SearchRelatedComponent' |
| @@ -30,6 +31,7 @@ export struct SearchComponent { | @@ -30,6 +31,7 @@ export struct SearchComponent { | ||
| 30 | scroller: Scroller = new Scroller() | 31 | scroller: Scroller = new Scroller() |
| 31 | @State count:string[] = [] | 32 | @State count:string[] = [] |
| 32 | @State isGetRequest:boolean = false; | 33 | @State isGetRequest:boolean = false; |
| 34 | + @State isConnectNetwork : boolean = NetworkUtil.isNetConnected() | ||
| 33 | 35 | ||
| 34 | aboutToAppear() { | 36 | aboutToAppear() { |
| 35 | //获取提示滚动 | 37 | //获取提示滚动 |
| @@ -127,8 +129,16 @@ export struct SearchComponent { | @@ -127,8 +129,16 @@ export struct SearchComponent { | ||
| 127 | .padding({ left: '31lpx', right: '31lpx' }) | 129 | .padding({ left: '31lpx', right: '31lpx' }) |
| 128 | } else { | 130 | } else { |
| 129 | if (this.hasChooseSearch) { | 131 | if (this.hasChooseSearch) { |
| 130 | - //搜索结果 | ||
| 131 | - SearchResultComponent({count:this.count,searchText:this.searchText,isGetRequest:this.isGetRequest}) | 132 | + if(!this.isConnectNetwork){ |
| 133 | + EmptyComponent({ emptyType: 1,emptyHeight:"100%" ,retry: () => { | ||
| 134 | + this.getSearchInputResData(this.searchText) | ||
| 135 | + }}) | ||
| 136 | + .layoutWeight(1) | ||
| 137 | + .width('100%') | ||
| 138 | + }else{ | ||
| 139 | + //搜索结果 | ||
| 140 | + SearchResultComponent({count:this.count,searchText:this.searchText,isGetRequest:this.isGetRequest}) | ||
| 141 | + } | ||
| 132 | } else { | 142 | } else { |
| 133 | //联想搜索 | 143 | //联想搜索 |
| 134 | SearchRelatedComponent({relatedSearchContentData:$relatedSearchContentsData,onGetSearchRes: (item): void => this.getSearchRelatedResData(item),searchText:this.searchText}) | 144 | SearchRelatedComponent({relatedSearchContentData:$relatedSearchContentsData,onGetSearchRes: (item): void => this.getSearchRelatedResData(item),searchText:this.searchText}) |
| @@ -138,7 +148,6 @@ export struct SearchComponent { | @@ -138,7 +148,6 @@ export struct SearchComponent { | ||
| 138 | .width('100%') | 148 | .width('100%') |
| 139 | } | 149 | } |
| 140 | 150 | ||
| 141 | - | ||
| 142 | /** | 151 | /** |
| 143 | * 点击搜索记录列表回调 | 152 | * 点击搜索记录列表回调 |
| 144 | * @param content | 153 | * @param content |
| @@ -329,11 +338,13 @@ export struct SearchComponent { | @@ -329,11 +338,13 @@ export struct SearchComponent { | ||
| 329 | // } | 338 | // } |
| 330 | } | 339 | } |
| 331 | this.isGetRequest = true | 340 | this.isGetRequest = true |
| 332 | - this.resetSearch() | 341 | + this.resetSearch() |
| 342 | + this.isConnectNetwork = NetworkUtil.isNetConnected() | ||
| 333 | }).catch((err: Error) => { | 343 | }).catch((err: Error) => { |
| 334 | console.log(TAG, JSON.stringify(err)) | 344 | console.log(TAG, JSON.stringify(err)) |
| 335 | this.isGetRequest = true | 345 | this.isGetRequest = true |
| 336 | this.resetSearch() | 346 | this.resetSearch() |
| 347 | + this.isConnectNetwork = NetworkUtil.isNetConnected() | ||
| 337 | }) | 348 | }) |
| 338 | } | 349 | } |
| 339 | 350 |
-
Please register or login to post a comment