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-07 18:21:18 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
292113d821467048a033477d07f2ddf8d053ccd2
292113d8
1 parent
d52efc83
fix:bug[16825] 手机验证码登录,输入手机号,验证码,点击2次切换按钮,预期手机号和验证码还在输入框,实际会清空手机号和验证码
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
8 deletions
sight_harmony/commons/wdKit/src/main/ets/utils/StringUtils.ts
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginInputComponent.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginPage.ets
sight_harmony/commons/wdKit/src/main/ets/utils/StringUtils.ts
View file @
292113d
...
...
@@ -125,6 +125,37 @@ export class StringUtils {
static
isScore
(
text
:
string
)
:
boolean
{
return
StringUtils
.
SCORE_REG_EXP
.
test
(
text
);
}
//手机号校验
static
photoMatch
(
phone
:
string
)
:
boolean
{
/**
* 移动号段正则表达式
*/
let
CM_NUM
=
"^((13[4-9])|(147)|(15[0-2,7-9])|(178)|(18[2-4,7-8]))\\d{8}|(1705)\\d{7}$"
;
/**
* 联通号段正则表达式
*/
let
CU_NUM
=
"^((13[0-2])|(145)|(15[5-6])|(176)|(18[5,6]))\\d{8}|(1709)\\d{7}$"
;
/**
* 电信号段正则表达式
*/
let
CT_NUM
=
"^((133)|(153)|(177)|(18[0,1,9]))\\d{8}$"
;
/**
* 官网正则
*/
let
GW_NUM
=
"^1(3|4|5|6|7|8|9)\\d{9}$"
;
let
CM_NUM_reg
:
RegExp
=
new
RegExp
(
CM_NUM
);
let
CU_NUM_reg
:
RegExp
=
new
RegExp
(
CU_NUM
);
let
CT_NUM_reg
:
RegExp
=
new
RegExp
(
CT_NUM
);
let
GW_NUM_reg
:
RegExp
=
new
RegExp
(
GW_NUM
);
if
(
CM_NUM_reg
.
test
(
phone
)
||
CU_NUM_reg
.
test
(
phone
)
||
CT_NUM_reg
.
test
(
phone
)
||
GW_NUM_reg
.
test
(
phone
))
{
return
true
;
}
console
.
log
(
'请输入正确的手机号'
)
return
false
;
}
}
// export default new StringUtils();
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginInputComponent.ets
View file @
292113d
...
...
@@ -22,7 +22,6 @@ export struct LoginInputComponent {
async aboutToAppear(){
if (this.pageType == 1) {
this.phoneContent = await SPHelper.default.get(SpConstants.USER_PHONE,"") as string;
Logger.debug("ddd")
}
}
@Builder
...
...
@@ -48,7 +47,7 @@ export struct LoginInputComponent {
}
})
}else{
TextInput({ placeholder: "请输入手机号" })
TextInput({
text: this.phoneContent,
placeholder: "请输入手机号" })
.fontSize(16)
.height(48)
.placeholderColor("#CCCCCC")
...
...
@@ -70,7 +69,7 @@ export struct LoginInputComponent {
Row() {
TextInput({ placeholder: "验证码" })
TextInput({
text: this.codeContent,
placeholder: "验证码" })
.placeholderColor("#CCCCCC")
.layoutWeight(1)
.fontSize(16)
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginPage.ets
View file @
292113d
import { Logger, EmitterEventId, EmitterUtils, DateTimeUtils,CustomToast } from 'wdKit'
import { Logger, EmitterEventId, EmitterUtils, DateTimeUtils,CustomToast
, StringUtils
} from 'wdKit'
import { CustomProtocolDialog } from './CustomProtocolDialog'
import router from '@ohos.router'
import { LoginViewModel } from './LoginViewModel'
...
...
@@ -38,8 +38,8 @@ struct LoginPage {
@State phoneContent: string = "" //手机号
@State codeContent: string = "" //验证码
@State protocolState: boolean = false //协议勾选状态
accountContent = '' //账号
passwordContent = ''
@State accountContent: string = '' //账号
@State passwordContent: string = ''
@State isSubmit: boolean = false
@State checkCodePage: boolean = true //判断是否是验证码页面 默认验证码登录
@State passwordSwitch: boolean = true //密码显示
...
...
@@ -213,7 +213,7 @@ struct LoginPage {
@Builder
addPassword() {
Column() {
TextInput({ placeholder: "请输入账号", controller: this.phoneController })
TextInput({
text: this.accountContent,
placeholder: "请输入账号", controller: this.phoneController })
.fontSize(16)
.placeholderColor("#CCCCCC")
.height(48)
...
...
@@ -312,8 +312,8 @@ struct LoginPage {
.size({ width: 20, height: 20 })
}.backgroundImage($r('app.media.login_other_right'), ImageRepeat.NoRepeat)
.otherStyle().onClick(() => {
this.updateAccount()
this.checkCodePage = !this.checkCodePage;
this.passwordContent = ''
this.passwordSwitch = true
this.isSubmit = false
})
...
...
@@ -326,6 +326,20 @@ struct LoginPage {
}.width('100%').margin({ bottom: 40 })
}
updateAccount(){
if(this.checkCodePage){
//验证码切换 密码
if(StringUtils.photoMatch(this.phoneContent)){
this.accountContent = this.phoneContent
}
}else{
//密码切换 验证码
if(StringUtils.photoMatch(this.accountContent)){
this.phoneContent = this.accountContent
}
}
}
//发送验证码
sendVerifyCode() {
this.loginViewModel.sendVerifyCode(this.phoneContent).then((verifyCode) => {
...
...
Please
register
or
login
to post a comment