Showing
3 changed files
with
29 additions
and
16 deletions
| @@ -256,4 +256,20 @@ export class ProcessUtils { | @@ -256,4 +256,20 @@ export class ProcessUtils { | ||
| 256 | Logger.error(TAG, 'jumpExternalWebPage success, error: ' + JSON.stringify(err)) | 256 | Logger.error(TAG, 'jumpExternalWebPage success, error: ' + JSON.stringify(err)) |
| 257 | }) | 257 | }) |
| 258 | } | 258 | } |
| 259 | + | ||
| 260 | + /** | ||
| 261 | + * 打开端内web页面 | ||
| 262 | + * @param url web地址 | ||
| 263 | + */ | ||
| 264 | + public static gotoDefaultWebPage(url: string) { | ||
| 265 | + let taskAction: Action = { | ||
| 266 | + type: 'JUMP_H5_BY_WEB_VIEW', | ||
| 267 | + params: { | ||
| 268 | + url: url, | ||
| 269 | + } as Params, | ||
| 270 | + }; | ||
| 271 | + WDRouterRule.jumpWithAction(taskAction) | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + | ||
| 259 | } | 275 | } |
| 1 | import router from '@ohos.router' | 1 | import router from '@ohos.router' |
| 2 | -import { WDRouterRule } from 'wdRouter'; | 2 | +import { ProcessUtils, WDRouterRule } from 'wdRouter'; |
| 3 | import { WDRouterPage } from 'wdRouter'; | 3 | import { WDRouterPage } from 'wdRouter'; |
| 4 | import { Logger, SPHelper } from 'wdKit/Index'; | 4 | import { Logger, SPHelper } from 'wdKit/Index'; |
| 5 | import { SpConstants } from 'wdConstant/Index'; | 5 | import { SpConstants } from 'wdConstant/Index'; |
| @@ -178,23 +178,14 @@ struct LaunchAdvertisingPage { | @@ -178,23 +178,14 @@ struct LaunchAdvertisingPage { | ||
| 178 | // openType 端外 端内 打开 | 178 | // openType 端外 端内 打开 |
| 179 | if (this.model.launchAdInfo[0].matInfo.openType == '2') { | 179 | if (this.model.launchAdInfo[0].matInfo.openType == '2') { |
| 180 | //端外打开 | 180 | //端外打开 |
| 181 | - let context = getContext(this) as common.UIAbilityContext; | ||
| 182 | - let wantInfo: Want = { | ||
| 183 | - // uncomment line below if wish to implicitly query only in the specific bundle. | ||
| 184 | - // bundleName: 'com.example.myapplication', | ||
| 185 | - action: 'ohos.want.action.viewData', | ||
| 186 | - // entities can be omitted. | ||
| 187 | - entities: ['entity.system.browsable'], | ||
| 188 | - uri: 'https://news.bjd.com.cn/2024/03/19/10724331.shtml' | ||
| 189 | - } | ||
| 190 | - context.startAbility(wantInfo).then(() => { | ||
| 191 | - // ... | ||
| 192 | - }).catch((err: BusinessError) => { | ||
| 193 | - // ... | ||
| 194 | - }) | 181 | + |
| 182 | + ProcessUtils.jumpExternalWebPage(this.model.launchAdInfo[0].matInfo.linkUrl) | ||
| 183 | + clearInterval(this.timer) | ||
| 184 | + | ||
| 195 | }else { | 185 | }else { |
| 196 | //端内打开 | 186 | //端内打开 |
| 197 | - | 187 | + ProcessUtils.gotoDefaultWebPage(this.model.launchAdInfo[0].matInfo.linkUrl) |
| 188 | + clearInterval(this.timer) | ||
| 198 | 189 | ||
| 199 | } | 190 | } |
| 200 | } | 191 | } |
| @@ -98,6 +98,12 @@ struct LaunchPage { | @@ -98,6 +98,12 @@ struct LaunchPage { | ||
| 98 | //获取本地存储的启动页数据 | 98 | //获取本地存储的启动页数据 |
| 99 | 99 | ||
| 100 | let dataModelStr : string = SPHelper.default.getSync(SpConstants.APP_LAUNCH_PAGE_DATA_MODEL,'') as string | 100 | let dataModelStr : string = SPHelper.default.getSync(SpConstants.APP_LAUNCH_PAGE_DATA_MODEL,'') as string |
| 101 | + if (!dataModelStr) { | ||
| 102 | + //直接跳转首页 | ||
| 103 | + WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage) | ||
| 104 | + return | ||
| 105 | + } | ||
| 106 | + | ||
| 101 | let dataModel : LaunchDataModel = JSON.parse(dataModelStr) | 107 | let dataModel : LaunchDataModel = JSON.parse(dataModelStr) |
| 102 | console.log(dataModelStr) | 108 | console.log(dataModelStr) |
| 103 | 109 |
-
Please register or login to post a comment