PrivacyPage.ets 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import { webview } from '@kit.ArkWeb'
  2. import { BasicType } from '../models'
  3. import { router } from '@kit.ArkUI'
  4. import { YTAvoid } from '../utils/YTAvoid'
  5. import { AppStorageKeyCollect } from '../constants'
  6. @Component
  7. @Entry
  8. struct PrivacyPage {
  9. @State safeTop: number = 30
  10. // 倒计时
  11. @State time: number = 5
  12. private webviewController: WebviewController = new webview.WebviewController()
  13. private forEach: Array<BasicType> = [
  14. {
  15. text: '隐私政策',
  16. message: 'https://file.ytmdm.com/小易旅记隐私协议.html'
  17. }, {
  18. text: '用户协议',
  19. message: 'https://file.ytmdm.com/小易旅记用户协议.html'
  20. }
  21. ]
  22. _onBack() {
  23. router.back()
  24. return true
  25. }
  26. // 同意
  27. _onConfirm() {
  28. AppStorage.set(AppStorageKeyCollect.FIRST_ENTER_APP, true)
  29. this.getUIContext().getRouter().pushUrl({
  30. url: 'pages/Index'
  31. })
  32. }
  33. aboutToAppear(): void {
  34. this.safeTop = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
  35. let _c = setInterval(() => {
  36. this.time--
  37. if (this.time == 0) {
  38. clearInterval(_c)
  39. }
  40. }, 1000)
  41. }
  42. build() {
  43. NavDestination() {
  44. Column({ space: 40 }) {
  45. Text('隐私政策及用户协议')
  46. .fontSize(18)
  47. .fontWeight(500)
  48. .fontColor(Color.Black)
  49. // Main
  50. Column({ space: 10 }) {
  51. ForEach(this.forEach, (item: BasicType) => {
  52. Column({ space: 8 }) {
  53. Text(item.text)
  54. .fontColor(Color.Black)
  55. Row() {
  56. Web({
  57. src: item.message,
  58. controller: this.webviewController,
  59. renderMode: RenderMode.ASYNC_RENDER // 设置渲染模式
  60. })
  61. }
  62. .height(225)
  63. .width('100%')
  64. .padding(8)
  65. .border({ width: 1 })
  66. }
  67. .alignItems(HorizontalAlign.Start)
  68. })
  69. Blank().height(10)
  70. Row() {
  71. Text('我不同意并返回')
  72. .fontSize(16)
  73. .fontWeight(400)
  74. .fontColor('#676767')
  75. .onClick(() => {
  76. this._onBack()
  77. })
  78. Text(`我已全部了解${this.time != 0 ? ' (' + this.time + ')' : ''}`)
  79. .fontSize(18)
  80. .fontWeight(500)
  81. .borderRadius(20)
  82. .fontColor('#FAFAFA')
  83. .enabled(this.time == 0)
  84. .backgroundColor(this.time == 0 ? '#7186F9' : '#ffacbaf3')
  85. .padding({
  86. left: 20,
  87. top: 8,
  88. right: 20,
  89. bottom: 8
  90. })
  91. .onClick(() => {
  92. this._onConfirm()
  93. })
  94. }
  95. .width('100%')
  96. .padding({ top: 5, bottom: 5 })
  97. .alignItems(VerticalAlign.Center)
  98. .justifyContent(FlexAlign.SpaceBetween)
  99. Row() {
  100. Text('*请仔细阅读以上协议内容,点击同意表示您已充分理解并接受协议条款')
  101. .fontSize(10)
  102. .fontWeight(400)
  103. .fontColor('#F50000')
  104. }
  105. .padding({ top: 5 })
  106. .width("100%")
  107. .justifyContent(FlexAlign.Center)
  108. }
  109. .width('100%')
  110. .layoutWeight(1)
  111. .alignItems(HorizontalAlign.Start)
  112. .justifyContent(FlexAlign.Start)
  113. }
  114. .width('100%')
  115. .height('100%')
  116. .padding({ left: 16, right: 16 })
  117. .alignItems(HorizontalAlign.Center)
  118. .justifyContent(FlexAlign.Center)
  119. }
  120. .backgroundColor(Color.White)
  121. .hideTitleBar(true)
  122. .padding({ top: this.safeTop })
  123. .onBackPressed(() => {
  124. return this._onBack()
  125. })
  126. }
  127. }