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/home/Home.ets | 233 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 233 insertions(+), 0 deletions(-) diff --git a/entry/src/main/ets/pages/home/Home.ets b/entry/src/main/ets/pages/home/Home.ets new file mode 100644 index 0000000..4f6cbe7 --- /dev/null +++ b/entry/src/main/ets/pages/home/Home.ets @@ -0,0 +1,233 @@ +class TabBarBase { + title: string = '' +} +class Classification { + title: string = '' + icon: ResourceStr = '' +} +class Activity { + title: string = '' + timeScope: string = '' + signupCount: number = 0 + statusText: string = '' +} +@Entry +@Component +export struct Home { + @State pageHeight: number = 0 + @State activeIndex:number = 0 + @State tabList: TabBarBase[] = [ + { title: '棣栭〉' }, + { title: '璇剧▼' } + ] + private tabController: TabsController = new TabsController() + @State swiperList: ResourceStr[] = [ + $r('app.media.image1'), + $r('app.media.image1'), + $r('app.media.image1'), + ] + @State swiperIndex: number = 0 + //TabBar鏍峰紡 + @State classificationList: Classification[] = [ + { title: '鏁伴��', icon: $r('app.media.classification_shutong') }, + { title: '瀹夊叏', icon: $r('app.media.classification_safety') }, + { title: '浜戣绠�', icon: $r('app.media.classification_cloudcalc') }, + { title: '瀛樺偍', icon: $r('app.media.classification_storage') }, + { title: '椴查箯', icon: $r('app.media.classification_roc') }, + { title: 'AI', icon: $r('app.media.classification_AI') }, + { title: '杩炴帴', icon: $r('app.media.classification_link') }, + { title: '澶ф暟鎹�', icon: $r('app.media.classification_bigdata') }, + { title: '浜戞湇鍔�', icon: $r('app.media.classification_cloudservice') }, + { title: '鏇村', icon: $r('app.media.classification_more') }, + ] + @State activityList: Activity[] = [ + { title: '鍖椾含浜哄伐鏅鸿兘IE', timeScope: '20250520-20250620', signupCount: 80, statusText: '鎶ュ悕涓�' }, + { title: '鍖椾含浜哄伐鏅鸿兘IE', timeScope: '20250520-20250620', signupCount: 80, statusText: '杩涜涓�' }, + { title: '鍖椾含浜哄伐鏅鸿兘IE', timeScope: '20250520-20250620', signupCount: 80, statusText: '宸茬粨鏉�' }, + { title: '鍖椾含浜哄伐鏅鸿兘IE', timeScope: '20250520-20250620', signupCount: 80, statusText: '鎶ュ悕涓�' }, + { title: '鍖椾含浜哄伐鏅鸿兘IE', timeScope: '20250520-20250620', signupCount: 80, statusText: '宸茬粨鏉�' }, + ] + + @Builder tabBarItem(name:string,index: number){ + Row(){ + Text(name) + .fontSize(this.activeIndex == index ? 16 : 14) + .fontWeight(700) + .fontColor(this.activeIndex == index ? '#1756f4' : '#666666') + .margin(index == 0 ? { left: '50%' } : { right: '50%' } ) + } + .onClick(() => { + this.activeIndex = index + this.tabController.changeIndex(index) + }) + } + + getTagFontColor(statusText: string) { + switch (statusText) { + case '鎶ュ悕涓�': + return '#10920e' + case '杩涜涓�': + return '#ffa100' + default : + return '#666666' + } + } + + getTagBgColor(statusText: string) { + switch (statusText) { + case '鎶ュ悕涓�': + return '#d5f2db' + case '杩涜涓�': + return '#fff0cc' + default : + return '#ebebeb' + } + } + + build() { + Column() { + Text('楦胯挋瀹炶棣栭〉') + .width('100%') + .textAlign(TextAlign.Center) + .fontWeight(800) + .fontSize(18) + Tabs({controller:this.tabController}){ + ForEach(this.tabList, (item: TabBarBase, index: number) => { + // 棣栭〉 ------------ + if (item.title == '棣栭〉') { + TabContent() { + Column({ space: 10 }){ + Swiper() { + ForEach(this.swiperList, (item: Resource) => { + Image(item) + .width('100%') + .height(120) + .backgroundColor(0xAFEEEE) + }) + } + .borderRadius(10) + .interval(3000) + .autoPlay(true) + .indicator( + Indicator.dot() + .itemWidth(8) + .itemHeight(8) + .selectedItemWidth(16) + .selectedItemHeight(8) + .color(Color.White) + ) + .onChange((index) => { + this.swiperIndex = index; + }) + + Grid() { + ForEach(this.classificationList, (item: Classification ) => { + GridItem() { + Column({ space: 6 }) { + Image(item.icon) + .width(26) + .height(26) + Text(item.title) + .fontSize(12) + .fontWeight(500) + } + } + }) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr') + .columnsGap(14) + .rowsGap(14) + .width('100%') + .height(110) + + Row() { + Image($r('app.media.title_decoration_icon')) + .width(4) + Text('鐑棬鍩硅') + .margin({ left: 8 }) + .fontSize(16) + .fontWeight(700) + + } + .alignItems(VerticalAlign.Center) + .width('100%') + + List({ space: 10, initialIndex: 0 }) { + ForEach(this.activityList, (item: Activity, index: number) => { + ListItem() { + Row() { + Column({ space: 6 }) { + Text(item.title) + .fontSize(12) + .fontWeight(500) + Row() { + Image($r('app.media.date_icon')) + .width(12) + .height(12) + Text(item.timeScope) + .fontSize(10) + .fontColor('#676767') + .margin({ left: 4 }) + } + Text(`${item.signupCount || 0}浜哄凡鎶ュ悕`) + .fontSize(10) + .fontColor('#676767') + Text(item.statusText) + .fontSize(10) + .fontWeight(500) + .padding(6) + .borderRadius(10) + .fontColor(this.getTagFontColor(item.statusText)) + .backgroundColor(this.getTagBgColor(item.statusText)) + } + .height('100%') + .justifyContent(FlexAlign.Start) + .alignItems(HorizontalAlign.Start) + Image($r('app.media.active_list_img')) + .aspectRatio(16/9) + .height('100%') + } + .width('100%') + .height(100) + .padding(10) + .justifyContent(FlexAlign.SpaceBetween) + } + }, (index: number) => index.toString()) + } + .listDirection(Axis.Vertical) // 鎺掑垪鏂瑰悜 + .scrollBar(BarState.Off) + .friction(0.6) + .divider({ strokeWidth: 1, color: '#e8e8e8' }) // 姣忚涔嬮棿鐨勫垎鐣岀嚎 + .edgeEffect(EdgeEffect.Spring) + .width('100%') + .height(300) + } + .height('100%') + } + .tabBar(this.tabBarItem(item.title, index)) + .height('100%') + } + + // 璇剧▼------------ + if (item.title == '璇剧▼') { + TabContent() { + Text('璇剧▼content') + + }.tabBar(this.tabBarItem(item.title, index)) + } + }) + } + .barHeight(40) + .margin({ top: 6 }) + .width('100%') + .height('100%') + .padding({ left: 14, right: 14, bottom: 14 }) + .onChange((index: number) => { + this.activeIndex = index + }) + } + .width('100%') + .height('100%') + + } +} \ No newline at end of file -- Gitblit v1.8.0