yangchenggong1_wd

desc:搜索推荐跳转

... ... @@ -25,6 +25,7 @@ export struct SearchComponent {
@State relatedSearchContentsData: SearchRelatedItem[] = []
scroller: Scroller = new Scroller()
@State count:string[] = []
@State isGetRequest:boolean = false;
aboutToAppear() {
//获取提示滚动
... ... @@ -112,7 +113,7 @@ export struct SearchComponent {
} else {
if (this.hasChooseSearch) {
//搜索结果
SearchResultComponent({count:this.count,searchText:this.searchText,isInit:true})
SearchResultComponent({count:this.count,searchText:this.searchText,isGetRequest:this.isGetRequest})
} else {
//联想搜索
SearchRelatedComponent({relatedSearchContentData:$relatedSearchContentsData,onGetSearchRes: (item): void => this.getSearchRelatedResData(item),searchText:this.searchText})
... ... @@ -287,8 +288,10 @@ export struct SearchComponent {
this.count.push("活动")
}
}
this.isGetRequest = true
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
this.isGetRequest = true
})
}
}
\ No newline at end of file
... ...
... ... @@ -17,7 +17,7 @@ const TAG = "SearchResultComponent"
export struct SearchResultComponent {
@Prop count: string[]
@Prop searchText: string
@State isInit:boolean = false;
@Prop isGetRequest:boolean = false;
@State currentIndex: number = 0
private controller: TabsController = new TabsController()
fontColor: string = '#999999'
... ... @@ -28,7 +28,7 @@ export struct SearchResultComponent {
scroller: Scroller = new Scroller()
aboutToAppear(): void {
if (this.count.length === 0 && this.isInit == true) {
if (this.count.length === 0 && this.isGetRequest == true) {
this.getSuggestData()
}
}
... ... @@ -40,18 +40,7 @@ export struct SearchResultComponent {
SearcherAboutDataModel.getSearchSuggestData(request, getContext(this)).then((value) => {
value.forEach((item) => {
this.data.push({
appStyle: item.appStyle,
channelId: item.channelId + "",
coverType: item.coverType,
coverUrl: item.coverUrl,
newsTitle: item.newsTitle,
objectId: item.objectId,
publishTime: item.publishTime,
relId: item.relId + "",
relType: item.relType + "",
source: item.source,
} as ContentDTO)
this.data.push(item)
})
this.data.notifyDataReload()
this.suggest_count = this.data.totalCount()
... ... @@ -61,7 +50,7 @@ export struct SearchResultComponent {
build() {
Column() {
if (this.count != null && this.count.length === 0 && this.isInit == true) {
if (this.count != null && this.count.length === 0 && this.isGetRequest == true) {
List() {
ListItem() {
//缺省图
... ...
... ... @@ -6,10 +6,9 @@ import { SearchHistoryItem } from '../viewmodel/SearchHistoryItem';
import { SearchHotContentItem } from '../viewmodel/SearchHotContentItem';
import { SearchResultCountItem } from '../viewmodel/SearchResultCountItem';
import { SearchResultContentData } from '../viewmodel/SearchResultContentData';
import { contentListParams, InteractDataDTO } from 'wdBean/Index';
import { ContentDTO, contentListParams, InteractDataDTO } from 'wdBean/Index';
import { CreatorDetailRequestItem } from '../viewmodel/CreatorDetailRequestItem';
import { CreatorDetailResponseItem } from '../viewmodel/CreatorDetailResponseItem';
import { SearchSuggestData } from '../viewmodel/SearchSuggestData';
import { SearchSuggestRequestItem } from '../viewmodel/SearchSuggestRequestItem';
const TAG = "SearcherAboutDataModel"
... ... @@ -354,17 +353,17 @@ class SearcherAboutDataModel{
/**
* 搜索推荐 展示列表
*/
getSearchSuggestData(object:SearchSuggestRequestItem,context: Context): Promise<SearchSuggestData[]> {
return new Promise<SearchSuggestData[]>((success, error) => {
getSearchSuggestData(object:SearchSuggestRequestItem,context: Context): Promise<ContentDTO[]> {
return new Promise<ContentDTO[]>((success, error) => {
Logger.info(TAG, `getSearchSuggestData start`);
this.fetchSearchSuggestData(object).then((navResDTO: ResponseDTO<SearchSuggestData[]>) => {
this.fetchSearchSuggestData(object).then((navResDTO: ResponseDTO<ContentDTO[]>) => {
if (!navResDTO || navResDTO.code != 0 /*|| navResDTO.data == null*/) {
// success(this.getSearchSuggestDataLocal(context))
success([])
return
}
Logger.info(TAG, "getSearchSuggestData then,SearchResultListResDTO.timeStamp:" + navResDTO.timestamp);
let navigationBean = navResDTO.data as SearchSuggestData[]
let navigationBean = navResDTO.data as ContentDTO[]
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `getSearchSuggestData catch, error.name : ${err.name}, error.message:${err.message}`);
... ... @@ -377,12 +376,12 @@ class SearcherAboutDataModel{
fetchSearchSuggestData(object:SearchSuggestRequestItem) {
let url = HttpUrlUtils.getSearchSuggestDataUrl()
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post<ResponseDTO<SearchSuggestData[]>>(url,object, headers)
return WDHttp.post<ResponseDTO<ContentDTO[]>>(url,object, headers)
};
async getSearchSuggestDataLocal(context: Context): Promise<SearchSuggestData[]> {
async getSearchSuggestDataLocal(context: Context): Promise<ContentDTO[]> {
Logger.info(TAG, `getInteractListDataLocal start`);
let compRes: ResponseDTO<SearchSuggestData[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<SearchSuggestData[]>>(context,'search_suggest_data.json' );
let compRes: ResponseDTO<ContentDTO[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<ContentDTO[]>>(context,'search_suggest_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getInteractListDataLocal compRes is empty`);
return []
... ...
@Observed
export class SearchSuggestData{
// activityExt: null
appStyle: string = ""
// askInfo: null
axisColor: string = ""
// bestNoticer: null
// bottomNavId: null
cardItemId: string = ""
channelId: number = -1
// commentInfo: null
corner: string = ""
coverSize: string = ""
coverType: number = -1
coverUrl: string = ""
expIds: string = ""
extra: string = ""
fullColumnImgUrls: Array<FullColumnImgUrls> = []
// hasMore: null
itemId: string = ""
itemType: string = ""
itemTypeCode: string = ""
keyArticle: number = -1
// landscape: null
// likeStyle: null
linkUrl: string = ""
// liveInfo: null
menuShow: number = -1
newTags: string = ""
newsAuthor: string = ""
newsSubTitle: string = ""
newsSummary: string = ""
newsTitle: string = ""
newsTitleColor: string = ""
objectId: string = ""
objectLevel: string = ""
objectType: string = ""
// openComment: null
// openLikes: null
pageId: string = ""
// photoNum: null
// position: null
// productNum: null
publishTime: string = ""
// pushTime: null
// pushUnqueId: null
readFlag: number = -1
recommend: number = -1
relId: number = -1
relObjectId: string = ""
relType: number = -1
// rmhInfo: null
rmhPlatform: number = -1
sceneId: string = ""
// shareInfo: null
// slideShows: Array< unknown >
// sortValue: null
source: string = ""
subObjectType: string = ""
subSceneId: string = ""
// tagIds: Array< unknown >
// tagWord: null
// titleShow: null
// titleShowPolicy: null
// topicTemplate: null
traceId: string = ""
traceInfo: string = ""
// userInfo: null
videoInfo: VideoInfo = new VideoInfo()
visitorComment: number = -1
// voiceInfo: null
}
class FullColumnImgUrls{
// format: null
fullUrl: string = ""
height: number = -1
landscape: number = -1
size: number = -1
url: string = ""
weight: number = -1
}
class VideoInfo{
firstFrameImageUri: string = ""
videoDuration: number = -1
videoLandscape: number = -1
videoUrl: string = ""
}