From 23fa268f56dcd99c8dcd46f50f3ffcaa4cdcbc49 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期五, 10 十月 2025 17:25:53 +0800
Subject: [PATCH] 功能完善

---
 entry/src/main/ets/pages/search/SearchPage.ets |  140 ++++++++++++++++++++++++++++------------------
 1 files changed, 84 insertions(+), 56 deletions(-)

diff --git a/entry/src/main/ets/pages/search/SearchPage.ets b/entry/src/main/ets/pages/search/SearchPage.ets
index 6ceb8d4..8cf6fa6 100644
--- a/entry/src/main/ets/pages/search/SearchPage.ets
+++ b/entry/src/main/ets/pages/search/SearchPage.ets
@@ -1,33 +1,65 @@
-import { IconType } from "@kit.ArkUI"
+import { IconType, promptAction } from "@kit.ArkUI"
+import { http } from "@kit.NetworkKit"
+import { LvMarkdownIn } from "@luvi/lv-markdown-in"
+import { HttpResponseResult } from "../../data/HttpResponse"
+import { ROMAIN } from "../../utils/config"
 
 class JobItem {
-  title: string = ''
-  payment: string = ''
-  tagList: string[] = []
-  company: string = ''
-  address: string = ''
-  detail: string = ''
+  ability: string = ''
+  addr: string = ''
+  companyName: string = ''
+  degree: string = ''
+  exp: string = ''
+  jobName: string = ''
+  salary: string = ''
 }
 
 @Entry
 @Component
 export struct SearchPage {
-  @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
+  @State jobList: JobItem[] = []
+  @State expandIndex: number | null = null
+  @State @Watch('filterJobList') searchKeyword: string = ''
+  @State origJobList: JobItem[] = []
+
+  aboutToAppear(): void {
+    this.getJobList()
+  }
+
+  getJobList() {
+    let httpRequest = http.createHttp();
+    httpRequest.request(
+      `${ROMAIN}/quiz-community/public/v1.0/home/seek/job`,
+      {
+        method: http.RequestMethod.GET,
+        header: { 'Content-Type': 'application/json', 'x-jwt-token': `Bearer ${AppStorage.get('x-jwt-token')}` },
+      },
+      (err, data) => {
+        console.log('response', '/home/seek/job')
+        console.log(JSON.stringify(data.result))
+        if (data.responseCode == 200) {
+          const resData = (typeof data.result == 'string' ? JSON.parse(data.result) : data.result) as HttpResponseResult<JobItem[]>
+          if (resData.code == 200) {
+            this.origJobList = resData.data as JobItem[]
+            this.filterJobList()
+          } else {
+            promptAction.showToast({ message: resData.msg })
+          }
+        }
+      }
+    )
+  }
+
+  filterJobList() {
+    if (this.searchKeyword) {
+      let list = this.origJobList.filter((ele: JobItem) => {
+        return ele.companyName.includes(this.searchKeyword) || ele.jobName.includes(this.searchKeyword)
+      })
+      this.jobList = list
+    } else {
+      this.jobList = this.origJobList
+    }
+  }
 
   build() {
     Column({ space: 10 }) {
@@ -42,7 +74,7 @@
         Image($r('app.media.search_icon'))
           .width(14)
           .height(14)
-        TextInput({ placeholder: '鎼滅储鎯宠鏌ユ壘鐨勫矖浣�' })
+        TextInput({ placeholder: '鎼滅储鎯宠鏌ユ壘鐨勫矖浣�', text: $$this.searchKeyword })
           .placeholderFont({ size: 14})
           .placeholderColor('#999999')
           .backgroundColor('#f3f7fe')
@@ -59,18 +91,22 @@
             Column() {
               Row({ space: 10 }) {
                 Column() {
-                  Text(item.title)
-                    .fontSize(14)
-                    .fontWeight(800)
+                  Text(item.jobName)
+                    .fontSize(18)
+                    .fontWeight(700)
                   Row({ space: 10 }) {
-                    ForEach(item.tagList, (tag: string) => {
-                      Text(tag)
-                        .padding(4)
-                        .borderRadius(4)
-                        .fontSize(10)
-                        .fontColor('#999999')
-                        .backgroundColor('#f5f5f5')
-                    })
+                    Text(item.exp)
+                      .padding(4)
+                      .borderRadius(4)
+                      .fontSize(12)
+                      .fontColor('#999999')
+                      .backgroundColor('#f5f5f5')
+                    Text(item.degree)
+                      .padding(4)
+                      .borderRadius(4)
+                      .fontSize(12)
+                      .fontColor('#999999')
+                      .backgroundColor('#f5f5f5')
                   }
                   .width('100%')
                   .justifyContent(FlexAlign.Start)
@@ -80,8 +116,8 @@
                       .width(16)
                       .height(16)
 
-                    Text(item.company)
-                      .fontSize(10)
+                    Text(item.companyName)
+                      .fontSize(12)
 
                   }
                 }
@@ -92,13 +128,13 @@
                 .alignItems(HorizontalAlign.Start)
 
                 Column() {
-                  Text(item.payment)
+                  Text(item.salary)
                     .fontColor('#1756f4')
-                    .fontSize(14)
-                    .fontWeight(800)
-                  Text(item.address)
+                    .fontSize(16)
+                    .fontWeight(700)
+                  Text(item.addr)
                     .fontColor('#a6a6a6')
-                    .fontSize(10)
+                    .fontSize(12)
                 }
                 .height('100%')
                 .justifyContent(FlexAlign.SpaceBetween)
@@ -111,12 +147,12 @@
 
               Row() {
                 Text() {
-                  Span(this.expandIndex == index ? '鏀惰捣' : '灞曞紑')
+                  Span(this.expandIndex == index ? '鏀惰捣' : '鏌ョ湅')
                   Span('宀椾綅瑕佹眰')
                 }
-                .fontSize(10)
+                .fontSize(12)
                 .fontColor('#666666')
-                Image(this.expandIndex == index ? $r('app.media.down_icon') : $r('app.media.up_icon'))
+                Image(this.expandIndex == index ? $r('app.media.up_icon') : $r('app.media.down_icon'))
                   .width(14)
                   .height(14)
                   .margin({ left: 4 })
@@ -143,17 +179,10 @@
                   .margin({ top: 10 })
                   .width('100%')
                   .textAlign(TextAlign.Start)
-                Text('1.瀛﹀巻瑕佹眰锛氭湰绉戝強浠ヤ笂瀛﹀巻锛岃绠楁満绉戝涓庢妧鏈�佽蒋浠跺伐绋嬬瓑鐩稿叧涓撲笟浼樺厛锛屼紭绉�澶т笓瀛﹀巻鑰�' +
-                  '1.瀛﹀巻瑕佹眰锛氭湰绉戝強浠ヤ笂瀛﹀巻锛岃绠楁満绉戝涓庢妧鏈�佽蒋浠跺伐绋嬬瓑鐩稿叧涓撲笟浼樺厛锛屼紭绉�澶т笓瀛﹀巻鑰�')
-                  .fontSize(10)
-                  .margin({ top: 6 })
-                  .fontColor('#666666')
-                  .lineHeight(15)
+                LvMarkdownIn({ text: item.ability })
                   .width('100%')
-                  .textAlign(TextAlign.Start)
+                  .padding({ left: 10, right: 10 })
               }
-
-
             }
             .padding(10)
             .border({ width: 1, style: BorderStyle.Solid, color: this.expandIndex == index ? '#1756f4' : '#f2f2f2' })
@@ -166,8 +195,7 @@
       .friction(0.6)
       .edgeEffect(EdgeEffect.Spring)
       .width('100%')
-      .height(560)
-
+      .height(600)
     }
     .padding({ left: 10, right: 10 })
     .height('100%')

--
Gitblit v1.8.0