yangchenggong1_wd

desc:埋点[个人主页(客态) - 页面浏览]

1 import router from '@ohos.router' 1 import router from '@ohos.router'
2 import { Params } from 'wdBean'; 2 import { Params } from 'wdBean';
3 -import { NetworkUtil, StringUtils } from 'wdKit'; 3 +import { DateTimeUtils, NetworkUtil, StringUtils } from 'wdKit';
  4 +import { TrackingPageBrowse, TrackConstants } from 'wdTracking/Index';
4 import { OtherHomePageBottomCommentComponent } from '../components/mine/home/OtherHomePageBottomCommentComponent'; 5 import { OtherHomePageBottomCommentComponent } from '../components/mine/home/OtherHomePageBottomCommentComponent';
5 import { OtherHomePageBottomFollowComponent } from '../components/mine/home/OtherHomePageBottomFollowComponent'; 6 import { OtherHomePageBottomFollowComponent } from '../components/mine/home/OtherHomePageBottomFollowComponent';
6 import { CustomTitleUI } from '../components/reusable/CustomTitleUI'; 7 import { CustomTitleUI } from '../components/reusable/CustomTitleUI';
@@ -16,9 +17,20 @@ struct OtherNormalUserHomePage { @@ -16,9 +17,20 @@ struct OtherNormalUserHomePage {
16 @State params:Record<string, string> = router.getParams() as Record<string, string>; 17 @State params:Record<string, string> = router.getParams() as Record<string, string>;
17 @Watch('change') @State curUserId: string = '-1'; 18 @Watch('change') @State curUserId: string = '-1';
18 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 19 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
  20 + pageShowTime:number = 0;
  21 + pageHideTime:number = 0;
  22 +
19 23
20 onPageShow() { 24 onPageShow() {
21 this.curUserId = this.params?.['userId']; 25 this.curUserId = this.params?.['userId'];
  26 + this.pageShowTime = DateTimeUtils.getTimeStamp()
  27 + }
  28 +
  29 + onPageHide(): void {
  30 + this.pageHideTime = DateTimeUtils.getTimeStamp()
  31 + let duration = 0
  32 + duration = Math.floor((this.pageHideTime - this.pageShowTime)/1000)
  33 + TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Customer_Personal,TrackConstants.PageName.Customer_Personal,duration)
22 } 34 }
23 35
24 change(){ 36 change(){