LoginPage.ets 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import { YTAvoid, yTRouter } from 'basic'
  2. import { LoginCollect } from 'basic/src/main/ets/models/LoginCollect'
  3. import { RegisterOrResetPassComp } from '../views/RegisterOrResetPassView'
  4. import { LoginView } from '../views/LoginView'
  5. @Builder
  6. function LoginBuilder() {
  7. NavDestination() {
  8. LoginPage()
  9. }
  10. .hideTitleBar(true)
  11. }
  12. @Component
  13. struct LoginPage {
  14. @StorageProp(YTAvoid.SAFE_TOP_KEY) private safeTop: number = 0
  15. @StorageProp(YTAvoid.SAFE_BOTTOM_KEY) private safeBottom: number = 0
  16. @State private tabBarIndex: number = 0
  17. private tabController: TabsController = new TabsController()
  18. private linearInfo1: LinearGradientOptions = {
  19. colors: [ ['#F7FCF3', 0.1], ['#DEFE9E', 1] ],
  20. angle: 90
  21. }
  22. aboutToAppear(): void {
  23. }
  24. build() {
  25. Column() {
  26. Column() {
  27. Column() {
  28. Text('跳过')
  29. .fontSize(12)
  30. .fontWeight(400)
  31. .alignSelf(ItemAlign.End)
  32. .textAlign(TextAlign.Center)
  33. .fontColor('#3E5100')
  34. .onClick(() => {
  35. yTRouter.routerBack()
  36. })
  37. .height(24)
  38. .width(48)
  39. .borderRadius(12)
  40. .backgroundColor('#4DFFFFFF')
  41. .margin({ bottom: 24, right: 28, top: 20 })
  42. Text('你好,\n欢迎来到盒小仓')
  43. .lineHeight(40)
  44. .fontSize(28)
  45. .fontWeight(600)
  46. .fontColor('#0E2E1A')
  47. }
  48. .padding({ left: 16, })
  49. .height(193)
  50. .width('100%')
  51. .alignItems(HorizontalAlign.Start)
  52. }
  53. .padding({ top: this.safeTop })
  54. .backgroundImage($r('app.media.loginPage_Bg'))
  55. .backgroundImageSize(ImageSize.Cover)
  56. Column(){
  57. Row() {
  58. Text('注册')
  59. .fontSize(16)
  60. .fontWeight(600)
  61. .layoutWeight(1)
  62. .fontColor(this.tabBarIndex == 0 ? '#FF141111' : '#80141111')
  63. .backgroundColor(this.tabBarIndex == 0 || this.tabBarIndex == 2 ? 'rgba(255,255,255,0.5)' : Color.Transparent)
  64. // .linearGradient(this.tabBarIndex == 0 ? this.linearInfo1 : this.linearInfo2)
  65. .textAlign(TextAlign.Center)
  66. .height(48)
  67. .borderRadius({ topLeft: 12, topRight: 12, bottomRight: this.tabBarIndex == 1 ? 12 : 0 })
  68. .onClick(() => {
  69. this.tabBarIndex = 0
  70. this.tabController.changeIndex(0)
  71. })
  72. Text('登录')
  73. .fontSize(16)
  74. .fontWeight(600)
  75. .borderRadius({
  76. topLeft: 12,
  77. topRight: 12,
  78. bottomLeft: this.tabBarIndex == 0 ? 12 : 0
  79. })
  80. .backgroundColor(this.tabBarIndex == 1 ? 'rgba(255,255,255,0.5)' : Color.Transparent)
  81. .layoutWeight(1)
  82. .height(48)
  83. .textAlign(TextAlign.Center)
  84. .fontColor(this.tabBarIndex == 1 || this.tabBarIndex == 2 ? '#FF141111' : '#80141111')
  85. // .linearGradient(this.tabBarIndex == 1 || this.tabBarIndex == 2 ? this.linearInfo1 : this.linearInfo2)
  86. .onClick(() => {
  87. this.tabBarIndex = 1
  88. this.tabController.changeIndex(1)
  89. })
  90. }
  91. .alignItems(VerticalAlign.Center)
  92. .justifyContent(FlexAlign.SpaceBetween)
  93. .width('100%')
  94. .linearGradient(this.linearInfo1)
  95. Tabs({ controller: this.tabController }) {
  96. TabContent() {
  97. RegisterOrResetPassComp({ loginCollect: new LoginCollect("register") })
  98. }
  99. .padding({ left: 20, right: 20 })
  100. TabContent() {
  101. LoginView({
  102. forgetPassClick: () => {
  103. this.tabBarIndex = 2
  104. this.tabController.changeIndex(2)
  105. }
  106. })
  107. }
  108. .padding({ left: 20, right: 20 })
  109. TabContent() {
  110. RegisterOrResetPassComp({ loginCollect: new LoginCollect("reset") })
  111. }
  112. .padding({ left: 20, right: 20 })
  113. }
  114. .scrollable(false)
  115. .layoutWeight(1)
  116. .barHeight(0)
  117. .padding({top: 20})
  118. }
  119. // .backgroundImage(this.tabBarIndex == 0 ? $r('app.media.loginPage_Bg_left') : $r('app.media.loginPage_Bg_right'))
  120. // .backgroundImageSize(ImageSize.Contain)
  121. }
  122. .padding({
  123. bottom: this.safeBottom
  124. })
  125. .height('100%')
  126. }
  127. }