SearchPage.ets 1.31 KB
import { DateTimeUtils } from 'wdKit/Index';
import { TrackingPageBrowse, TrackConstants } from 'wdTracking/Index';
import { SearchComponent } from '../components/search/SearchComponent'
import { router } from '@kit.ArkUI';

@Entry
@Component
struct SearchPage {
  @State params:Record<string, string> =  router.getParams() as Record<string, string>;
  @State fromTabName: string = 'NEWS';
  pageShowTime:number = 0;
  pageHideTime:number = 0;
  @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
  @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0

  onPageShow() {
    this.fromTabName = this.params?.['tabName'];
    this.pageShowTime = DateTimeUtils.getTimeStamp()
  }

  onPageHide(): void {
    this.pageHideTime = DateTimeUtils.getTimeStamp()
    let duration = 0
    duration = Math.floor((this.pageHideTime - this.pageShowTime)/1000)
    TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Search,TrackConstants.PageName.Search,duration)
  }

  build() {
    Column(){
      Column(){
        SearchComponent({fromTabName:$fromTabName})
      }.height('100%')
      .width('100%')
      .backgroundColor($r('app.color.white'))
    }.width("100%")
    .height("100%")
    .padding({top:px2vp(this.topSafeHeight),bottom:px2vp(this.bottomSafeHeight)})
  }
}