import { AppStorageKeyCollect, BasicType, YTAvoid, YTRequest, yTRouter } from 'basic' import { webview } from '@kit.ArkWeb' @ComponentV2 struct PrivacyPage { @Local safeTop: number = 30 // 倒计时 @Local time: number = 5 private webviewController: WebviewController = new webview.WebviewController() private forEach: Array = [ { text: '隐私政策', message: 'https://hm-static.ytpm.net/friend/doc/%E9%9A%90%E7%A7%81%E6%94%BF%E7%AD%96.html' }, { text: '用户协议', message: 'https://hm-static.ytpm.net/friend/doc/%E7%94%A8%E6%88%B7%E5%8D%8F%E8%AE%AE.html' } ] _onBack(){ yTRouter.pop() return true } // 同意 _onConfirm(){ AppStorage.set(AppStorageKeyCollect.FIRST_ENTER_APP, true) yTRouter.clear() } aboutToAppear(): void { this.safeTop = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number let _c = setInterval(() => { this.time-- if(this.time == 0) clearInterval(_c) }, 1000) } build() { NavDestination() { Column({space: 40}) { Text('隐私政策及用户协议') .fontSize(18) .fontWeight(500) // Main Column({space: 10}){ ForEach(this.forEach, (item: BasicType) => { Column({ space: 8 }) { Text(item.text) Row() { Web({ src: item.message, controller: this.webviewController, renderMode: RenderMode.ASYNC_RENDER // 设置渲染模式 }) } .height(225) .width('100%') .padding(8) .border({ width: 1 }) } .alignItems(HorizontalAlign.Start) }) Blank().height(10) Row(){ Text('我不同意并返回') .fontSize(16) .fontWeight(400) .fontColor('#676767') .onClick(() => { this._onBack() }) Text(`我已全部了解${this.time != 0 ? ' ('+this.time+')' : '' }`) .fontSize(18) .fontWeight(500) .borderRadius(20) .fontColor('#FAFAFA') .enabled(this.time == 0) .backgroundColor(this.time == 0 ?'#7186F9' : '#ffacbaf3') .padding({ left: 20, top: 8, right: 20, bottom: 8 }) .onClick(() => { this._onConfirm() }) } .width('100%') .padding({top: 5, bottom: 5}) .alignItems(VerticalAlign.Center) .justifyContent(FlexAlign.SpaceBetween ) Row(){ Text('*请仔细阅读以上协议内容,点击同意表示您已充分理解并接受协议条款') .fontSize(10) .fontWeight(400) .fontColor('#F50000') } .padding({top: 5}) .width("100%") .justifyContent(FlexAlign.Center) } .width('100%') .layoutWeight(1) .alignItems(HorizontalAlign.Start) .justifyContent(FlexAlign.Start) } .width('100%') .height('100%') .padding({left: 16, right: 16}) .alignItems(HorizontalAlign.Center) .justifyContent(FlexAlign.Center) } .hideTitleBar(true) .padding({ top: this.safeTop }) .onBackPressed(() => { return this._onBack() }) } } @Builder function PrivacyPageBuilder() { PrivacyPage() }