yuanfeiyang02

desc:串联启动页与引导页

import { WDRouterRule } from 'wdRouter';
import { WDRouterPage } from 'wdRouter';
@Entry
@Component
struct GuidePages {
... ... @@ -56,6 +59,7 @@ struct GuidePages {
.onClick(() => {
if (index == 3) {
// 跳转到首页
WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage)
}
})
.id('index')
... ...
... ... @@ -15,6 +15,7 @@ struct LaunchPage {
private context?: common.UIAbilityContext;
private timerId: number = 0;
private isJumpToAdvertising: boolean = false;
private isJumpToGuide: boolean = false;
dialogController: CustomDialogController = new CustomDialogController({
builder: CustomDialogComponent(
... ... @@ -40,7 +41,9 @@ struct LaunchPage {
onConfirm() {
// Save privacy agreement status.
this.saveIsPrivacy();
this.jumpToAdvertisingPage();
//跳转引导页
this.jumpToGuidePage();
}
jumpToAdvertisingPage() {
... ... @@ -57,6 +60,21 @@ struct LaunchPage {
}, 1000);
}
jumpToGuidePage() {
this.timerId = setTimeout(() => {
this.isJumpToGuide = true;
WDRouterRule.jumpWithPage(WDRouterPage.guidePage)
// router.pushUrl({
// url: 'pages/LaunchAdvertisingPage'
// }).catch((error: Error) => {
// //Logger.error(CommonConstants.LAUNCHER_PAGE_TAG, 'LauncherPage pushUrl error ' + JSON.stringify(error));
// });
}, 1000);
}
onPageShow() {
this.context = getContext(this) as common.UIAbilityContext;
// Get the operation class for saving data.
... ... @@ -66,11 +84,13 @@ struct LaunchPage {
if (value) {
// let isJumpPrivacy: boolean = globalThis.isJumpPrivacy ?? false;
// let isJumpPrivacy: boolean = (GlobalContext.getContext().getObject('isJumpPrivacy') as boolean) ?? false;
// if (!isJumpPrivacy) {
//if (!isJumpPrivacy) {
this.dialogController.open();
// }
// }
} else {
//跳转广告页
this.jumpToAdvertisingPage();
}
});
});
... ... @@ -80,9 +100,13 @@ struct LaunchPage {
if (this.isJumpToAdvertising) {
router.clear();
}
if (this.isJumpToGuide) {
router.clear();
}
// globalThis.isJumpPrivacy = true;
//GlobalContext.getContext().setObject('isJumpPrivacy', true);
// GlobalContext.getContext().setObject('isJumpPrivacy', true);
clearTimeout(this.timerId);
this.dialogController.close();
}
getDataPreferences(common: Object) {
... ... @@ -104,8 +128,6 @@ struct LaunchPage {
});
}
build(){
Stack({alignContent:Alignment.Bottom}){
... ...
... ... @@ -81,9 +81,8 @@ export default struct CustomDialogComponent {
.width('40%')
.fontColor(Color.Red)
.onClick(() => {
//GlobalContext.getContext().setObject('isJumpPrivacy', false);
// WDRouterRule.jumpWithPage(WDRouterPage.privacyPage)
//GlobalContext.getContext().setObject('isJumpPrivacy', true);
//WDRouterRule.jumpWithPage(WDRouterPage.privacyPage)
// router.pushUrl({
// url: 'pages/PrivacyPage'
// }).catch((error: Error) => {
... ... @@ -96,7 +95,7 @@ export default struct CustomDialogComponent {
.fontColor(Color.Red)
.onClick(() => {
//GlobalContext.getContext().setObject('isJumpPrivacy', true);
// WDRouterRule.jumpWithPage(WDRouterPage.privacyPage)
//WDRouterRule.jumpWithPage(WDRouterPage.privacyPage)
// router.pushUrl({
// url: 'pages/PrivacyPage'
// }).catch((error: Error) => {
... ...