PrivacyPage.ets 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import { AppStorageKeyCollect, BasicType, YTAvoid, YTRequest, yTRouter } from 'basic'
  2. import { webview } from '@kit.ArkWeb'
  3. @ComponentV2
  4. struct PrivacyPage {
  5. @Local safeTop: number = 30
  6. // 倒计时
  7. @Local time: number = 5
  8. private webviewController: WebviewController = new webview.WebviewController()
  9. private forEach: Array<BasicType> = [
  10. {
  11. text: '隐私政策',
  12. message: 'https://hm-static.ytpm.net/friend/doc/%E9%9A%90%E7%A7%81%E6%94%BF%E7%AD%96.html'
  13. }, {
  14. text: '用户协议',
  15. message: 'https://hm-static.ytpm.net/friend/doc/%E7%94%A8%E6%88%B7%E5%8D%8F%E8%AE%AE.html'
  16. }
  17. ]
  18. _onBack(){
  19. yTRouter.pop()
  20. return true
  21. }
  22. // 同意
  23. _onConfirm(){
  24. AppStorage.set(AppStorageKeyCollect.FIRST_ENTER_APP, true)
  25. yTRouter.clear()
  26. }
  27. aboutToAppear(): void {
  28. this.safeTop = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
  29. let _c = setInterval(() => {
  30. this.time--
  31. if(this.time == 0) clearInterval(_c)
  32. }, 1000)
  33. }
  34. build() {
  35. NavDestination() {
  36. Column({space: 40}) {
  37. Text('隐私政策及用户协议')
  38. .fontSize(18)
  39. .fontWeight(500)
  40. // Main
  41. Column({space: 10}){
  42. ForEach(this.forEach, (item: BasicType) => {
  43. Column({ space: 8 }) {
  44. Text(item.text)
  45. Row() {
  46. Web({
  47. src: item.message,
  48. controller: this.webviewController,
  49. renderMode: RenderMode.ASYNC_RENDER // 设置渲染模式
  50. })
  51. }
  52. .height(225)
  53. .width('100%')
  54. .padding(8)
  55. .border({ width: 1 })
  56. }
  57. .alignItems(HorizontalAlign.Start)
  58. })
  59. Blank().height(10)
  60. Row(){
  61. Text('我不同意并返回')
  62. .fontSize(16)
  63. .fontWeight(400)
  64. .fontColor('#676767')
  65. .onClick(() => { this._onBack() })
  66. Text(`我已全部了解${this.time != 0 ? ' ('+this.time+')' : '' }`)
  67. .fontSize(18)
  68. .fontWeight(500)
  69. .borderRadius(20)
  70. .fontColor('#FAFAFA')
  71. .enabled(this.time == 0)
  72. .backgroundColor(this.time == 0 ?'#7186F9' : '#ffacbaf3')
  73. .padding({ left: 20, top: 8, right: 20, bottom: 8 })
  74. .onClick(() => { this._onConfirm() })
  75. }
  76. .width('100%')
  77. .padding({top: 5, bottom: 5})
  78. .alignItems(VerticalAlign.Center)
  79. .justifyContent(FlexAlign.SpaceBetween )
  80. Row(){
  81. Text('*请仔细阅读以上协议内容,点击同意表示您已充分理解并接受协议条款')
  82. .fontSize(10)
  83. .fontWeight(400)
  84. .fontColor('#F50000')
  85. }
  86. .padding({top: 5})
  87. .width("100%")
  88. .justifyContent(FlexAlign.Center)
  89. }
  90. .width('100%')
  91. .layoutWeight(1)
  92. .alignItems(HorizontalAlign.Start)
  93. .justifyContent(FlexAlign.Start)
  94. }
  95. .width('100%')
  96. .height('100%')
  97. .padding({left: 16, right: 16})
  98. .alignItems(HorizontalAlign.Center)
  99. .justifyContent(FlexAlign.Center)
  100. }
  101. .hideTitleBar(true)
  102. .padding({ top: this.safeTop })
  103. .onBackPressed(() => { return this._onBack() })
  104. }
  105. }
  106. @Builder
  107. function PrivacyPageBuilder() {
  108. PrivacyPage()
  109. }