Mine.ets 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import {
  2. BasicType,
  3. copyText,
  4. IBestToast,
  5. userInfo,
  6. UserInfo,
  7. YTAvoid,
  8. YTLog,
  9. yTRouter
  10. } from 'basic'
  11. import { common, Want } from '@kit.AbilityKit'
  12. import { BusinessError } from '@kit.BasicServicesKit'
  13. import { BUNDLE_NAME } from 'BuildProfile'
  14. @Component
  15. export struct Mine {
  16. @StorageProp(YTAvoid.SAFE_TOP_KEY) safeTop: number = 0
  17. @StorageProp(UserInfo.KEY) userInfo: UserInfo = userInfo
  18. setArr: Array<BasicType<undefined>> = [
  19. {
  20. text: '意见反馈',
  21. click: () => {
  22. if (this.userInfo.checkLogin()) {
  23. yTRouter.router2SuggestionPage()
  24. } else {
  25. yTRouter.router2LoginPage()
  26. }
  27. },
  28. src: $r('app.media.right_arrow')
  29. },
  30. {
  31. text: '给个好评',
  32. click: () => {
  33. const want: Want = {
  34. uri: "store://appgallery.huawei.com/app/detail?id=" + BUNDLE_NAME
  35. };
  36. const context = this.getUIContext().getHostContext() as common.UIAbilityContext;
  37. context.startAbility(want).then(() => {
  38. //拉起成功
  39. YTLog.info('跳转成功')
  40. }).catch((err: BusinessError) => {
  41. // 拉起失败
  42. YTLog.error(err)
  43. IBestToast.show('出现未知错误,请稍后再试')
  44. });
  45. },
  46. src: $r('app.media.right_arrow')
  47. },
  48. {
  49. text: '关于我们',
  50. click: () => {
  51. yTRouter.router2AboutUS()
  52. },
  53. src: $r('app.media.right_arrow')
  54. }
  55. ]
  56. aboutToAppear(): void {
  57. }
  58. build() {
  59. Column() {
  60. Row() {
  61. Row() {
  62. Image(this.userInfo.getHeadImg() ?? $r('app.media.app_icon'))
  63. .aspectRatio(1)
  64. .height(40)
  65. .borderRadius(20)
  66. .margin({ right: 9 })
  67. Column({ space: 7 }) {
  68. Text(this.userInfo.getName() ?? this.userInfo.getPhoneNumber() ?? this.userInfo.getId()?.toString() ??
  69. '未登录')
  70. .fontSize($r('[basic].float.page_text_font_size_16'))
  71. .fontColor('Color.Black')
  72. Text() {
  73. Span('ID:' + (this.userInfo.getId()?.toString().padStart(8, '0') ?? '00000000'))
  74. ImageSpan($r('app.media.copy'))
  75. .width(7)
  76. .height(8)
  77. .margin({ left: 4 })
  78. .onClick(() => {
  79. copyText((this.userInfo.getId()?.toString().padStart(8, '0') ?? '00000000'))
  80. })
  81. .offset({ bottom: 4 })
  82. }
  83. .fontColor('#80000000')
  84. .fontSize($r('[basic].float.page_text_font_size_10'))
  85. }
  86. .alignItems(HorizontalAlign.Start)
  87. }
  88. .onClick(() => {
  89. if (this.userInfo.checkLogin()) {
  90. yTRouter.router2SettingPage()
  91. return
  92. }
  93. yTRouter.router2LoginPage()
  94. })
  95. }
  96. .width('100%')
  97. .margin({ bottom: 30 })
  98. // ShowBannerAd()
  99. Column() {
  100. List() {
  101. ForEach(this.setArr, (item: BasicType<undefined>, index) => {
  102. ListItem() {
  103. Row() {
  104. Text(item.text)
  105. .fontColor('#80000000')
  106. .fontSize(12)
  107. if (!index) {
  108. Row() {
  109. Text(this.userInfo.getAiNum()?.toString() ?? '')
  110. .fontWeight(600)
  111. .fontSize($r('[basic].float.page_text_font_size_14'))
  112. Image($r('app.media.right_arrow'))
  113. .width(24)
  114. .aspectRatio(1)
  115. }
  116. } else {
  117. Image($r('app.media.right_arrow'))
  118. .width(24)
  119. .aspectRatio(1)
  120. }
  121. }
  122. .width('100%')
  123. .height(36)
  124. .justifyContent(FlexAlign.SpaceBetween)
  125. .onClick(() => {
  126. item.click?.()
  127. })
  128. }
  129. })
  130. }
  131. .padding({ left: 12, right: 4 })
  132. .divider({ strokeWidth: 1, color: '#0A000000', endMargin: 8 })
  133. .margin({ top: 30 })
  134. .width('100%')
  135. .height('100%')
  136. }
  137. .layoutWeight(1)
  138. .width('100%')
  139. }
  140. .padding({ top: this.safeTop + 22, left: 16, right: 16 })
  141. .height('100%')
  142. }
  143. }