Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
yangchenggong1_wd
2024-05-24 18:11:08 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4350677f339ee0880c9ac1aaa08b06f730158005
4350677f
1 parent
87db9379
desc:埋点[重置密码页,设置密码 - 页面浏览,登录按钮点击]
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
392 additions
and
500 deletions
sight_harmony/features/wdLogin/Index.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/ForgetPasswordPage.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginInputComponent.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginPage.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/ModifyPasswordPage.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/SettingPasswordLayout.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/SettingPasswordPage.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/VerifyPhoneNumberPage.ets
sight_harmony/features/wdLogin/src/main/resources/base/profile/main_pages.json
sight_harmony/features/wdLogin/Index.ets
View file @
4350677
export { add } from "./src/main/ets/utils/Calc"
export { SettingPasswordParams } from "./src/main/ets/pages/login/SettingPassword
Layout
"
export { SettingPasswordParams } from "./src/main/ets/pages/login/SettingPassword
Page
"
export { LoginModule } from './src/main/ets/LoginModule'
\ No newline at end of file
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/ForgetPasswordPage.ets
View file @
4350677
...
...
@@ -3,7 +3,7 @@ import { LoginInputComponent } from './LoginInputComponent'
import { LoginViewModel } from './LoginViewModel'
import router from '@ohos.router'
import { WDRouterRule, WDRouterPage } from 'wdRouter';
import { SettingPasswordParams } from './SettingPassword
Layout
'
import { SettingPasswordParams } from './SettingPassword
Page
'
import { Router } from '@ohos.arkui.UIContext'
import { CustomToast, EmitterEventId, EmitterUtils, NetworkUtil, SPHelper, StringUtils, ToastUtils } from 'wdKit/Index'
import { SpConstants } from 'wdConstant/Index'
...
...
@@ -22,7 +22,6 @@ struct ForgetPasswordPage {
@State isSubmit: boolean = false //是否可以提交 默认不可以
loginViewModel: LoginViewModel = new LoginViewModel()
@State @Watch('onCodeSend') isCodeSend: boolean = false //验证码点击发送事件
pageType:number = (router.getParams() as Record<string, number>)['pageType']; //0、登录->忘记密码 1、设置->重置密码 3、设置->更换手机号页面2(不知道是啥)
phone:string = (router.getParams() as Record<string, number>)['phone'] + ""; //登录 密码登录 填写手机号 点击忘记密码 带过来手机号
@State pageTitle:string = '找回密码';
@State codeStateSuccess:boolean=false
...
...
@@ -57,7 +56,7 @@ struct ForgetPasswordPage {
codeContent: $codeContent,
isSubmit: $isSubmit,
isCodeSend: $isCodeSend,
pageType:
this.pageType
,
pageType:
0
,
codeStateSuccess:$codeStateSuccess
})
Row() {
...
...
@@ -81,21 +80,8 @@ struct ForgetPasswordPage {
}
aboutToAppear() {
if (router.getParams()) {
let params = router.getParams() as Record<string, number>
this.pageType = params['pageType']
Logger.info(TAG, 'params.contentID:' + params.contentID);
}
if (this.pageType == 0){
this.pageTitle = '找回密码'
if(StringUtils.isNotEmpty(this.phone) && this.phone.indexOf("****") === -1){
this.phoneContent = this.phone
}
}else if (this.pageType == 1){
this.pageTitle = '验证当前手机号'
}
if (this.isCodeSend) {
this.sendVerifyCode()
if(StringUtils.isNotEmpty(this.phone) && this.phone.indexOf("****") === -1){
this.phoneContent = this.phone
}
}
...
...
@@ -105,20 +91,7 @@ struct ForgetPasswordPage {
return
}
if(this.pageType == 1){
this.loginViewModel.sendVerifyCodeByToken().then(()=>{
this.showToastTip("已发送")
this.codeStateSuccess=true
this.isCodeSend=false
}).catch((message: string)=>{
this.showToastTip(message)
this.codeStateSuccess=false
this.isCodeSend=false
})
return
}
if(this.pageType == 0 && this.phoneContent.indexOf("****")!=-1){
if(this.phoneContent.indexOf("****")!=-1){
//设置密码 忘记密码跳转过来的 需要使用上面方法
this.loginViewModel.sendVerifyCodeByToken().then(()=>{
this.showToastTip("已发送")
...
...
@@ -168,22 +141,8 @@ struct ForgetPasswordPage {
if (this.isEmpty(this.codeContent)) {
return
}
if(this.pageType == 1){
this.loginViewModel.checkVerifyCodeByToken(this.codeContent).then(()=>{
let params: SettingPasswordParams = {
pageID:'1',
phoneContent:this.phoneContent,
codeContent:this.codeContent,
pageType:this.pageType
}
WDRouterRule.jumpWithPage(WDRouterPage.settingPasswordPage, params)
}).catch((message: string)=>{
this.showToastTip(message)
})
return
}
if(this.p
ageType == 0 && this.p
honeContent.indexOf("****")!=-1){
if(this.phoneContent.indexOf("****")!=-1){
this.loginViewModel.checkVerifyCodeByToken(this.codeContent).then(()=>{
let params: SettingPasswordParams = {
pageID:'1',
...
...
@@ -203,7 +162,7 @@ struct ForgetPasswordPage {
pageID:'1',
phoneContent:this.phoneContent,
codeContent:this.codeContent,
pageType:
this.pageType
pageType:
0
}
WDRouterRule.jumpWithReplacePage(WDRouterPage.settingPasswordPage, params)
...
...
@@ -218,53 +177,6 @@ struct ForgetPasswordPage {
return (obj == undefined || obj == null || obj == '');
}
changeBindPhone(){
if (!this.isSubmit) {
return
}
if (this.isEmpty(this.phoneContent)) {
return
}
if (this.isEmpty(this.codeContent)) {
return
}
this.loginViewModel.changeBindPhone(this.phoneContent,this.codeContent).then(()=>{
ToastUtils.shortToast('绑定成功')
this.querySecurity()
}).catch((message: string) => {
if (message != '') {
ToastUtils.shortToast(message)
}
})
}
querySecurity(){
this.loginViewModel.querySecurity().then(()=>{
SPHelper.default.save(SpConstants.USER_PHONE,this.phoneContent)
this.sendEmitEvent()
router.back()
}).catch(()=>{
})
}
sendEmitEvent(){
// 定义一个eventId为1的事件,事件优先级为Low
let event: emitter.InnerEvent = {
eventId: EmitterEventId.PHONE_CHANGE_SUCCESS,
priority: emitter.EventPriority.LOW
};
let eventData: emitter.EventData = {
data: {
content: this.phoneContent,
}
};
// 发送eventId为1的事件,事件内容为eventData
emitter.emit(event, eventData);
}
showToastTip(msg:string){
this.toastText = msg
this.dialogToast.open()
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginInputComponent.ets
View file @
4350677
...
...
@@ -10,7 +10,7 @@ export struct LoginInputComponent {
@Link isCodeSend: boolean //验证码控件是否点击 默认没有 发送接口
@Link isSubmit: boolean //是否可以提交
isFirst:boolean=true//是否第一次获取验证码
pageType?:number; //0、登录->忘记密码
3、设置->更换手机号页面2
pageType?:number; //0、登录->忘记密码
lastTime: number = 0
@Link @Watch('startCount') codeStateSuccess: boolean //验证码获取成功与否回调 成功显示倒计时
@Watch('onCheckChange') @Prop protocolState: boolean = false //协议勾选状态
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginPage.ets
View file @
4350677
...
...
@@ -177,11 +177,10 @@ struct LoginPage {
.onClick(() => {
TrackingButton.click("loginPageForgotPassword",TrackConstants.PageName.Login_Page,TrackConstants.PageName.Login_Page)
if(StringUtils.isNotEmpty(this.accountContent) && StringUtils.photoMatch(this.accountContent)){
let pageType = { 'p
ageType': 0, 'p
hone': Number(this.accountContent) } as Record<string, number>;
let pageType = { 'phone': Number(this.accountContent) } as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
}else{
let pageType = { 'pageType': 0 } as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage)
}
})
}
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/ModifyPasswordPage.ets
View file @
4350677
...
...
@@ -166,8 +166,7 @@ struct ModifyPasswordPage {
Column() {
Text("忘记密码").fontSize(12).maxLines(3).fontColor(0x999999).padding({top:'10lpx'})
.onClick(()=>{
let pageType = { 'pageType': 0 } as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage)
})
}
.width('100%')
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/SettingPasswordLayout.ets
deleted
100644 → 0
View file @
87db937
import ArrayList from '@ohos.util.ArrayList';
import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/Index';
import router from '@ohos.router';
import { LoginViewModel } from './LoginViewModel';
import { CustomToast, Logger, SPHelper, ToastUtils } from 'wdKit';
import {
SpConstants
} from '../../../../../../../commons/wdNetwork/oh_modules/wdConstant/src/main/ets/constants/SpConstants'
import data_preferences from '@ohos.data.preferences';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
const TAG = "SettingPasswordLayout"
export interface SettingPasswordParams {
pageID: string;
phoneContent?: string;
codeContent?: string;
tempToken?:string;
pageType?:number; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2
}
export default class AccoutPageDataModel {
// 页面数据
compType: number // 0:标题 / 1:密码输入框 / 2:验证码输入框 / 3:desc描述 / 4:按钮 / 5:logo / 6:子标题 7:手机号输入框 7:空白
compLogo: string
compTitle: string
compSubTitle: string = '';
compDesc: string
compButtonTitle: string
inputPlacholder: string
inputTag: number
constructor(compType: number, compTitle: string, compLogo: string, compDesc: string, compButtonTitle: string, inputPlacholder: string, inputTag: number) {
this.compType = compType
this.compTitle = compTitle
this.compLogo = compLogo
this.compDesc = compDesc
this.compButtonTitle = compButtonTitle
this.inputPlacholder = inputPlacholder
this.inputTag = inputTag
}
}
@Entry
@Component
export struct SettingPasswordLayout {
@State listData: Array<AccoutPageDataModel> = new Array(); // 页面配置数据
@State btnStatus: boolean = false;
pageId:number = 0;
phoneContent:string = '';
codeContent:string = '';
tempToken:string = '';
password01: string = '';
password02: string = '';
passwordOri: string = '';
loginViewModel = new LoginViewModel()
pageType?:number; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机
@State toastText:string = ""
dialogToast: CustomDialogController = new CustomDialogController({
builder: CustomToast({
msg: this.toastText,
}),
autoCancel: false,
alignment: DialogAlignment.Center,
customStyle: true,
maskColor:"#00000000"
})
aboutToAppear() {
let params:SettingPasswordParams = router.getParams() as SettingPasswordParams;
this.pageId = parseInt(params.pageID);
this.getPageListData(this.pageId)
this.phoneContent = params.phoneContent!;
this.codeContent = params.codeContent!;
this.pageType = params.pageType;
}
getPageListData(pageId:number) {
switch (pageId) {
case 0:
// 验证/更换手机号
this.listData.push(new AccoutPageDataModel(0, '更换手机号', '', '', '', '', 0))
this.listData.push(new AccoutPageDataModel(7, '', '', '', '', '请输入手机号', 10010))
this.listData.push(new AccoutPageDataModel(2, '', '', '', '', '验证码', 10088))
this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
break;
case 1:
// 设置密码
this.listData.push(new AccoutPageDataModel(0, '设置密码', '', '', '', '', 0))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入密码', 10086))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '再次输入密码', 10087))
this.listData.push(new AccoutPageDataModel(3, '', '', '提示:密码长度6~20位,使用大写字母、小写字母、数字、特殊字符中三种或三种以上', '', '', 0))
this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
break;
case 2:
// 修改密码
this.listData.push(new AccoutPageDataModel(0, '修改密码', '', '', '', '', 0))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入原密码', 10010))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入新密码', 10086))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请再请输入原密码', 10087))
this.listData.push(new AccoutPageDataModel(3, '', '', '提示:密码长度6~20位,使用大写字母、小写字母、数字、特殊字符中三种或三种以上', '', '', 0))
this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
this.listData.push(new AccoutPageDataModel(3, '', '', '忘记密码', '', '', 0))
break;
case 3:
// 绑定手机号
this.listData.push(new AccoutPageDataModel(0, '绑定手机号', '', '', '', '', 0))
this.listData.push(new AccoutPageDataModel(7, '', '', '', '', '请输入手机号', 10010))
this.listData.push(new AccoutPageDataModel(2, '', '', '', '', '验证码', 10088))
this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
break;
case 4:
// 有logo的
this.listData.push(new AccoutPageDataModel(5, '', '', '', '', '' , 0))
this.listData.push(new AccoutPageDataModel(0, '修改密码', '', '', '', '', 0))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入原密码', 10010))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入新密码', 10086))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请再请输入原密码', 10087))
this.listData.push(new AccoutPageDataModel(2, '', '', '', '', '验证码', 10088))
this.listData.push(new AccoutPageDataModel(3, '', '', '提示:密码长度6~20位,使用大写字母、小写字母、数字、特殊字符中三种或三种以上', '', '', 0))
this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
this.listData.push(new AccoutPageDataModel(3, '', '', '忘记密码', '', '', 0))
break;
default:
break;
}
}
build() {
Navigation() {
this.settingList() //滑动区域
}.titleMode(NavigationTitleMode.Mini)
.title('')
}
// 页面布局
@Builder settingList() {
Column() {
List() {
ForEach(this.listData, (item: AccoutPageDataModel, index: number) => {
ListItem() {
if (item.compType == 0) {
this.getTitleCell(item, HorizontalAlign.Start)
} else if (item.compType == 1) {
this.getPasswordCell(item)
} else if (item.compType == 2) {
this.getCodeCell(item)
} else if (item.compType == 3) {
if (index == this.listData.length - 1) {
this.getDescCell(item, HorizontalAlign.Center)
} else {
this.getDescCell(item, HorizontalAlign.Start)
}
} else if (item.compType == 4) {
this.getButtonCell(item)
} else if (item.compType == 5) {
this.getLogoCell(item)
} else if (item.compType == 7) {
this.getPhoneCell(item)
} else {
Text('' + item.compType)
}
}
})
}
// .divider({
// strokeWidth: 1,
// startMargin: 15,
// endMargin: 10,
// color: '#f0f0f0'
// })
}.width('100%').padding('30lpx')
}
/***************************** UI元素 ******************************************/
// 标题
@Builder getTitleCell(item: AccoutPageDataModel, alignTitle: HorizontalAlign) {
Column() {
Text(item.compTitle).fontWeight(FontWeight.Bold).fontSize(20).maxLines(1)
}
.width('100%')
.height('75lpx')
.alignItems(alignTitle)
}
// 密码输入框
@Builder getPasswordCell(item: AccoutPageDataModel) {
Row() {
Row() {
TextInput({ placeholder: item.inputPlacholder })
.placeholderColor("#CCCCCC")
.passwordIcon({onIconSrc:$r("app.media.login_password_on"),offIconSrc:$r("app.media.login_password_off")})
.type(InputType.Password)
.showPasswordIcon(true)
.backgroundColor('#00000000')
.onChange((value: string) => {
this.inputTextChange(value, item.inputTag)
})
.onSubmit((EnterKeyType) => {
this.showToastTip('submit')
})
}
.alignItems(VerticalAlign.Center)
.height('80lpx')
.backgroundColor('#f5f5f5')
.borderRadius('4vp')
}
.width('100%')
.height('110lpx')
.backgroundColor(0xffffff0)
.alignItems(VerticalAlign.Center)
}
// 手机号输入框
@Builder getPhoneCell(item: AccoutPageDataModel) {
Row() {
Row() {
TextInput({ placeholder: item.inputPlacholder })
.placeholderColor("#CCCCCC")
.backgroundColor('#00000000')
.onChange((value: string) => {
this.inputTextChange(value, item.inputTag)
})
.onSubmit((EnterKeyType) => {
this.showToastTip('submit')
})
}
.alignItems(VerticalAlign.Center)
.height('80lpx')
.backgroundColor('#f5f5f5')
.borderRadius('4vp')
}
.width('100%')
.height('110lpx')
.backgroundColor(0xffffff0)
.alignItems(VerticalAlign.Center)
}
// 验证码码输入框
@Builder getCodeCell(item: AccoutPageDataModel) {
Row() {
Stack() {
Image($r('app.media.get_code_bg')).width('100%').borderRadius('4vp')
Row() {
TextInput({ placeholder: item.inputPlacholder })
.placeholderColor("#CCCCCC")
.backgroundColor('#00000000')
.width('67.28%')
.onChange((value: string) => {
this.inputTextChange(value, item.inputTag)
})
Button('发送验证码')
.width('32.71%')
.backgroundColor('#00000000')
.fontColor('#da3e22')
}
.width('100%')
}.height('80lpx')
}
.width('100%')
.height('110lpx')
.backgroundColor(0xffffff0)
.alignItems(VerticalAlign.Center)
}
// desc
@Builder getDescCell(item: AccoutPageDataModel, alignTitle: HorizontalAlign) {
Column() {
Text(item.compDesc).fontSize(12).maxLines(3).fontColor(0x999999).padding({top:'10lpx'})
.onClick(()=>{
if (item.compDesc == '忘记密码') {
this.showToastTip('密码不符合密码规范')
}
})
}
.width('100%')
.height('85lpx')
.alignItems(alignTitle)
}
// 按钮
@Builder getButtonCell(item: AccoutPageDataModel) {
Row() {
Button(item.compButtonTitle, { type: ButtonType.Normal, stateEffect: true })
.width('100%')
.height('80lpx')
.backgroundColor(this.btnStatus ? '#da3e22' : '#e5856d')
.fontColor('#fff')
.borderRadius('4vp')
.onClick(() => {
this.buttonClick()
})
}
.padding({top:'25lpx'})
.alignItems(VerticalAlign.Center)
.width('100%')
.height('120lpx')
}
// 标题
@Builder getLogoCell(item: AccoutPageDataModel) {
Column() {
Image(item.compLogo).height('150lpx').width('150lpx')
}
.width('100%')
.height('200lpx')
}
/***************************** 事件处理 ******************************************/
// 提交按钮点击事件
async buttonClick() {
if (this.btnStatus) {
// 需要+手机号校验
if (this.password01.length < 6 || this.password01.length > 20) {
this.showToastTip('密码不符合密码规范')
return
}
if (this.password01 != this.password02) {
this.showToastTip('两次输入的密码不一致,请重新输入')
return
}
if(this.pageId == 1){ //设置密码
SPHelper.default.get(SpConstants.USER_TEMP_TOKEN, '').then((str) => {
this.loginViewModel.forgotPassword(this.password01, str.toString()).then((data =>{
if (this.pageType == 0) {//登录页
this.showToastTip("修改成功")
router.back({
url: `${WDRouterPage.getLoginBundleInfo()}`
})
}else if(this.pageType == 1){//设置
let params: Params = {
pageID: 'AccountAndSecurityLayout'
}
this.showToastTip("修改成功")
router.back({
params:params,
url: `${WDRouterPage.getSettingBundleInfo()}`
})
// WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params)
}
}))
.catch((err: string) => {
this.showToastTip(err)
});
}).catch((err: string) => {
this.showToastTip(err)
Logger.error(TAG, 'catch err:' + JSON.stringify(err));
});
}
}
}
// 输入框数据变动:输入数据处理
inputTextChange(text: string, tag: number) {
if (tag == 10086) {
this.password01 = text;
} else if (tag == 10087) {
this.password02 = text;
} else {
this.passwordOri = text;
}
if (this.password01) {
if ((this.password01.length >= 6 && this.password01.length <= 20) && (this.password02.length >= 6 && this.password02.length <= 20)) {
this.btnStatus = true;
} else {
this.btnStatus = false;
}
}
}
showToastTip(msg:string){
this.toastText = msg
this.dialogToast.open()
}
}
sight_harmony/features/wdLogin/src/main/ets/pages/login/SettingPasswordPage.ets
View file @
4350677
import { SettingPasswordLayout } from './SettingPasswordLayout';
import ArrayList from '@ohos.util.ArrayList';
import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/Index';
import router from '@ohos.router';
import { LoginViewModel } from './LoginViewModel';
import { CustomToast, DateTimeUtils, Logger, SPHelper, ToastUtils } from 'wdKit';
import {
SpConstants
} from '../../../../../../../commons/wdNetwork/oh_modules/wdConstant/src/main/ets/constants/SpConstants'
import data_preferences from '@ohos.data.preferences';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import { TrackingPageBrowse, TrackConstants, TrackingButton } from 'wdTracking/Index';
const TAG = "SettingPasswordLayout"
export interface SettingPasswordParams {
pageID: string;
phoneContent?: string;
codeContent?: string;
tempToken?:string;
pageType?:number; //0、登录->忘记密码 1、设置->重置密码
}
export default class AccoutPageDataModel {
// 页面数据
compType: number // 0:标题 / 1:密码输入框 / 2:验证码输入框 / 3:desc描述 / 4:按钮 / 5:logo / 6:子标题 7:手机号输入框 7:空白
compLogo: string
compTitle: string
compSubTitle: string = '';
compDesc: string
compButtonTitle: string
inputPlacholder: string
inputTag: number
constructor(compType: number, compTitle: string, compLogo: string, compDesc: string, compButtonTitle: string, inputPlacholder: string, inputTag: number) {
this.compType = compType
this.compTitle = compTitle
this.compLogo = compLogo
this.compDesc = compDesc
this.compButtonTitle = compButtonTitle
this.inputPlacholder = inputPlacholder
this.inputTag = inputTag
}
}
@Entry
@Component
struct SettingPasswordPage {
@State message: string = 'Hello World'
export struct SettingPasswordPage {
@State listData: Array<AccoutPageDataModel> = new Array(); // 页面配置数据
@State btnStatus: boolean = false;
pageId:number = 0;
phoneContent:string = '';
codeContent:string = '';
tempToken:string = '';
password01: string = '';
password02: string = '';
passwordOri: string = '';
loginViewModel = new LoginViewModel()
pageType?:number; //0、登录->忘记密码 1、设置->重置密码
@State toastText:string = ""
dialogToast: CustomDialogController = new CustomDialogController({
builder: CustomToast({
msg: this.toastText,
}),
autoCancel: false,
alignment: DialogAlignment.Center,
customStyle: true,
maskColor:"#00000000"
})
pageShowResetTime:number = 0;
pageHideResetTime:number = 0;
pageShowSetTime:number = 0;
pageHideSetTime:number = 0;
onPageShow(): void {
if (this.pageType === 0){//重置密码
this.pageShowResetTime = DateTimeUtils.getTimeStamp()
}else{
this.pageShowSetTime = DateTimeUtils.getTimeStamp()
}
}
onPageHide(): void {
if (this.pageType === 0){
this.pageHideResetTime = DateTimeUtils.getTimeStamp()
}else{
this.pageHideSetTime = DateTimeUtils.getTimeStamp()
}
let duration = 0
if(this.pageType === 0){
duration = Math.floor((this.pageHideResetTime - this.pageShowResetTime)/1000)
}else{
duration = Math.floor((this.pageHideSetTime - this.pageShowSetTime)/1000)
}
if(this.pageType === 0){
TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Reset_Password,TrackConstants.PageName.Reset_Password,duration)
}else{
TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Setup_Passwd,TrackConstants.PageName.Setup_Passwd,duration)
}
}
aboutToAppear() {
let params:SettingPasswordParams = router.getParams() as SettingPasswordParams;
this.pageId = parseInt(params.pageID);
this.getPageListData(this.pageId)
this.phoneContent = params.phoneContent!;
this.codeContent = params.codeContent!;
this.pageType = params.pageType;
}
getPageListData(pageId:number) {
switch (pageId) {
case 0:
break;
case 1:
// 设置密码
this.listData.push(new AccoutPageDataModel(0, '设置密码', '', '', '', '', 0))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入密码', 10086))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '再次输入密码', 10087))
this.listData.push(new AccoutPageDataModel(3, '', '', '提示:密码长度6~20位,使用大写字母、小写字母、数字、特殊字符中三种或三种以上', '', '', 0))
this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
break;
case 2:
break;
case 3:
break;
case 4:
break;
}
}
build() {
Navigation() {
this.settingList() //滑动区域
}.titleMode(NavigationTitleMode.Mini)
.title('')
}
// 页面布局
@Builder settingList() {
Column() {
List() {
ForEach(this.listData, (item: AccoutPageDataModel, index: number) => {
ListItem() {
if (item.compType == 0) {
this.getTitleCell(item, HorizontalAlign.Start)
} else if (item.compType == 1) {
this.getPasswordCell(item)
} else if (item.compType == 2) {
this.getCodeCell(item)
} else if (item.compType == 3) {
if (index == this.listData.length - 1) {
this.getDescCell(item, HorizontalAlign.Center)
} else {
this.getDescCell(item, HorizontalAlign.Start)
}
} else if (item.compType == 4) {
this.getButtonCell(item)
} else if (item.compType == 5) {
this.getLogoCell(item)
} else if (item.compType == 7) {
this.getPhoneCell(item)
} else {
Text('' + item.compType)
}
}
})
}
}.width('100%')
.padding('30lpx')
.height('100%')
}
/***************************** UI元素 ******************************************/
// 标题
@Builder getTitleCell(item: AccoutPageDataModel, alignTitle: HorizontalAlign) {
Column() {
Text(item.compTitle).fontWeight(FontWeight.Bold).fontSize(20).maxLines(1)
}
.width('100%')
.height('75lpx')
.alignItems(alignTitle)
}
// 密码输入框
@Builder getPasswordCell(item: AccoutPageDataModel) {
Row() {
Column() {
SettingPasswordLayout()
Row() {
TextInput({ placeholder: item.inputPlacholder })
.placeholderColor("#CCCCCC")
.passwordIcon({onIconSrc:$r("app.media.login_password_on"),offIconSrc:$r("app.media.login_password_off")})
.type(InputType.Password)
.showPasswordIcon(true)
.backgroundColor('#00000000')
.onChange((value: string) => {
this.inputTextChange(value, item.inputTag)
})
.onSubmit((EnterKeyType) => {
this.showToastTip('submit')
})
}
.width('100%')
.alignItems(VerticalAlign.Center)
.height('80lpx')
.backgroundColor('#f5f5f5')
.borderRadius('4vp')
}
.height('100%')
.width('100%')
.height('110lpx')
.backgroundColor(0xffffff0)
.alignItems(VerticalAlign.Center)
}
// 手机号输入框
@Builder getPhoneCell(item: AccoutPageDataModel) {
Row() {
Row() {
TextInput({ placeholder: item.inputPlacholder })
.placeholderColor("#CCCCCC")
.backgroundColor('#00000000')
.onChange((value: string) => {
this.inputTextChange(value, item.inputTag)
})
.onSubmit((EnterKeyType) => {
this.showToastTip('submit')
})
}
.alignItems(VerticalAlign.Center)
.height('80lpx')
.backgroundColor('#f5f5f5')
.borderRadius('4vp')
}
.width('100%')
.height('110lpx')
.backgroundColor(0xffffff0)
.alignItems(VerticalAlign.Center)
}
// 验证码码输入框
@Builder getCodeCell(item: AccoutPageDataModel) {
Row() {
Stack() {
Image($r('app.media.get_code_bg')).width('100%').borderRadius('4vp')
Row() {
TextInput({ placeholder: item.inputPlacholder })
.placeholderColor("#CCCCCC")
.backgroundColor('#00000000')
.width('67.28%')
.onChange((value: string) => {
this.inputTextChange(value, item.inputTag)
})
Button('发送验证码')
.width('32.71%')
.backgroundColor('#00000000')
.fontColor('#da3e22')
}
.width('100%')
}.height('80lpx')
}
.width('100%')
.height('110lpx')
.backgroundColor(0xffffff0)
.alignItems(VerticalAlign.Center)
}
// desc
@Builder getDescCell(item: AccoutPageDataModel, alignTitle: HorizontalAlign) {
Column() {
Text(item.compDesc).fontSize(12).maxLines(3).fontColor(0x999999).padding({top:'10lpx'})
.onClick(()=>{
if (item.compDesc == '忘记密码') {
this.showToastTip('密码不符合密码规范')
}
})
}
.width('100%')
.height('85lpx')
.alignItems(alignTitle)
}
// 按钮
@Builder getButtonCell(item: AccoutPageDataModel) {
Row() {
Button(item.compButtonTitle, { type: ButtonType.Normal, stateEffect: true })
.width('100%')
.height('80lpx')
.backgroundColor(this.btnStatus ? '#da3e22' : '#e5856d')
.fontColor('#fff')
.borderRadius('4vp')
.onClick(() => {
this.buttonClick()
})
}
.padding({top:'25lpx'})
.alignItems(VerticalAlign.Center)
.width('100%')
.height('120lpx')
}
// 标题
@Builder getLogoCell(item: AccoutPageDataModel) {
Column() {
Image(item.compLogo).height('150lpx').width('150lpx')
}
.width('100%')
.height('200lpx')
}
}
\ No newline at end of file
/***************************** 事件处理 ******************************************/
// 提交按钮点击事件
async buttonClick() {
if (this.btnStatus) {
if(this.pageType === 0){
TrackingButton.click("resetPasswordPageConfirmButton",TrackConstants.PageName.Reset_Password,TrackConstants.PageName.Reset_Password)
}else{
TrackingButton.click("setPasswordPageConfirm",TrackConstants.PageName.Setup_Passwd,TrackConstants.PageName.Setup_Passwd)
}
// 需要+手机号校验
if (this.password01.length < 6 || this.password01.length > 20) {
this.showToastTip('密码不符合密码规范')
return
}
if (this.password01 != this.password02) {
this.showToastTip('两次输入的密码不一致,请重新输入')
return
}
if(this.pageId == 1){ //设置密码
SPHelper.default.get(SpConstants.USER_TEMP_TOKEN, '').then((str) => {
this.loginViewModel.forgotPassword(this.password01, str.toString()).then((data =>{
if (this.pageType == 0) {//登录页
this.showToastTip("修改成功")
router.back({
url: `${WDRouterPage.getLoginBundleInfo()}`
})
}else if(this.pageType == 1){//设置
let params: Params = {
pageID: 'AccountAndSecurityLayout'
}
this.showToastTip("修改成功")
router.back({
params:params,
url: `${WDRouterPage.getSettingBundleInfo()}`
})
}
}))
.catch((err: string) => {
this.showToastTip(err)
});
}).catch((err: string) => {
this.showToastTip(err)
Logger.error(TAG, 'catch err:' + JSON.stringify(err));
});
}
}
}
// 输入框数据变动:输入数据处理
inputTextChange(text: string, tag: number) {
if (tag == 10086) {
this.password01 = text;
} else if (tag == 10087) {
this.password02 = text;
} else {
this.passwordOri = text;
}
if (this.password01) {
if ((this.password01.length >= 6 && this.password01.length <= 20) && (this.password02.length >= 6 && this.password02.length <= 20)) {
this.btnStatus = true;
} else {
this.btnStatus = false;
}
}
}
showToastTip(msg:string){
this.toastText = msg
this.dialogToast.open()
}
}
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/VerifyPhoneNumberPage.ets
View file @
4350677
import { CustomToast, DateTimeUtils, Logger, SPHelper } from 'wdKit/Index'
import { WDRouterRule, WDRouterPage } from 'wdRouter/Index'
import { LoginViewModel } from './LoginViewModel'
import { SettingPasswordParams } from './SettingPassword
Layout
'
import { SettingPasswordParams } from './SettingPassword
Page
'
import { router } from '@kit.ArkUI'
import { SpConstants } from 'wdConstant/Index'
import { TrackingPageBrowse, TrackConstants, TrackingButton } from 'wdTracking/Index'
...
...
sight_harmony/features/wdLogin/src/main/resources/base/profile/main_pages.json
View file @
4350677
...
...
@@ -5,7 +5,6 @@
"pages/login/ForgetPasswordPage"
,
"pages/login/LoginProtocolWebview"
,
"pages/login/SettingPasswordPage"
,
"pages/login/SettingPasswordLayout"
,
"pages/guide/GuidePages"
,
"pages/login/OneKeyLoginPage"
,
"pages/login/ModifyPasswordPage"
,
...
...
Please
register
or
login
to post a comment