Code owners
Assign users and groups as approvers for specific file changes. Learn more.
RegisterPage.ets 2.17 KiB
// 注册页面
import { router, promptAction } from '@kit.ArkUI'
import CommonConstants from '../common/CommonConstant';
@Component
export default struct Register {
@Consume('loginPageStack') LoginPageStack: NavPathStack
@State name: string = ''
@State phone: string = ''
@State pwd: string = ''
@State pwd2: string = ''
// 提交
handleSubmit() {
if(this.name === '' || this.pwd === '' || this.phone === '' || this.pwd2 === '') {
promptAction.showToast({ message: '输入项不能为空' })
}
else if(this.pwd != this.pwd2) {
promptAction.showToast({ message: '密码不一致' })
}
else {
// 登录接口逻辑...
promptAction.showToast({ message: '登录成功' })
setTimeout(() => {
router.replaceUrl({ url: 'pages/Index' })
}, 2000)
}
}
build() {
NavDestination() {
Column() {
Column({space: 10}) {
Image('media/startIcon.png').height(40).width(40)
Text('欢迎注册Todolist').fontSize(18).fontColor(CommonConstants.base_blue).margin({top:10})
}
.margin({top: 50})
Column({space: 15}) {
TextInput({placeholder: '昵称'})
.onChange((value) => {
this.name = value
})
TextInput({placeholder: '手机号'})
.onChange((value) => {
this.phone = value
})
TextInput({placeholder: '密码'}).type(InputType.Password)
.onChange((value) => {
this.pwd = value
})
TextInput({placeholder: '确认密码'}).type(InputType.Password)
.onChange((value) => {
this.pwd2 = value
})
Button('注册').height(45).width('100%')
.onClick(() => {
this.handleSubmit()
})
.margin({top: 8})
}
.margin({top: 20})
.width('80%')
Row({space: 15}) {
Text('返回登录').fontSize(14).opacity(0.5)
.onClick(()=>{
this.LoginPageStack.pop()
})
}
.margin({top: 20})
}
.height('100%')
.width('100%')
}
.hideTitleBar(true)
}
}