鸿蒙 - 修改密码页面
·
import { user } from '../../../viewModel/type';
import { router } from '@kit.ArkUI';
@Entry
@Component
struct ModifyPass {
@State message: string = 'Hello World';
@State oldPass: string = '';
@State newPass: string = '';
@State confirmPass: string = '';
@State tips: string = '';
build() {
Column({
space:15
}){
TextInput({placeholder:'请输入原密码',text:$$this.oldPass}).type(InputType.Password)
TextInput({placeholder:'请输入新密码',text:$$this.newPass}).type(InputType.Password)
TextInput({placeholder:'请确认密码',text:$$this.confirmPass}).type(InputType.Password)
Text(this.tips).fontColor(Color.Red)
Button('修改').onClick((event: ClickEvent) => {
// 验证原密码是否正确
if (this.oldPass !== user.getpwd()) {
this.tips = '原密码不正确';
return;
}
// 验证新密码和确认密码是否一致
if (this.newPass !== this.confirmPass) {
this.tips = '新密码与确认密码不一致';
return;
}
// 验证密码是否为空
if (this.newPass === '') {
this.tips = '新密码不能为空';
return;
}
// 修改密码
user.setPwd(this.newPass);
this.tips = '密码修改成功';
setTimeout(() => {
router.pushUrl({
url:"pages/week3/day5/Login"
})
})
// 清空输入框
this.oldPass = '';
this.newPass = '';
this.confirmPass = '';
})
}
.height('100%')
.width('100%')
.padding({left: 30, right: 30})
}
}

更多推荐



所有评论(0)