LaunchAdvertisingPage.ets 2.29 KB
import router from '@ohos.router'

@Entry
@Component
struct LaunchAdvertisingPage {
  @State time: number = 4
  timer :number = -1

  enter() {
    router.replaceUrl({
      url:'pages/MainPage'
    })
  }

  onPageShow(){
    this.timer = setInterval(() => {
      this.time--
      if (this.time < 1) {
        this.enter()
        clearInterval(this.timer)
      }
    },1000)

  }

  build(){
    Column(){
      Stack({alignContent:Alignment.Bottom}){

        Stack({alignContent:Alignment.Bottom}){
          Column(){
            Image($r('app.media.app_icon'))
              .margin({
                top:'128lpx',left:'48lpx',right:'48lpx',bottom:'128lpx'
              })
          }
          .justifyContent(FlexAlign.Center)
          .width('100%')
          .height('100%')
          .margin({
            bottom: 0
          })

          Stack({alignContent:Alignment.TopEnd}){
            Button(){
              Text(this.time + 's 跳过')
                .fontSize('27lpx')
                .fontColor(Color.White)
                .margin({left:'28lpx',right:'28lpx'})

            }
            .width('148lpx')
            .height('56lpx')
            .margin({top:'54lpx',right:'19lpx'})
            .backgroundColor('#80000000')
            .onClick(() => {
              this.enter()
            })
          }
          .width('100%')
          .height('100%')

          Button(){
            Row(){
              Text('点击跳转至详情或第三方应用')
                .fontSize('31lpx')
                .fontColor(Color.White)
                .margin({
                  left:'55lpx'
                })
              Image($r('app.media.Slice'))
                .width('46lpx')
                .height('46lpx')
                .margin({right:'55lpx'})
            }.alignItems(VerticalAlign.Center)
          }
          .width('566lpx')
          .height('111lpx')
          .margin({
            bottom: '51lpx'
          })
          .backgroundColor('#80000000')

        }

      }
      .width('100%')
      .height('84%')
      .backgroundColor('#FF6C75')
      .margin({top:'0'})

      Image($r('app.media.LaunchPage_logo'))
        .width('278lpx')
        .height('154lpx')
        .margin({bottom: '48lpx'})
    }
    .width('100%')
    .height('100%')
    .backgroundColor(Color.White)

  }




}