Mine.ets 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import { BasicType, 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<BasicType<undefined>> = [
  7. {
  8. text: '意见反馈',
  9. click: () => {
  10. yTRouter.router2SuggestionPage()
  11. if (this.userInfo.checkLogin()) {
  12. } else {
  13. //TODO 去登录页
  14. }
  15. },
  16. src: $r('app.media.right_arrow')
  17. },
  18. {
  19. text: '给个好评',
  20. click: () => {
  21. },
  22. src: $r('app.media.right_arrow')
  23. },
  24. {
  25. text: '关于我们',
  26. click: () => {
  27. yTRouter.router2AboutUS()
  28. },
  29. src: $r('app.media.right_arrow')
  30. }
  31. ]
  32. aboutToAppear(): void {
  33. }
  34. build() {
  35. Column() {
  36. Row() {
  37. Row() {
  38. if (this.userInfo.getHeadImg()) {
  39. Image(this.userInfo.getHeadImg())
  40. .aspectRatio(1)
  41. .height(40)
  42. .borderRadius(20)
  43. .margin({ right: 9 })
  44. } else {
  45. Image($r('app.media.app_icon'))
  46. .width(50)
  47. .height(40)
  48. .margin({ right: 9 })
  49. }
  50. Column({ space: 7 }) {
  51. Text(this.userInfo.getName() ?? this.userInfo.getPhoneNumber() ?? this.userInfo.getId()?.toString() ??
  52. '未登录')
  53. .fontSize($r('[basic].float.page_text_font_size_16'))
  54. .fontColor('#FF000000')
  55. Text() {
  56. Span('ID:' + (this.userInfo.getId()?.toString().padStart(8, '0') ?? '00000000'))
  57. ImageSpan($r('app.media.copy'))
  58. .width(7)
  59. .height(8)
  60. .margin({ left: 4 })
  61. .onClick(() => {
  62. copyText((this.userInfo.getId()?.toString().padStart(8, '0') ?? '00000000'))
  63. })
  64. .offset({ bottom: 4 })
  65. }
  66. .fontColor('#80000000')
  67. .fontSize($r('[basic].float.page_text_font_size_10'))
  68. }
  69. .alignItems(HorizontalAlign.Start)
  70. }
  71. .onClick(() => {
  72. if (this.userInfo.checkLogin()) {
  73. yTRouter.router2SettingPage()
  74. return
  75. }
  76. yTRouter.router2LoginPage()
  77. })
  78. }
  79. .width('100%')
  80. .margin({ bottom: 30 })
  81. ShowBannerAd()
  82. List() {
  83. ForEach(this.setArr, (item: BasicType<undefined>, index) => {
  84. ListItem() {
  85. Row() {
  86. Text(item.text)
  87. .fontColor('#80000000')
  88. .fontSize(12)
  89. if (!index) {
  90. Row() {
  91. Text(this.userInfo.getAiNum()?.toString() ?? '')
  92. .fontWeight(600)
  93. .fontSize($r('[basic].float.page_text_font_size_14'))
  94. Image($r('app.media.right_arrow'))
  95. .width(24)
  96. .aspectRatio(1)
  97. }
  98. } else {
  99. Image($r('app.media.right_arrow'))
  100. .width(24)
  101. .aspectRatio(1)
  102. }
  103. }
  104. .width('100%')
  105. .height(36)
  106. .justifyContent(FlexAlign.SpaceBetween)
  107. .onClick(() => {
  108. item.click?.()
  109. })
  110. }
  111. })
  112. }
  113. .padding({ left: 12, right: 4 })
  114. .divider({ strokeWidth: 1, color: '#0A000000', endMargin: 8 })
  115. .margin({ top: 30 })
  116. }
  117. .padding({ top: this.safeTop + 22, left: 16, right: 16 })
  118. .height('100%')
  119. }
  120. }