yangchenggong1_wd

fix:bug[16960] 断网,进入登录页,输入手机号码,提示连接出错((undefined),预期发送验证码按钮置灰

@@ -155,9 +155,15 @@ function buildErrorMsg(httpStatus: number): string { @@ -155,9 +155,15 @@ function buildErrorMsg(httpStatus: number): string {
155 case HttpStatusCode.HttpVersionNotSupported: 155 case HttpStatusCode.HttpVersionNotSupported:
156 message = "HTTP版本不受支持(505)"; 156 message = "HTTP版本不受支持(505)";
157 break; 157 break;
158 - default:  
159 - // 网络连接故障  
160 - message = `连接出错(${httpStatus})!`; 158 + default:{
  159 + // 网络连接故障
  160 + if(httpStatus != undefined){
  161 + message = `连接出错(${httpStatus})!`;
  162 + }else{
  163 + message = `连接出错!`;
  164 + }
  165 + }
  166 +
161 } 167 }
162 return message; 168 return message;
163 } 169 }
@@ -5,7 +5,7 @@ import router from '@ohos.router' @@ -5,7 +5,7 @@ import router from '@ohos.router'
5 import { WDRouterRule, WDRouterPage } from 'wdRouter'; 5 import { WDRouterRule, WDRouterPage } from 'wdRouter';
6 import { SettingPasswordParams } from './SettingPasswordLayout' 6 import { SettingPasswordParams } from './SettingPasswordLayout'
7 import { Router } from '@ohos.arkui.UIContext' 7 import { Router } from '@ohos.arkui.UIContext'
8 -import { CustomToast, EmitterEventId, EmitterUtils, SPHelper, ToastUtils } from 'wdKit/Index' 8 +import { CustomToast, EmitterEventId, EmitterUtils, NetworkUtil, SPHelper, ToastUtils } from 'wdKit/Index'
9 import { SpConstants } from 'wdConstant/Index' 9 import { SpConstants } from 'wdConstant/Index'
10 import { emitter } from '@kit.BasicServicesKit' 10 import { emitter } from '@kit.BasicServicesKit'
11 11
@@ -128,7 +128,12 @@ struct ForgetPasswordPage { @@ -128,7 +128,12 @@ struct ForgetPasswordPage {
128 this.isCodeSend=false 128 this.isCodeSend=false
129 Logger.debug(TAG, "sendVerifyCode: " + verifyCode) 129 Logger.debug(TAG, "sendVerifyCode: " + verifyCode)
130 }).catch((message: string)=>{ 130 }).catch((message: string)=>{
131 - this.showToastTip(message) 131 + let netStatus = NetworkUtil.isNetConnected()
  132 + if (netStatus) {
  133 + this.showToastTip(message)
  134 + } else {
  135 + this.showToastTip("验证码获取失败,请重新尝试")
  136 + }
132 this.codeStateSuccess=false 137 this.codeStateSuccess=false
133 this.isCodeSend=false 138 this.isCodeSend=false
134 }) 139 })
@@ -13,12 +13,25 @@ export struct LoginInputComponent { @@ -13,12 +13,25 @@ export struct LoginInputComponent {
13 pageType?:number; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2 13 pageType?:number; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2
14 lastTime: number = 0 14 lastTime: number = 0
15 @Link @Watch('startCount') codeStateSuccess: boolean //验证码获取成功与否回调 成功显示倒计时 15 @Link @Watch('startCount') codeStateSuccess: boolean //验证码获取成功与否回调 成功显示倒计时
  16 + @Watch('onCheckChange') @Prop protocolState: boolean = false //协议勾选状态
  17 + @State isNeedProtocol:boolean = false
  18 +
16 build() { 19 build() {
17 Column() { 20 Column() {
18 this.addCodeLayout() 21 this.addCodeLayout()
19 }.width('100%').padding({ left: 25, right: 25 }) 22 }.width('100%').padding({ left: 25, right: 25 })
20 } 23 }
21 24
  25 + onCheckChange(){
  26 + if(this.isNeedProtocol){
  27 + if(this.protocolState && this.phoneContent.length >= 11){
  28 + this.codeBtnState = true
  29 + }else{
  30 + this.codeBtnState = false
  31 + }
  32 + }
  33 + }
  34 +
22 async aboutToAppear(){ 35 async aboutToAppear(){
23 if (this.pageType == 1) { 36 if (this.pageType == 1) {
24 this.phoneContent = await SPHelper.default.get(SpConstants.USER_PHONE,"") as string; 37 this.phoneContent = await SPHelper.default.get(SpConstants.USER_PHONE,"") as string;
@@ -27,7 +40,7 @@ export struct LoginInputComponent { @@ -27,7 +40,7 @@ export struct LoginInputComponent {
27 @Builder 40 @Builder
28 addCodeLayout() { 41 addCodeLayout() {
29 if (this.pageType == 1){ 42 if (this.pageType == 1){
30 - TextInput({ placeholder: this.securityPhone(this.phoneContent) }) 43 + TextInput({ text: this.securityPhone(this.phoneContent) })
31 .placeholderColor("#CCCCCC") 44 .placeholderColor("#CCCCCC")
32 .fontSize(16) 45 .fontSize(16)
33 .height(48) 46 .height(48)
@@ -59,10 +72,19 @@ export struct LoginInputComponent { @@ -59,10 +72,19 @@ export struct LoginInputComponent {
59 .onChange((content) => { 72 .onChange((content) => {
60 this.phoneContent = content 73 this.phoneContent = content
61 this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 4) 74 this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 4)
62 - if (content.length >= 11) {  
63 - this.codeBtnState = true  
64 - } else {  
65 - this.codeBtnState = false 75 +
  76 + if(this.isNeedProtocol){
  77 + if (content.length >= 11 && this.protocolState) {
  78 + this.codeBtnState = true
  79 + } else {
  80 + this.codeBtnState = false
  81 + }
  82 + }else{
  83 + if (content.length >= 11 ) {
  84 + this.codeBtnState = true
  85 + } else {
  86 + this.codeBtnState = false
  87 + }
66 } 88 }
67 }) 89 })
68 } 90 }
@@ -97,6 +119,12 @@ export struct LoginInputComponent { @@ -97,6 +119,12 @@ export struct LoginInputComponent {
97 if (this.phoneContent.length < 11) { 119 if (this.phoneContent.length < 11) {
98 return 120 return
99 } 121 }
  122 + if(this.isNeedProtocol){
  123 + if (!this.protocolState ) {
  124 + return
  125 + }
  126 + }
  127 +
100 let currentTime = DateTimeUtils.getTimeStamp() 128 let currentTime = DateTimeUtils.getTimeStamp()
101 if (currentTime - this.lastTime < 500) { 129 if (currentTime - this.lastTime < 500) {
102 return 130 return
1 -import { Logger, EmitterEventId, EmitterUtils, DateTimeUtils,CustomToast, StringUtils } from 'wdKit' 1 +import { Logger, EmitterEventId, EmitterUtils, DateTimeUtils,CustomToast, StringUtils, NetworkUtil } from 'wdKit'
2 import { CustomProtocolDialog } from './CustomProtocolDialog' 2 import { CustomProtocolDialog } from './CustomProtocolDialog'
3 import router from '@ohos.router' 3 import router from '@ohos.router'
4 import { LoginViewModel } from './LoginViewModel' 4 import { LoginViewModel } from './LoginViewModel'
@@ -106,7 +106,9 @@ struct LoginPage { @@ -106,7 +106,9 @@ struct LoginPage {
106 codeContent: $codeContent, 106 codeContent: $codeContent,
107 isSubmit: $isSubmit, 107 isSubmit: $isSubmit,
108 isCodeSend: $isCodeSend, 108 isCodeSend: $isCodeSend,
109 - codeStateSuccess:$codeStateSuccess 109 + codeStateSuccess:$codeStateSuccess,
  110 + protocolState:this.protocolState,
  111 + isNeedProtocol:true
110 }) 112 })
111 } else { 113 } else {
112 this.addPassword() 114 this.addPassword()
@@ -347,7 +349,12 @@ struct LoginPage { @@ -347,7 +349,12 @@ struct LoginPage {
347 this.codeStateSuccess=true 349 this.codeStateSuccess=true
348 this.isCodeSend=false 350 this.isCodeSend=false
349 }).catch((message:string)=>{ 351 }).catch((message:string)=>{
350 - this.showToastTip(message) 352 + let netStatus = NetworkUtil.isNetConnected()
  353 + if (netStatus) {
  354 + this.showToastTip(message)
  355 + } else {
  356 + this.showToastTip("验证码获取失败,请重新尝试")
  357 + }
351 this.codeStateSuccess=false 358 this.codeStateSuccess=false
352 this.isCodeSend=false 359 this.isCodeSend=false
353 Logger.debug(TAG, "sendVerifyCode: " + message) 360 Logger.debug(TAG, "sendVerifyCode: " + message)