From 1ce875be27d9011c3944c6b975d9f817947ecdf8 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期三, 01 十月 2025 16:22:24 +0800
Subject: [PATCH] 登录、注册

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

diff --git a/entry/src/main/ets/pages/search/SearchPage.ets b/entry/src/main/ets/pages/search/SearchPage.ets
new file mode 100644
index 0000000..408cf26
--- /dev/null
+++ b/entry/src/main/ets/pages/search/SearchPage.ets
@@ -0,0 +1,82 @@
+import { AxiosResponse } from "@ohos/axios"
+import { NewsBase, NewsBaseData } from "../../data/NewsBase"
+import { TextBase } from "../../data/TextBase"
+import { NewsApi, TextApi } from "../../http/AxiosAPI"
+
+@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)
+
+      }
+      .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)
+      }
+      .width('65%')
+    }
+    .width('95%')
+    .padding(10)
+    .borderRadius(10)
+    .backgroundColor(Color.White)
+  }
+}
+@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