Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
yangchenggong1_wd
2024-04-16 11:34:20 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
808b082e9e3fdd0490f7cf08ac4a6766612b2dd8
808b082e
2 parents
8bc141f3
d730ad5d
Merge branch 'feature_ycg2'
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
413 additions
and
33 deletions
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultContentComponent.ets
sight_harmony/features/wdComponent/src/main/ets/model/SearcherAboutDataModel.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/SearchResultContentItem.ets
sight_harmony/products/phone/src/main/resources/rawfile/search_result_list_data.json
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
View file @
808b082
...
...
@@ -217,6 +217,11 @@ export class HttpUrlUtils {
static readonly SEARCH_RESULT_COUNT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/count?keyword=";
/**
* 搜索结果 显示list 详情
*/
static readonly SEARCH_RESULT_LIST_DATA_PATH: string = "/api/rmrb-search-api/zh/c/search";
/**
* 早晚报列表
* 根据页面id获取页面楼层列表
* https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/pageInfo?pageId=28927
...
...
@@ -645,6 +650,11 @@ export class HttpUrlUtils {
return url
}
static getSearchResultListDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_RESULT_LIST_DATA_PATH
return url
}
// static getYcgCommonHeaders(): HashMap<string, string> {
// let headers: HashMap<string, string> = new HashMap<string, string>()
//
...
...
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchComponent.ets
View file @
808b082
...
...
@@ -128,7 +128,7 @@ export struct SearchComponent {
* @param content
*/
getSearchHistoryResData(content:string,index:number){
//删除单
挑
记录
//删除单
条
记录
SearcherAboutDataModel.delSearchSingleHistoryData(index)
this.isClickedHistory = true
this.searchResData(content)
...
...
@@ -149,33 +149,6 @@ export struct SearchComponent {
this.getSearchResultCountData()
}
getSearchResultCountData() {
SearcherAboutDataModel.getSearchResultCountData(encodeURI(this.searchText),getContext(this)).then((value) => {
if (value != null) {
this.count = []
if(value.allTotal!=0){
this.count.push("全部")
}
if(value.cmsTotal!=0){
this.count.push("精选")
}
if(value.rmhTotal!=0){
this.count.push("人民号")
}
if(value.videoTotal!=0){
this.count.push("视频")
}
if(value.activityTotal!=0){
this.count.push("活动")
}
}
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
}
/**
* 点击联想搜索列表回调
* @param content
...
...
@@ -291,4 +264,30 @@ export struct SearchComponent {
.padding({ left: '31lpx' })
.alignItems(VerticalAlign.Center)
}
getSearchResultCountData() {
SearcherAboutDataModel.getSearchResultCountData(encodeURI(this.searchText),getContext(this)).then((value) => {
if (value != null) {
this.count = []
if(value.allTotal!=0){
this.count.push("全部")
}
if(value.cmsTotal!=0){
this.count.push("精选")
}
if(value.rmhTotal!=0){
this.count.push("人民号")
}
if(value.videoTotal!=0){
this.count.push("视频")
}
if(value.activityTotal!=0){
this.count.push("活动")
}
}
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultComponent.ets
View file @
808b082
...
...
@@ -20,7 +20,7 @@ export struct SearchResultComponent{
Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
ForEach(this.count, (item: string, index: number ) => {
TabContent(){
SearchResultContentComponent()
SearchResultContentComponent(
{keywords:this.searchText,searchType:item}
)
}.tabBar(this.TabBuilder(index,item))
}, (item: string, index: number) => index.toString())
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultContentComponent.ets
View file @
808b082
import { ContentDTO, FullColumnImgUrlDTO, InteractDataDTO, RmhInfoDTO, VideoInfoDTO } from 'wdBean/Index'
import { LiveInfoDTO } from 'wdBean/src/main/ets/bean/detail/LiveInfoDTO'
import { VoiceInfoDTO } from 'wdBean/src/main/ets/bean/detail/VoiceInfoDTO'
import { LazyDataSource, StringUtils } from 'wdKit/Index'
import SearcherAboutDataModel from '../../model/SearcherAboutDataModel'
import { CardParser } from '../CardParser'
import { ListHasNoMoreDataUI } from '../reusable/ListHasNoMoreDataUI'
const TAG = "SearchResultContentComponent"
@Component
export struct SearchResultContentComponent{
@State keywords:string = ""
@State searchType:string = ""
@State data: LazyDataSource<ContentDTO> = new LazyDataSource();
@State count:number = 0;
@State isLoading:boolean = false
@State hasMore:boolean = true
curPageNum:number = 1;
aboutToAppear(): void {
if(this.searchType == "全部"){
this.searchType = "all"
}else if(this.searchType == "精选"){
this.searchType = "cms"
}else if(this.searchType == "人民号"){
this.searchType = "rmh"
}else if(this.searchType == "视频"){
this.searchType = "video"
}else if(this.searchType == "活动"){
this.searchType = "activity"
}
this.keywords = encodeURI(this.keywords)
this.getNewSearchResultData()
}
getNewSearchResultData(){
this.isLoading = true
if(this.hasMore){
SearcherAboutDataModel.getSearchResultListData("20",`${this.curPageNum}`,this.searchType,this.keywords,getContext(this)).then((value)=>{
if (!this.data || value.list.length == 0){
this.hasMore = false
}else{
value.list.forEach((value)=>{
let photos:FullColumnImgUrlDTO[] = []
if(value.data.appStyle === 4){
value.data.appStyleImages.split("&&").forEach((value)=>{
photos.push({url:value} as FullColumnImgUrlDTO)
})
}
//TODO 48 个赋值
let contentDTO:ContentDTO = {
appStyle:value.data.appStyle+"",
cityCode:value.data.cityCode,
coverSize:"",
coverType:-1,
coverUrl:value.data.appStyleImages.split("&&")[0],
description:value.data.description,
districtCode:value.data.districtCode,
endTime:value.data.endTime,
hImageUrl:"",
heatValue:"",
innerUrl:"",
landscape:Number.parseInt(value.data.landscape),
// lengthTime:null,
linkUrl:value.data.linkUrl,
openLikes:Number.parseInt(value.data.openLikes),
openUrl:"",
pageId:value.data.pageId,
programAuth:"",
programId:"",
programName:"",
programSource:-1,
programType:-1,
provinceCode:value.data.provinceCode,
showTitleEd:value.data.showTitleEd,
showTitleIng:value.data.showTitleIng,
showTitleNo:value.data.showTitleNo,
startTime:value.data.startTime,
subType:"",
subtitle:"",
title:value.data.title,
vImageUrl:"",
screenType:"",
source:StringUtils.isEmpty(value.data.creatorName)?value.data.sourceName:value.data.creatorName,
objectId:"",
objectType:value.data.type,
channelId:value.data.channelId,
relId:value.data.relId,
relType:value.data.relType,
newsTitle:value.data.titleLiteral,// 有颜色,目前没做
publishTime:value.data.publishTime,
visitorComment:-1,
fullColumnImgUrls:photos,
newsSummary:"",
hasMore:-1,
slideShows:[],
voiceInfo:{} as VoiceInfoDTO,
tagWord:-1,
isSelect:true,
rmhInfo:{} as RmhInfoDTO,
photoNum:-1,
liveInfo:{} as LiveInfoDTO,
videoInfo:{
videoDuration:Number.parseInt(value.data.duration)
} as VideoInfoDTO,
interactData:{} as InteractDataDTO
}
this.data.push(contentDTO)
})
this.data.notifyDataReload()
this.count = this.data.totalCount()
if (this.data.totalCount() < value.totalCount) {
this.curPageNum++
}else {
this.hasMore = false
}
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
})
}
this.isLoading = false
}
build() {
Column() {
if(this.count == 0){
ListHasNoMoreDataUI({style:2})
}else{
//List
List({ space: '6lpx' }) {
LazyForEach(this.data, (item: ContentDTO, index: number) => {
ListItem() {
CardParser({contentDTO:item})
}
.onClick(()=>{
//TODO 跳转
})
}, (item: ContentDTO, index: number) => index.toString())
//没有更多数据 显示提示
if(!this.hasMore){
ListItem(){
ListHasNoMoreDataUI()
}
}
}.cachedCount(4)
.scrollBar(BarState.Off)
.margin({top:'23lpx',left:'23lpx',right:'23lpx'})
.layoutWeight(1)
.onReachEnd(()=>{
console.log(TAG,"触底了");
if(!this.isLoading){
//加载分页数据
this.getNewSearchResultData()
}
})
}
}
.backgroundColor($r('app.color.white'))
.height('100%')
.width('100%')
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/model/SearcherAboutDataModel.ets
View file @
808b082
...
...
@@ -5,6 +5,7 @@ import HashMap from '@ohos.util.HashMap';
import { SearchHistoryItem } from '../viewmodel/SearchHistoryItem';
import { SearchHotContentItem } from '../viewmodel/SearchHotContentItem';
import { SearchResultCountItem } from '../viewmodel/SearchResultCountItem';
import { SearchResultContentData } from '../viewmodel/SearchResultContentData';
const TAG = "SearcherAboutDataModel"
...
...
@@ -35,6 +36,11 @@ class SearcherAboutDataModel{
public async putSearchHistoryData(content:string){
let history = SPHelper.default.getSync(this.SEARCH_HISTORY_KEY,"[]") as string
this.searchHistoryData = JSON.parse(history)
this.searchHistoryData.forEach((element,index) => {
if (element.searchContent == content) {
this.searchHistoryData.splice(index,1)
}
});
this.searchHistoryData.splice(0,0,new SearchHistoryItem(content))
await SPHelper.default.saveSync(this.SEARCH_HISTORY_KEY, JSON.stringify(this.searchHistoryData));
}
...
...
@@ -234,6 +240,45 @@ class SearcherAboutDataModel{
return compRes.data
}
/**
* 搜索结果 展示列表
*/
getSearchResultListData(pageSize:string,pageNum:string,searchType:string,keyword:string,context: Context): Promise<SearchResultContentData> {
return new Promise<SearchResultContentData>((success, error) => {
Logger.info(TAG, `getSearchResultListData start`);
this.fetchSearchResultListData(pageSize,pageNum,searchType,keyword).then((navResDTO: ResponseDTO<SearchResultContentData>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getSearchResultListDataLocal(context))
return
}
Logger.info(TAG, "getSearchResultListData then,SearchResultListResDTO.timeStamp:" + navResDTO.timestamp);
let navigationBean = navResDTO.data as SearchResultContentData
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `getSearchResultListData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getSearchResultListDataLocal(context))
})
})
}
fetchSearchResultListData(pageSize:string,pageNum:string,searchType:string,keyword:string) {
let url = HttpUrlUtils.getSearchResultListDataUrl() + `?pageSize=${pageSize}&pageNum=${pageNum}&searchType=${searchType}&keyword=${keyword}`
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<SearchResultContentData>>(url, headers)
};
async getSearchResultListDataLocal(context: Context): Promise<SearchResultContentData> {
Logger.info(TAG, `getSearchResultListDataLocal start`);
let compRes: ResponseDTO<SearchResultContentData> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<SearchResultContentData>>(context,'search_result_list_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getSearchResultListDataLocal compRes is empty`);
return new SearchResultContentData()
}
Logger.info(TAG, `getSearchResultListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
}
const searcherAboutDataModel = SearcherAboutDataModel.getInstance()
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/SearchResultContentItem.ets
View file @
808b082
import { ContentDTO } from 'wdBean/Index'
export interface SearchResultContentItem{
data:ContentDTO
resultType:string
export class SearchResultContentItem{
data:SearchDescription = new SearchDescription()
resultType:string = ""
}
class SearchDescription{
likeEnable: string = ""
previewUri: string = ""
firstFrameImageBucket: string = ""
appImg: string = ""
onlineStatus: string = ""
createUserName: string = ""
contentCheck: string = ""
type: string = ""
titleOsst: string = ""
coverHImageBucket: string = ""
shareImageUri: string = ""
searchTypeInt: string = ""
authIcon: string = ""
id: string = ""
newOld: string = ""
seoTags: string = ""
publishTime: string = ""
feedControl: string = ""
saveType: string = ""
userTypeInt: string = ""
userOrigin: string = ""
creatorType: string = ""
planStartTime: string = ""
waresSwitch: string = ""
introductionLiteral: string = ""
topicType: string = ""
hotFlag: string = ""
coverUrl: string = ""
itemId: string = ""
titleEn: string = ""
matrixId: string = ""
tplId: string = ""
joinActivity: string = ""
status: string = ""
headerPhotoUrl: string = ""
zhSearch: string = ""
activityControl: string = ""
city: string = ""
showTitleIng: string = ""
shareFlag: string = ""
creatorName: string = ""
className: string = ""
showTitleNo: string = ""
liveSwitch: string = ""
likesStyle: string = ""
dataKey: string = ""
search: string = ""
puserId: string = ""
top: string = ""
titleLiteral: string = ""
countryCode: string = ""
startTime: string = ""
shareDescription: string = ""
channelId: string = ""
openComment: string = ""
creatorClassify: string = ""
previewBucket: string = ""
picCount: string = ""
recommendControl: string = ""
creatorNameLiteral: string = ""
subjects: string = ""
updateUser: string = ""
i: string = ""
updateTime: string = ""
userId: string = ""
showTitleEd: string = ""
authTo: string = ""
rmhPlatformInt: string = ""
giftEnable: string = ""
titleEnosst: string = ""
shareCoverUrl: string = ""
deleted: string = ""
zhOperateFlag: string = ""
shareTitle: string = ""
scrollUpdated: string = ""
createTime: string = ""
creatorBan: string = ""
publishTimeInt: string = ""
organization: string = ""
channelName: string = ""
createUser: string = ""
currentPoliticsFlag: string = ""
endTime: string = ""
sourceId: string = ""
country: string = ""
secondClassify: string = ""
createUserId: string = ""
firstFrameImageUri: string = ""
pubTime: string = ""
openLikes: string = ""
contentText: string = ""
relType: string = ""
authImg: string = ""
roomId: string = ""
nameLiteral: string = ""
mainControl: string = ""
coverVImageBucket: string = ""
linkUrl: string = ""
openDownload: string = ""
zhChannelPageImg: string = ""
appStandImg: string = ""
shareSummary: string = ""
firstPublishTimeInt: string = ""
rmhPlatform: string = ""
creatorNameOsst: string = ""
searchType: string = ""
author: string = ""
askAnswerFlag: string = ""
seoTagName: string = ""
weight: string = ""
pageId: string = ""
firstPublishTime: string = ""
coverVImageUri: string = ""
publishType: string = ""
isVr: string = ""
name: string = ""
shareUrl: string = ""
userType: string = ""
firstProcessTime: string = ""
hasRecord: string = ""
shareTitleOsst: string = ""
classify: string = ""
itemType: string = ""
nameOsst: string = ""
districtCode: string = ""
hidden: string = ""
cityCode: string = ""
liveType: string = ""
appStyleImages: string = ""
titleShow: string = ""
cornerMark: string = ""
creatorId: string = ""
levelScore: string = ""
description: string = ""
liveStartTime: string = ""
likeStyle: string = ""
title: string = ""
content: string = ""
platform: string = ""
duration: string = "0"
shareDescriptionLiteral: string = ""
createTimeInt: string = ""
liveEndTime: string = ""
topicTemplate: string = ""
barrageEnable: string = ""
introduction: string = ""
notice: string = ""
shareTitleLiteral: string = ""
coverHImageUri: string = ""
relId: string = ""
classCode: string = ""
grayScale: string = ""
appStyle: number = -1
authTitle: string = ""
provinceCode: string = ""
tenancy: string = ""
platformId: string = ""
classSubName: string = ""
recommended: string = ""
descriptionLiteral: string = ""
banControl: string = ""
auditingStatus: string = ""
planEndTime: string = ""
speakControl: string = ""
sourceName: string = ""
shareImageBucket: string = ""
landscape: string = ""
}
\ No newline at end of file
...
...
sight_harmony/products/phone/src/main/resources/rawfile/search_result_list_data.json
0 → 100644
View file @
808b082
This diff could not be displayed because it is too large.
Please
register
or
login
to post a comment