Mine.ets 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import { BarType, copyText, ShowBannerAd, UserInfo, userInfo, YtAvoid, yTRouter } from 'basic'
  2. @Component
  3. export struct Mine {
  4. @StorageProp(YtAvoid.safeTopKey) safeTop: number = 0
  5. @StorageProp(userInfo.KEY) userInfo: UserInfo = new UserInfo()
  6. setArr: Array<BarType<undefined>> = [
  7. // {
  8. // text: 'AI次数兑换',
  9. // click: () => {
  10. // yTRouter.router2AIExchangePage()
  11. // if (this.userInfo.checkLogin()) {
  12. //
  13. // } else {
  14. // //TODO 去登录页
  15. // }
  16. //
  17. // },
  18. // src: $r('app.media.right_arrow')
  19. // },
  20. // {
  21. // text: '意见反馈',
  22. // click: () => {
  23. // yTRouter.router2SuggestionPage()
  24. // if (this.userInfo.checkLogin()) {
  25. //
  26. // } else {
  27. // //TODO 去登录页
  28. // }
  29. //
  30. // },
  31. // src: $r('app.media.right_arrow')
  32. // },
  33. // {
  34. // text: '给个好评',
  35. // click: () => {
  36. //
  37. // },
  38. // src: $r('app.media.right_arrow')
  39. // },
  40. // {
  41. // text: '关于我们',
  42. // click: () => {
  43. // yTRouter.router2AgreementPage('关于我们')
  44. // },
  45. // src: $r('app.media.right_arrow')
  46. // },
  47. // {
  48. // text: '隐私政策',
  49. // click: () => {
  50. // yTRouter.router2AgreementPage('隐私政策')
  51. // },
  52. // src: $r('app.media.right_arrow')
  53. // }
  54. ]
  55. aboutToAppear(): void {
  56. }
  57. build() {
  58. Column() {
  59. Row() {
  60. Row() {
  61. if (this.userInfo.getHeadImg()) {
  62. Image(this.userInfo.getHeadImg())
  63. .aspectRatio(1)
  64. .height(40)
  65. .borderRadius(20)
  66. .margin({ right: 9 })
  67. } else {
  68. Image($r('app.media.app_icon'))
  69. .width(50)
  70. .height(40)
  71. .margin({ right: 9 })
  72. }
  73. Column({ space: 7 }) {
  74. Text(this.userInfo.getName() ?? this.userInfo.getPhoneNumber() ?? this.userInfo.getId()?.toString() ??
  75. '未登录')
  76. .fontSize($r('[basic].float.page_text_font_size_16'))
  77. .fontColor('#FF000000')
  78. Text() {
  79. Span('ID:' + (this.userInfo.getId()?.toString().padStart(8, '0') ?? '00000000'))
  80. ImageSpan($r('app.media.copy'))
  81. .width(7)
  82. .height(8)
  83. .margin({ left: 4 })
  84. .onClick(() => {
  85. copyText((this.userInfo.getId()?.toString().padStart(8, '0') ?? '00000000'))
  86. })
  87. .offset({ bottom: 4 })
  88. }
  89. .fontColor('#80000000')
  90. .fontSize($r('[basic].float.page_text_font_size_10'))
  91. }
  92. .alignItems(HorizontalAlign.Start)
  93. }
  94. .onClick(() => {
  95. if (this.userInfo.checkLogin()) {
  96. yTRouter.router2SettingPage()
  97. return
  98. }
  99. yTRouter.router2LoginPage()
  100. })
  101. }
  102. .width('100%')
  103. .margin({ bottom: 30 })
  104. ShowBannerAd()
  105. List() {
  106. ForEach(this.setArr, (item: BarType<undefined>, index) => {
  107. ListItem() {
  108. Row() {
  109. Text(item.text)
  110. .fontColor('#80000000')
  111. .fontSize(12)
  112. if (!index) {
  113. Row() {
  114. Text(this.userInfo.getAiNum()?.toString() ?? '')
  115. .fontWeight(600)
  116. .fontSize($r('[basic].float.page_text_font_size_14'))
  117. Image($r('app.media.right_arrow'))
  118. .width(24)
  119. .aspectRatio(1)
  120. }
  121. } else {
  122. Image($r('app.media.right_arrow'))
  123. .width(24)
  124. .aspectRatio(1)
  125. }
  126. }
  127. .width('100%')
  128. .height(36)
  129. .justifyContent(FlexAlign.SpaceBetween)
  130. .onClick(() => {
  131. item.click?.()
  132. })
  133. }
  134. })
  135. }
  136. .padding({ left: 12, right: 4 })
  137. .divider({ strokeWidth: 1, color: '#0A000000', endMargin: 8 })
  138. .margin({ top: 30 })
  139. }
  140. .padding({ top: this.safeTop + 22, left: 16, right: 16 })
  141. .height('100%')
  142. }
  143. }