DialogTip.ets 1.8 KB
import { noticeRow } from '../api/notice'
import  { HmParseHTML } from "@wuyan/html_parse"
@CustomDialog
export default struct DialogTip{
  controller: CustomDialogController = new CustomDialogController({builder: ''})
  cancel: Function = () => {}
  confirm: Function = () => {}
  @Prop noticeDetail: noticeRow
  @State count: number = 5
  aboutToAppear(): void {
    let timer = setInterval(() => {
      this.count--
      if(this.count <= 0){
        this.count = 0
        clearInterval(timer)
      }
    }, 1000)
  }
  build() {
    Column({space: 10}){
      Text('- 温馨提示 -').fontSize(16).lineHeight(21).fontColor('#fff').fontWeight(600).margin({bottom: 20})
      HmParseHTML({
        htmlStr: this.noticeDetail?.noticeContent || '', // 富文本内容-必传
        baseFontColor: '#fff',
        baseFontSize: 14
      })
      Text(`我已知晓(${this.count}s后可关闭)`)
        .fontSize(16).lineHeight(21).fontColor('#1890ff').fontWeight(600).textAlign(TextAlign.Center)
        .margin({top: 60}).width('100%').border({width: {top: 1}, color: '#fff'}).padding({top: 20, bottom: 20})
        .visibility(this.count > 0 ? Visibility.Visible : Visibility.None)
      Text('我已知晓')
        .fontSize(16).lineHeight(21).fontColor('#1890ff').fontWeight(600).textAlign(TextAlign.Center)
        .margin({top: 60}).width('100%').border({width: {top: 1}, color: '#fff'}).padding({top: 20, bottom: 20})
        .visibility(this.count == 0 ? Visibility.Visible : Visibility.None)
        .onClick(() => {
          this.confirm()
          this.controller.close()
      })
    }.backgroundImage($r('app.media.login_back'))
    .backgroundImageSize({width: '100%'}).width('100%')
    .backgroundImagePosition(Alignment.Center)
    .padding({top: 20,left: 13, right: 13})
  }
}