From e794ed885a75be8ab5c789c2ea8db902ce338b0b Mon Sep 17 00:00:00 2001 From: wwf <1971391498@qq.com> Date: 星期三, 08 十月 2025 00:01:17 +0800 Subject: [PATCH] 完善功能 --- entry/src/main/ets/pages/search/SearchPage.ets | 237 +++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 165 insertions(+), 72 deletions(-) diff --git a/entry/src/main/ets/pages/search/SearchPage.ets b/entry/src/main/ets/pages/search/SearchPage.ets index 408cf26..6ceb8d4 100644 --- a/entry/src/main/ets/pages/search/SearchPage.ets +++ b/entry/src/main/ets/pages/search/SearchPage.ets @@ -1,82 +1,175 @@ -import { AxiosResponse } from "@ohos/axios" -import { NewsBase, NewsBaseData } from "../../data/NewsBase" -import { TextBase } from "../../data/TextBase" -import { NewsApi, TextApi } from "../../http/AxiosAPI" +import { IconType } from "@kit.ArkUI" + +class JobItem { + title: string = '' + payment: string = '' + tagList: string[] = [] + company: string = '' + address: string = '' + detail: string = '' +} @Entry @Component export struct SearchPage { - //鍙橀噺鎵胯浇鏂伴椈鏁版嵁 - @State newsBase: NewsBase = new NewsBase() - @State TextData: TextBase = new TextBase() - async aboutToAppear() { - let newsData:NewsBase = await NewsApi() - this.newsBase = newsData - let textData:TextBase = await TextApi() - this.TextData = textData - console.info('textData ' + JSON.stringify(textData)) - } - build() { - Column() { - Column(){ - Text(JSON.stringify(this.TextData.text)) - .fontWeight(700) - .fontSize(20) + @State jobList: JobItem[] = [ + { title: '楂樼骇鍓嶇寮�鍙戝伐绋嬪笀锛圴ue3+TS鏂瑰悜锛�', payment: '25k-40k 路 14钖�', tagList: ['1-3骞�', '鏈鍙婁互涓�'], company: '浜戣垝鎶�鏈湁闄愬叕鍙�', address: '娣卞湷甯� 鍗楀北鍖� 铔囧彛', detail: '' }, + { title: '楂樼骇鍓嶇寮�鍙戝伐绋嬪笀锛圴ue3+TS鏂瑰悜锛�', payment: '25k-40k 路 14钖�', tagList: ['1-3骞�', '鏈鍙婁互涓�'], company: '浜戣垝鎶�鏈湁闄愬叕鍙�', address: '娣卞湷甯� 鍗楀北鍖� 铔囧彛', detail: '' }, + { title: '楂樼骇鍓嶇寮�鍙戝伐绋嬪笀锛圴ue3+TS鏂瑰悜锛�', payment: '25k 路 14钖�', tagList: ['1-3骞�', '鏈鍙婁互涓�'], company: '浜戣垝鎶�鏈湁闄愬叕鍙�', address: '娣卞湷甯� 鍗楀北鍖� 铔囧彛', detail: '' }, + { title: '楂樼骇鍓嶇寮�鍙戝伐绋嬪笀锛圴ue3+TS鏂瑰悜锛�', payment: '25k 路 14钖�', tagList: ['1-3骞�', '鏈鍙婁互涓�'], company: '浜戣垝鎶�鏈湁闄愬叕鍙�', address: '娣卞湷甯� 鍗楀北鍖� 铔囧彛', detail: '' }, + { title: '楂樼骇鍓嶇寮�鍙戝伐绋嬪笀锛圴ue3+TS鏂瑰悜锛�', payment: '25k 路 14钖�', tagList: ['1-3骞�', '鏈鍙婁互涓�'], company: '浜戣垝鎶�鏈湁闄愬叕鍙�', address: '娣卞湷甯� 鍗楀北鍖� 铔囧彛', detail: '' }, + { title: '楂樼骇鍓嶇寮�鍙戝伐绋嬪笀锛圴ue3+TS鏂瑰悜锛�', payment: '25k 路 14钖�', tagList: ['1-3骞�', '鏈鍙婁互涓�'], company: '浜戣垝鎶�鏈湁闄愬叕鍙�', address: '娣卞湷甯� 鍗楀北鍖� 铔囧彛', detail: '' }, + { title: '楂樼骇鍓嶇寮�鍙戝伐绋嬪笀锛圴ue3+TS鏂瑰悜锛�', payment: '25k 路 14钖�', tagList: ['1-3骞�', '鏈鍙婁互涓�'], company: '浜戣垝鎶�鏈湁闄愬叕鍙�', address: '娣卞湷甯� 鍗楀北鍖� 铔囧彛', detail: '' }, + { title: '楂樼骇鍓嶇寮�鍙戝伐绋嬪笀锛圴ue3+TS鏂瑰悜锛�', payment: '25k 路 14钖�', tagList: ['1-3骞�', '鏈鍙婁互涓�'], company: '浜戣垝鎶�鏈湁闄愬叕鍙�', address: '娣卞湷甯� 鍗楀北鍖� 铔囧彛', detail: '' }, + { title: '楂樼骇鍓嶇寮�鍙戝伐绋嬪笀锛圴ue3+TS鏂瑰悜锛�', payment: '25k 路 14钖�', tagList: ['1-3骞�', '鏈鍙婁互涓�'], company: '浜戣垝鎶�鏈湁闄愬叕鍙�', address: '娣卞湷甯� 鍗楀北鍖� 铔囧彛', detail: '' }, + { title: '楂樼骇鍓嶇寮�鍙戝伐绋嬪笀锛圴ue3+TS鏂瑰悜锛�', payment: '25k 路 14钖�', tagList: ['1-3骞�', '鏈鍙婁互涓�'], company: '浜戣垝鎶�鏈湁闄愬叕鍙�', address: '娣卞湷甯� 鍗楀北鍖� 铔囧彛', detail: '' }, + { title: '楂樼骇鍓嶇寮�鍙戝伐绋嬪笀锛圴ue3+TS鏂瑰悜锛�', payment: '25k 路 14钖�', tagList: ['1-3骞�', '鏈鍙婁互涓�'], company: '浜戣垝鎶�鏈湁闄愬叕鍙�', address: '娣卞湷甯� 鍗楀北鍖� 铔囧彛', detail: '' }, + { title: '楂樼骇鍓嶇寮�鍙戝伐绋嬪笀锛圴ue3+TS鏂瑰悜锛�', payment: '25k 路 14钖�', tagList: ['1-3骞�', '鏈鍙婁互涓�'], company: '浜戣垝鎶�鏈湁闄愬叕鍙�', address: '娣卞湷甯� 鍗楀北鍖� 铔囧彛', detail: '' }, + { title: '楂樼骇鍓嶇寮�鍙戝伐绋嬪笀锛圴ue3+TS鏂瑰悜锛�', payment: '25k 路 14钖�', tagList: ['1-3骞�', '鏈鍙婁互涓�'], company: '浜戣垝鎶�鏈湁闄愬叕鍙�', address: '娣卞湷甯� 鍗楀北鍖� 铔囧彛', detail: '' }, + ] + @State expandIndex: number | null = 0 - } - .width('95%') - .height(50) - .borderRadius(20) - .backgroundColor(Color.White) - .justifyContent(FlexAlign.Center) - .onClick(() => { - console.info('TextData: ' + JSON.stringify(this.TextData.text)) - }) - List({space:15}){ - ForEach(this.newsBase.data,(item:NewsBaseData) =>{ - ListItem(){ - newsItem({newsData: item}) - } - }) - } - .alignListItem(ListItemAlign.Center) - } - .height('100%') - .width('100%') - .backgroundColor("#ffececec") - } -} -//鏉$洰鏍峰紡锛岃嚜瀹氫箟缁勪欢 -@Component -struct newsItem { - @Prop newsData: NewsBaseData build() { - Row({space: 10}){ - Image(this.newsData.pic) - //鍗犱綅鍥� - .alt($r('app.media.app_logo_image')) - .width(100) - .height(70) - .objectFit(ImageFit.Fill) - Column({space: 10}){ - Text(this.newsData.title).SearchTextSty(18,700) - Text(this.newsData.desc).SearchTextSty(15,400,Color.Black,2) - Text(`鐑害锛� ${this.newsData.hot}`).SearchTextSty(10,400,Color.Red) - .textAlign(TextAlign.End) + Column({ space: 10 }) { + Text('宀椾綅鎺ㄨ崘') + .width('100%') + .textAlign(TextAlign.Start) + .fontWeight(800) + .fontSize(18) + .margin({ left: 16 }) + + Row() { + Image($r('app.media.search_icon')) + .width(14) + .height(14) + TextInput({ placeholder: '鎼滅储鎯宠鏌ユ壘鐨勫矖浣�' }) + .placeholderFont({ size: 14}) + .placeholderColor('#999999') + .backgroundColor('#f3f7fe') } - .width('65%') + .borderRadius(30) + .padding({ left: 20, right: 20 }) + .backgroundColor('#f3f7fe') + .width('100%') + .margin({ top: 10 }) + + List({ space: 10, initialIndex: 0 }) { + ForEach(this.jobList, (item: JobItem, index: number) => { + ListItem() { + Column() { + Row({ space: 10 }) { + Column() { + Text(item.title) + .fontSize(14) + .fontWeight(800) + Row({ space: 10 }) { + ForEach(item.tagList, (tag: string) => { + Text(tag) + .padding(4) + .borderRadius(4) + .fontSize(10) + .fontColor('#999999') + .backgroundColor('#f5f5f5') + }) + } + .width('100%') + .justifyContent(FlexAlign.Start) + + Row({ space: 8 }) { + Image($r('app.media.company_icon')) + .width(16) + .height(16) + + Text(item.company) + .fontSize(10) + + } + } + .layoutWeight(0) + .width(200) + .height('100%') + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(HorizontalAlign.Start) + + Column() { + Text(item.payment) + .fontColor('#1756f4') + .fontSize(14) + .fontWeight(800) + Text(item.address) + .fontColor('#a6a6a6') + .fontSize(10) + } + .height('100%') + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(HorizontalAlign.End) + } + .width('100%') + .height(100) + .justifyContent(FlexAlign.SpaceBetween) + + + Row() { + Text() { + Span(this.expandIndex == index ? '鏀惰捣' : '灞曞紑') + Span('宀椾綅瑕佹眰') + } + .fontSize(10) + .fontColor('#666666') + Image(this.expandIndex == index ? $r('app.media.down_icon') : $r('app.media.up_icon')) + .width(14) + .height(14) + .margin({ left: 4 }) + } + .height(20) + .margin({ top: 10 }) + .alignItems(VerticalAlign.Center) + .onClick(() => { + if (this.expandIndex == index) { + this.expandIndex = null + } else { + this.expandIndex = index + } + }) + + if (this.expandIndex == index) { + Divider() + .color('#f0f0f0') + .margin({ top: 5, bottom: 5 }) + + Text('宀椾綅瑕佹眰:') + .fontSize(13) + .fontWeight(500) + .margin({ top: 10 }) + .width('100%') + .textAlign(TextAlign.Start) + Text('1.瀛﹀巻瑕佹眰锛氭湰绉戝強浠ヤ笂瀛﹀巻锛岃绠楁満绉戝涓庢妧鏈�佽蒋浠跺伐绋嬬瓑鐩稿叧涓撲笟浼樺厛锛屼紭绉�澶т笓瀛﹀巻鑰�' + + '1.瀛﹀巻瑕佹眰锛氭湰绉戝強浠ヤ笂瀛﹀巻锛岃绠楁満绉戝涓庢妧鏈�佽蒋浠跺伐绋嬬瓑鐩稿叧涓撲笟浼樺厛锛屼紭绉�澶т笓瀛﹀巻鑰�') + .fontSize(10) + .margin({ top: 6 }) + .fontColor('#666666') + .lineHeight(15) + .width('100%') + .textAlign(TextAlign.Start) + } + + + } + .padding(10) + .border({ width: 1, style: BorderStyle.Solid, color: this.expandIndex == index ? '#1756f4' : '#f2f2f2' }) + .borderRadius(10) + } + }, (index: number) => index.toString()) + } + .listDirection(Axis.Vertical) // 鎺掑垪鏂瑰悜 + .scrollBar(BarState.Off) + .friction(0.6) + .edgeEffect(EdgeEffect.Spring) + .width('100%') + .height(560) + } - .width('95%') - .padding(10) - .borderRadius(10) - .backgroundColor(Color.White) + .padding({ left: 10, right: 10 }) + .height('100%') } } -@Extend(Text) function SearchTextSty(mSize:number,mWeight?:FontWeight,mColor?: ResourceColor,mLines?: number){ - .fontSize(mSize) - .fontWeight(mWeight? mWeight : 400) - .fontColor(mColor? mColor : Color.Black) - .maxLines(mLines? mLines : 1) - .textOverflow({overflow: TextOverflow.Ellipsis}) - .width('100%') -} \ No newline at end of file -- Gitblit v1.8.0