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/home/Home.ets | 144 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 140 insertions(+), 4 deletions(-) diff --git a/entry/src/main/ets/pages/home/Home.ets b/entry/src/main/ets/pages/home/Home.ets index 4f6cbe7..47cf6dd 100644 --- a/entry/src/main/ets/pages/home/Home.ets +++ b/entry/src/main/ets/pages/home/Home.ets @@ -1,3 +1,5 @@ +import { router } from "@kit.ArkUI" + class TabBarBase { title: string = '' } @@ -11,11 +13,19 @@ signupCount: number = 0 statusText: string = '' } +class Course { + title: string = '' + desc: string = '' + count: string = '' + time: string = '' + difficult: string = '' +} + @Entry @Component export struct Home { @State pageHeight: number = 0 - @State activeIndex:number = 0 + @State activeIndex:number = 1 @State tabList: TabBarBase[] = [ { title: '棣栭〉' }, { title: '璇剧▼' } @@ -46,6 +56,25 @@ { title: '鍖椾含浜哄伐鏅鸿兘IE', timeScope: '20250520-20250620', signupCount: 80, statusText: '宸茬粨鏉�' }, { title: '鍖椾含浜哄伐鏅鸿兘IE', timeScope: '20250520-20250620', signupCount: 80, statusText: '鎶ュ悕涓�' }, { title: '鍖椾含浜哄伐鏅鸿兘IE', timeScope: '20250520-20250620', signupCount: 80, statusText: '宸茬粨鏉�' }, + ] + @State courseList: Course[] = [ + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: 'Java楂樼骇锛欽VM娣卞害璋冧紭涓嶫VM娣卞害璋冧紭', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + { title: '闆跺熀纭�鍒颁紒涓氱骇椤圭洰瀹炴垬', 'desc': '閽堝闆跺熀纭�灏忕櫧鎴栨兂鍗囩骇鎶�鏈爤鐨勫墠绔粠涓氳�咃紝浠庢牳蹇冭娉曞叆鎵嬶紝閫愭娣卞叆Vue3缁勪欢寮�鍙戞墦浠跺紑鍙戜欢寮�鍙�', count: '800', time: '01:30:23', difficult: '绠�鍗�' }, + ] @Builder tabBarItem(name:string,index: number){ @@ -94,7 +123,7 @@ Tabs({controller:this.tabController}){ ForEach(this.tabList, (item: TabBarBase, index: number) => { // 棣栭〉 ------------ - if (item.title == '棣栭〉') { + if (this.activeIndex == 0) { TabContent() { Column({ space: 10 }){ Swiper() { @@ -103,6 +132,14 @@ .width('100%') .height(120) .backgroundColor(0xAFEEEE) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ + url: 'pages/home/BannerDetail', + params: { + id: index + } + }) + }) }) } .borderRadius(10) @@ -131,6 +168,14 @@ .fontSize(12) .fontWeight(500) } + .onClick(() => { + router.pushUrl({ + url: 'pages/home/ClassificationDetail', + params: { + title: item.title + } + }) + }) } }) } @@ -191,6 +236,14 @@ .height(100) .padding(10) .justifyContent(FlexAlign.SpaceBetween) + .onClick(() => { + router.pushUrl({ + url: 'pages/home/ActiveDetail', + params: { + index: index + } + }) + }) } }, (index: number) => index.toString()) } @@ -209,10 +262,93 @@ } // 璇剧▼------------ - if (item.title == '璇剧▼') { + if (this.activeIndex == 1) { TabContent() { - Text('璇剧▼content') + Column({ space: 10 }) { + Row() { + Image($r('app.media.search_icon')) + .width(14) + .height(14) + TextInput({ placeholder: '鎼滅储鎯宠鏌ユ壘鐨勫唴瀹�' }) + .placeholderFont({ size: 14}) + .placeholderColor('#999999') + .backgroundColor('#f3f7fe') + } + .borderRadius(30) + .padding({ left: 20, right: 20 }) + .backgroundColor('#f3f7fe') + .width('100%') + List({ space: 10, initialIndex: 0 }) { + ForEach(this.courseList, (item: Course, index: number) => { + ListItem() { + Row({ space: 10 }) { + Column() { + Text(item.title) + .fontSize(14) + .fontWeight(800) + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + Text(item.desc) + .fontSize(12) + .fontColor('#666666') + .maxLines(2) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + Row() { + Row({ space: 2 }) { + Image($r('app.media.person_icon')) + .width(10) + .height(10) + Text(item.count) + .fontSize(10) + .fontColor('#666666') + } + Row({ space: 2 }) { + Image($r('app.media.video_icon')) + .width(10) + .height(10) + Text(item.time) + .fontSize(10) + .fontColor('#666666') + } + Text() { + Span('璇剧▼闅惧害: ') + Span(item.difficult) + } + .fontSize(10) + .fontColor('#666666') + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + } + .layoutWeight(0) + .width(170) + .height('100%') + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(HorizontalAlign.Start) + Image($r('app.media.active_list_img')) + .aspectRatio(16/9) + .height('100%') + .layoutWeight(1) + } + .width('100%') + .height(100) + .padding(10) + .justifyContent(FlexAlign.SpaceBetween) + .border({ width: 1, style: BorderStyle.Solid, color: '#f2f2f2' }) + .borderRadius(10) + } + }, (index: number) => index.toString()) + } + .listDirection(Axis.Vertical) // 鎺掑垪鏂瑰悜 + .scrollBar(BarState.Off) + .friction(0.6) + .edgeEffect(EdgeEffect.Spring) + .width('100%') + .height(530) + + } + .height('100%') }.tabBar(this.tabBarItem(item.title, index)) } }) -- Gitblit v1.8.0