首页页面和我的页面的框架
This commit is contained in:
71
entry/src/main/ets/pages/HomePage.ets
Normal file
71
entry/src/main/ets/pages/HomePage.ets
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
@Entry
|
||||||
|
@Component
|
||||||
|
struct HomePage {
|
||||||
|
@State currentIndex: number = 0;
|
||||||
|
|
||||||
|
build() {
|
||||||
|
Tabs({ barPosition: BarPosition.End, index: this.currentIndex }) {
|
||||||
|
TabContent() {
|
||||||
|
this.HomeContent()
|
||||||
|
}
|
||||||
|
.tabBar(this.TabBarItem(0, '首页', '○'))
|
||||||
|
|
||||||
|
TabContent() {
|
||||||
|
this.MineContent()
|
||||||
|
}
|
||||||
|
.tabBar(this.TabBarItem(1, '我的', '○'))
|
||||||
|
}
|
||||||
|
.barMode(BarMode.Fixed)
|
||||||
|
.onChange((index: number) => {
|
||||||
|
this.currentIndex = index;
|
||||||
|
})
|
||||||
|
.width('100%')
|
||||||
|
.height('100%')
|
||||||
|
.backgroundColor('#F5F6F7')
|
||||||
|
}
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
TabBarItem(index: number, title: string, icon: string) {
|
||||||
|
Column() {
|
||||||
|
Text(icon)
|
||||||
|
.fontSize(22)
|
||||||
|
Text(title)
|
||||||
|
.fontSize(12)
|
||||||
|
.fontColor(this.currentIndex === index ? '#4E6EF2' : '#999999')
|
||||||
|
.fontWeight(this.currentIndex === index ? FontWeight.Medium : FontWeight.Normal)
|
||||||
|
.margin({ top: 2 })
|
||||||
|
}
|
||||||
|
.width('100%')
|
||||||
|
.height('100%')
|
||||||
|
.justifyContent(FlexAlign.Center)
|
||||||
|
.alignItems(HorizontalAlign.Center)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
HomeContent() {
|
||||||
|
Column() {
|
||||||
|
Text('首页')
|
||||||
|
.fontSize(20)
|
||||||
|
.fontWeight(FontWeight.Bold)
|
||||||
|
.fontColor('#333333')
|
||||||
|
}
|
||||||
|
.width('100%')
|
||||||
|
.height('100%')
|
||||||
|
.justifyContent(FlexAlign.Center)
|
||||||
|
.alignItems(HorizontalAlign.Center)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
MineContent() {
|
||||||
|
Column() {
|
||||||
|
Text('我的')
|
||||||
|
.fontSize(20)
|
||||||
|
.fontWeight(FontWeight.Bold)
|
||||||
|
.fontColor('#333333')
|
||||||
|
}
|
||||||
|
.width('100%')
|
||||||
|
.height('100%')
|
||||||
|
.justifyContent(FlexAlign.Center)
|
||||||
|
.alignItems(HorizontalAlign.Center)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { router } from '@kit.ArkUI';
|
import { promptAction, router } from '@kit.ArkUI';
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
@@ -132,11 +132,13 @@ struct LoginPage {
|
|||||||
|
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
|
|
||||||
// 模拟登录请求
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (this.username === 'admin' && this.password === 'admin123') {
|
||||||
|
router.replaceUrl({ url: 'pages/HomePage' });
|
||||||
|
} else {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
// TODO: 登录成功,跳转刷题主页
|
promptAction.showToast({ message: '账号或密码错误', duration: 2000 });
|
||||||
// router.replaceUrl({ url: 'pages/HomePage' });
|
}
|
||||||
}, 1500);
|
}, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"src": [
|
"src": [
|
||||||
"pages/LoginPage",
|
"pages/LoginPage",
|
||||||
"pages/RegisterPage"
|
"pages/RegisterPage",
|
||||||
|
"pages/HomePage"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user