Showing
1 changed file
with
25 additions
and
8 deletions
| 1 | import { insightIntent, InsightIntentExecutor } from '@kit.AbilityKit'; | 1 | import { insightIntent, InsightIntentExecutor } from '@kit.AbilityKit'; |
| 2 | import { window } from '@kit.ArkUI'; | 2 | import { window } from '@kit.ArkUI'; |
| 3 | import { BusinessError } from '@kit.BasicServicesKit'; | 3 | import { BusinessError } from '@kit.BasicServicesKit'; |
| 4 | +import { NetworkUtil, SPHelper, ToastUtils } from 'wdKit'; | ||
| 4 | import { ProcessUtils } from 'wdRouter'; | 5 | import { ProcessUtils } from 'wdRouter'; |
| 6 | +import DailyPaperTopicModel from 'wdComponent/src/main/ets/model/DailyPaperTopicModel' | ||
| 7 | + | ||
| 5 | /** | 8 | /** |
| 6 | * 意图调用 | 9 | * 意图调用 |
| 7 | */ | 10 | */ |
| @@ -19,7 +22,7 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor { | @@ -19,7 +22,7 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor { | ||
| 19 | */ | 22 | */ |
| 20 | onExecuteInUIAbilityForegroundMode(name: string, param: Record<string, Object>, pageLoader: window.WindowStage): | 23 | onExecuteInUIAbilityForegroundMode(name: string, param: Record<string, Object>, pageLoader: window.WindowStage): |
| 21 | Promise<insightIntent.ExecuteResult> { | 24 | Promise<insightIntent.ExecuteResult> { |
| 22 | - console.log('yzl onExecuteInUIAbilityForegroundMode',name,JSON.stringify(param)) | 25 | + console.log('yzl onExecuteInUIAbilityForegroundMode', name, JSON.stringify(param)) |
| 23 | // 根据意图名称分发处理逻辑 | 26 | // 根据意图名称分发处理逻辑 |
| 24 | switch (name) { | 27 | switch (name) { |
| 25 | case InsightIntentExecutorImpl.ViewBlog: | 28 | case InsightIntentExecutorImpl.ViewBlog: |
| @@ -36,19 +39,19 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor { | @@ -36,19 +39,19 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor { | ||
| 36 | } | 39 | } |
| 37 | } as insightIntent.ExecuteResult) | 40 | } as insightIntent.ExecuteResult) |
| 38 | } | 41 | } |
| 42 | + | ||
| 39 | /** | 43 | /** |
| 40 | * 实现习惯推荐功能 | 44 | * 实现习惯推荐功能 |
| 41 | * @param param 意图参数 | 45 | * @param param 意图参数 |
| 42 | * @param pageLoader 窗口 | 46 | * @param pageLoader 窗口 |
| 43 | */ | 47 | */ |
| 44 | - private jumpToViewBlog(param: Record<string, Object>, pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> { | ||
| 45 | - console.log('yzl jumpToView',JSON.stringify(param)) | 48 | + private jumpToViewBlog(param: Record<string, Object>, |
| 49 | + pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> { | ||
| 50 | + console.log('yzl jumpToView', JSON.stringify(param)) | ||
| 46 | return new Promise((resolve, reject) => { | 51 | return new Promise((resolve, reject) => { |
| 47 | - // TODO 实现意图调用,loadContent的入参为歌曲落地页路径,例如:pages/SongPage | ||
| 48 | // TODO 热启动是否切到主页 | 52 | // TODO 热启动是否切到主页 |
| 49 | pageLoader.loadContent('pages/MainPage') | 53 | pageLoader.loadContent('pages/MainPage') |
| 50 | .then(() => { | 54 | .then(() => { |
| 51 | - | ||
| 52 | resolve({ | 55 | resolve({ |
| 53 | code: 0, | 56 | code: 0, |
| 54 | result: { | 57 | result: { |
| @@ -72,12 +75,26 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor { | @@ -72,12 +75,26 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor { | ||
| 72 | * @param param 意图参数 | 75 | * @param param 意图参数 |
| 73 | * @param pageLoader 窗口 | 76 | * @param pageLoader 窗口 |
| 74 | */ | 77 | */ |
| 75 | - private jumpToViewColumnUpdate(param: Record<string, Object>, pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> { | ||
| 76 | - console.log('yzl jumpToViewColum',JSON.stringify(param)) | 78 | + private jumpToViewColumnUpdate(param: Record<string, Object>, |
| 79 | + pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> { | ||
| 77 | return new Promise((resolve, reject) => { | 80 | return new Promise((resolve, reject) => { |
| 78 | pageLoader.loadContent('pages/MainPage') | 81 | pageLoader.loadContent('pages/MainPage') |
| 79 | .then(() => { | 82 | .then(() => { |
| 80 | - ProcessUtils.gotoMorningEveningPaper() | 83 | + if (NetworkUtil.isNetConnected()) { |
| 84 | + DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean => { | ||
| 85 | + if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) { | ||
| 86 | + SPHelper.default.saveSync('dailyPaperTopicPageId', dailyPaperTopicBean.id); | ||
| 87 | + ProcessUtils.gotoMorningEveningPaper() //跳转至早晚报页面 | ||
| 88 | + } else { | ||
| 89 | + ToastUtils.showToast('暂无早晚报信息', 1000) | ||
| 90 | + } | ||
| 91 | + }).catch((err: string) => { | ||
| 92 | + console.log('yzlerr',JSON.stringify(err)) | ||
| 93 | + ToastUtils.showToast('暂无早晚报信息', 1000) | ||
| 94 | + }) | ||
| 95 | + } else { | ||
| 96 | + ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000) | ||
| 97 | + } | ||
| 81 | resolve({ | 98 | resolve({ |
| 82 | code: 0, | 99 | code: 0, |
| 83 | result: { | 100 | result: { |
-
Please register or login to post a comment