yangchenggong1_wd

desc:登录 忘记密码 适配折叠屏

1 -import { Logger, EmitterEventId, EmitterUtils, DateTimeUtils,CustomToast, StringUtils, NetworkUtil } from 'wdKit' 1 +import { Logger, EmitterEventId, EmitterUtils, DateTimeUtils,CustomToast, StringUtils, NetworkUtil,
  2 + BreakpointSystem } from 'wdKit'
2 import router from '@ohos.router' 3 import router from '@ohos.router'
3 import { LoginViewModel } from './LoginViewModel' 4 import { LoginViewModel } from './LoginViewModel'
4 import { LoginInputComponent } from './LoginInputComponent' 5 import { LoginInputComponent } from './LoginInputComponent'
@@ -56,6 +57,17 @@ struct LoginPage { @@ -56,6 +57,17 @@ struct LoginPage {
56 57
57 loginViewModel = new LoginViewModel() 58 loginViewModel = new LoginViewModel()
58 @State isProtocol:boolean=false 59 @State isProtocol:boolean=false
  60 + @StorageProp('currentBreakpoint') @Watch("currentChanged")currentBreakpoint: string = 'sm';
  61 + private breakpointSystem = new BreakpointSystem();
  62 + @State percent:number = 1
  63 +
  64 + currentChanged(){
  65 + if(this.currentBreakpoint == "md" || this.currentBreakpoint == "lg"){
  66 + this.percent = 0.7
  67 + }else {
  68 + this.percent = 1
  69 + }
  70 + }
59 onCodeSend() { 71 onCodeSend() {
60 Logger.debug(TAG, "isCodeSend:" + this.isCodeSend + "") 72 Logger.debug(TAG, "isCodeSend:" + this.isCodeSend + "")
61 if (this.isCodeSend) { 73 if (this.isCodeSend) {
@@ -66,6 +78,12 @@ struct LoginPage { @@ -66,6 +78,12 @@ struct LoginPage {
66 78
67 aboutToAppear() { 79 aboutToAppear() {
68 Logger.debug(TAG, "aboutToAppear:" + this.isCodeSend + "") 80 Logger.debug(TAG, "aboutToAppear:" + this.isCodeSend + "")
  81 + this.breakpointSystem.register();
  82 + this.currentChanged()
  83 + }
  84 +
  85 + aboutToDisappear(): void {
  86 + this.breakpointSystem.unregister();
69 } 87 }
70 88
71 onPageShow() { 89 onPageShow() {
@@ -144,10 +162,10 @@ struct LoginPage { @@ -144,10 +162,10 @@ struct LoginPage {
144 Text("登录") 162 Text("登录")
145 .borderRadius(4) 163 .borderRadius(4)
146 .fontColor(this.isSubmit ? "#FFFFFFFF" : "#66FFFFFF") 164 .fontColor(this.isSubmit ? "#FFFFFFFF" : "#66FFFFFF")
147 - .fontSize("31lpx") 165 + .fontSize(`${this.calcHeight(31)}lpx`)
148 .fontWeight(400) 166 .fontWeight(400)
149 - .margin({ top: 20 })  
150 - .lineHeight("50lpx") 167 + .margin({ top: `${this.calcHeight(20)}` })
  168 + .lineHeight(`${this.calcHeight(50)}lpx`)
151 .height(44) 169 .height(44)
152 .textAlign(TextAlign.Center) 170 .textAlign(TextAlign.Center)
153 .width("100%") 171 .width("100%")
@@ -170,9 +188,9 @@ struct LoginPage { @@ -170,9 +188,9 @@ struct LoginPage {
170 if (!this.checkCodePage) { 188 if (!this.checkCodePage) {
171 Text('忘记密码') 189 Text('忘记密码')
172 .fontColor('#666666') 190 .fontColor('#666666')
173 - .fontSize("31lpx") 191 + .fontSize(`${this.calcHeight(31)}lpx`)
174 .fontWeight(400) 192 .fontWeight(400)
175 - .lineHeight("38lpx") 193 + .lineHeight(`${this.calcHeight(38)}lpx`)
176 .margin({ top: 16 }) 194 .margin({ top: 16 })
177 .onClick(() => { 195 .onClick(() => {
178 TrackingButton.click("loginPageForgotPassword",TrackConstants.PageName.Login_Page,TrackConstants.PageName.Login_Page) 196 TrackingButton.click("loginPageForgotPassword",TrackConstants.PageName.Login_Page,TrackConstants.PageName.Login_Page)
@@ -217,7 +235,8 @@ struct LoginPage { @@ -217,7 +235,8 @@ struct LoginPage {
217 235
218 ProtocolComponent({ 236 ProtocolComponent({
219 cancelMethod: (): void => this.cancelProtocol(), 237 cancelMethod: (): void => this.cancelProtocol(),
220 - agreeMethod: (): void => this.agreeProtocol() 238 + agreeMethod: (): void => this.agreeProtocol(),
  239 + percent:$percent
221 }) 240 })
222 .visibility(this.isProtocol ? Visibility.Visible : Visibility.None) 241 .visibility(this.isProtocol ? Visibility.Visible : Visibility.None)
223 242
@@ -301,15 +320,15 @@ struct LoginPage { @@ -301,15 +320,15 @@ struct LoginPage {
301 Row() { 320 Row() {
302 Row() { 321 Row() {
303 Image(this.checkCodePage ? $r('app.media.login_qt') : $r('app.media.login_other_password')) 322 Image(this.checkCodePage ? $r('app.media.login_qt') : $r('app.media.login_other_password'))
304 - .size({ width: "35lpx", height: "35lpx" })  
305 - .margin({right:"8lpx"})  
306 - .height("38lpx")  
307 - .width("38lpx") 323 + .size({ width: `${this.calcHeight(35)}lpx`, height: `${this.calcHeight(35)}lpx` })
  324 + .margin({right:`${this.calcHeight(8)}lpx`})
  325 + .height(`${this.calcHeight(38)}lpx`)
  326 + .width(`${this.calcHeight(38)}lpx`)
308 Text(this.checkCodePage ? "密码登录" : "手机号登录") 327 Text(this.checkCodePage ? "密码登录" : "手机号登录")
309 .fontWeight(400) 328 .fontWeight(400)
310 .fontColor("#3D3D3D") 329 .fontColor("#3D3D3D")
311 - .fontSize("23lpx")  
312 - .lineHeight("38lpx") 330 + .fontSize(`${this.calcHeight(23)}lpx`)
  331 + .lineHeight(`${this.calcHeight(38)}lpx`)
313 } 332 }
314 .onClick(() => { 333 .onClick(() => {
315 this.onPageHide() 334 this.onPageHide()
@@ -332,7 +351,7 @@ struct LoginPage { @@ -332,7 +351,7 @@ struct LoginPage {
332 }.height(36) 351 }.height(36)
333 .width('100%') 352 .width('100%')
334 .padding({ left: 25, right: 25 }) 353 .padding({ left: 25, right: 25 })
335 - .margin({ top: "46lpx" }) 354 + .margin({ top: `${this.calcHeight(46)}lpx` })
336 } 355 }
337 .width('100%') 356 .width('100%')
338 .margin({ bottom: 40 }) 357 .margin({ bottom: 40 })
@@ -478,7 +497,9 @@ struct LoginPage { @@ -478,7 +497,9 @@ struct LoginPage {
478 .slide(SlideEffect.Right) 497 .slide(SlideEffect.Right)
479 } 498 }
480 499
481 - 500 + calcHeight(value:number): number{
  501 + return value * this.percent
  502 + }
482 } 503 }
483 504
484 505
@@ -486,41 +507,42 @@ struct LoginPage { @@ -486,41 +507,42 @@ struct LoginPage {
486 struct ProtocolComponent { 507 struct ProtocolComponent {
487 cancelMethod?: () => void 508 cancelMethod?: () => void
488 agreeMethod?: () => void 509 agreeMethod?: () => void
  510 + @Link percent:number
489 511
490 build() { 512 build() {
491 Stack() { 513 Stack() {
492 Column() { 514 Column() {
493 Text("温馨提示") 515 Text("温馨提示")
494 .fontColor("#222222") 516 .fontColor("#222222")
495 - .fontSize("35lpx")  
496 - .lineHeight("50lpx") 517 + .fontSize(`${this.calcHeight(35)}lpx`)
  518 + .lineHeight(`${this.calcHeight(50)}lpx`)
497 .width("100%") 519 .width("100%")
498 .fontWeight(500) 520 .fontWeight(500)
499 .textAlign(TextAlign.Center) 521 .textAlign(TextAlign.Center)
500 - .margin({ top: "38lpx" }) 522 + .margin({ top: `${this.calcHeight(38)}lpx` })
501 Text() { 523 Text() {
502 Span("为保障您的合法权益,请阅读并同意") 524 Span("为保障您的合法权益,请阅读并同意")
503 - .fontSize("27lpx")  
504 - .lineHeight("42lpx") 525 + .fontSize(`${this.calcHeight(27)}lpx`)
  526 + .lineHeight(`${this.calcHeight(42)}lpx`)
505 .fontWeight(400) 527 .fontWeight(400)
506 .fontColor("#666666") 528 .fontColor("#666666")
507 529
508 Span("《用户协议》") 530 Span("《用户协议》")
509 - .fontSize("27lpx")  
510 - .lineHeight("42lpx") 531 + .fontSize(`${this.calcHeight(27)}lpx`)
  532 + .lineHeight(`${this.calcHeight(42)}lpx`)
511 .fontWeight(400) 533 .fontWeight(400)
512 .fontColor("#ED2800") 534 .fontColor("#ED2800")
513 .onClick(() => { 535 .onClick(() => {
514 let bean = { contentID: "1", pageID: "" } as Params 536 let bean = { contentID: "1", pageID: "" } as Params
515 WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean) 537 WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
516 }) 538 })
517 - Span("及").fontSize("27lpx")  
518 - .lineHeight("42lpx") 539 + Span("及").fontSize(`${this.calcHeight(27)}lpx`)
  540 + .lineHeight(`${this.calcHeight(42)}lpx`)
519 .fontWeight(400) 541 .fontWeight(400)
520 .fontColor("#666666") 542 .fontColor("#666666")
521 Span("《隐私政策》") 543 Span("《隐私政策》")
522 - .fontSize("27lpx")  
523 - .lineHeight("42lpx") 544 + .fontSize(`${this.calcHeight(27)}lpx`)
  545 + .lineHeight(`${this.calcHeight(42)}lpx`)
524 .fontWeight(400) 546 .fontWeight(400)
525 .fontColor("#ED2800") 547 .fontColor("#ED2800")
526 .onClick(() => { 548 .onClick(() => {
@@ -528,20 +550,20 @@ struct ProtocolComponent { @@ -528,20 +550,20 @@ struct ProtocolComponent {
528 WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean) 550 WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
529 }) 551 })
530 Span("后进行登录") 552 Span("后进行登录")
531 - .fontSize("27lpx")  
532 - .lineHeight("42lpx") 553 + .fontSize(`${this.calcHeight(27)}lpx`)
  554 + .lineHeight(`${this.calcHeight(42)}lpx`)
533 .fontWeight(400) 555 .fontWeight(400)
534 .fontColor("#666666") 556 .fontColor("#666666")
535 - }.margin({ top: "23lpx", left: "31lpx", right: "31lpx" }) 557 + }.margin({ top: `${this.calcHeight(23)}lpx`, left: `${this.calcHeight(31)}lpx`, right: `${this.calcHeight(31)}lpx` })
536 .wordBreak(WordBreak.BREAK_ALL) 558 .wordBreak(WordBreak.BREAK_ALL)
537 .textAlign(TextAlign.Start) 559 .textAlign(TextAlign.Start)
538 560
539 - Divider().color("#f5f5f5").width("100%").margin({ top: "27lpx" }).height('1lpx').strokeWidth('1lpx') 561 + Divider().color("#f5f5f5").width("100%").margin({ top: `${this.calcHeight(27)}lpx` }).height(`${this.calcHeight(1)}lpx`).strokeWidth(`${this.calcHeight(1)}lpx`)
540 Row() { 562 Row() {
541 Text('放弃登录') 563 Text('放弃登录')
542 - .fontSize("31lpx") 564 + .fontSize(`${this.calcHeight(31)}lpx`)
543 .fontWeight(500) 565 .fontWeight(500)
544 - .lineHeight("42lpx") 566 + .lineHeight(`${this.calcHeight(42)}lpx`)
545 .fontColor("#999999") 567 .fontColor("#999999")
546 .layoutWeight(1) 568 .layoutWeight(1)
547 .textAlign(TextAlign.Center) 569 .textAlign(TextAlign.Center)
@@ -553,17 +575,17 @@ struct ProtocolComponent { @@ -553,17 +575,17 @@ struct ProtocolComponent {
553 .height('100%') 575 .height('100%')
554 576
555 Divider() 577 Divider()
556 - .width("1lpx")  
557 - .strokeWidth('1lpx') 578 + .width(`${this.calcHeight(1)}lpx`)
  579 + .strokeWidth(`${this.calcHeight(1)}lpx`)
558 .vertical(true) 580 .vertical(true)
559 .height('100%') 581 .height('100%')
560 .color("#F5F5F5") 582 .color("#F5F5F5")
561 583
562 584
563 Text('同意并登录') 585 Text('同意并登录')
564 - .fontSize("31lpx") 586 + .fontSize(`${this.calcHeight(31)}lpx`)
565 .fontWeight(500) 587 .fontWeight(500)
566 - .lineHeight("42lpx") 588 + .lineHeight(`${this.calcHeight(42)}lpx`)
567 .fontColor("#ED2800") 589 .fontColor("#ED2800")
568 .layoutWeight(1) 590 .layoutWeight(1)
569 .textAlign(TextAlign.Center) 591 .textAlign(TextAlign.Center)
@@ -582,15 +604,19 @@ struct ProtocolComponent { @@ -582,15 +604,19 @@ struct ProtocolComponent {
582 .justifyContent(FlexAlign.Center) 604 .justifyContent(FlexAlign.Center)
583 } 605 }
584 .backgroundColor(Color.White) 606 .backgroundColor(Color.White)
585 - .borderRadius("12lpx")  
586 - .width("528lpx")  
587 - .height("309lpx") 607 + .borderRadius(`${this.calcHeight(12)}lpx`)
  608 + .width(`${this.calcHeight(528)}lpx`)
  609 + .height(`${this.calcHeight(309)}lpx`)
588 610
589 }.width('100%') 611 }.width('100%')
590 .height('100%') 612 .height('100%')
591 .backgroundColor('#66000000') 613 .backgroundColor('#66000000')
592 614
593 } 615 }
  616 +
  617 + calcHeight(value:number): number{
  618 + return value * this.percent
  619 + }
594 } 620 }
595 621
596 function trackTypeClick(typeValue: number,pageId: string){ 622 function trackTypeClick(typeValue: number,pageId: string){