ref |> 调整早晚报和桌面组件数据和加载逻辑
Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
Showing
5 changed files
with
20 additions
and
6 deletions
| @@ -27,8 +27,7 @@ import { common } from '@kit.AbilityKit'; | @@ -27,8 +27,7 @@ import { common } from '@kit.AbilityKit'; | ||
| 27 | import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent'; | 27 | import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent'; |
| 28 | import { EmitterEventId, EmitterUtils } from 'wdKit/Index' | 28 | import { EmitterEventId, EmitterUtils } from 'wdKit/Index' |
| 29 | import { ColorUtils } from '../../utils/ColorUtils'; | 29 | import { ColorUtils } from '../../utils/ColorUtils'; |
| 30 | -import { SpConstants } from 'wdConstant'; | ||
| 31 | - | 30 | +import DailyPaperTopicModel from '../../model/DailyPaperTopicModel'; |
| 32 | 31 | ||
| 33 | const TAG = 'MorningEveningPaperComponent'; | 32 | const TAG = 'MorningEveningPaperComponent'; |
| 34 | 33 | ||
| @@ -129,6 +128,19 @@ export struct MorningEveningPaperComponent { | @@ -129,6 +128,19 @@ export struct MorningEveningPaperComponent { | ||
| 129 | async aboutToAppear() { | 128 | async aboutToAppear() { |
| 130 | this.dailyPaperTopicPageId = await SPHelper.default.getSync('dailyPaperTopicPageId', "") as string | 129 | this.dailyPaperTopicPageId = await SPHelper.default.getSync('dailyPaperTopicPageId', "") as string |
| 131 | 130 | ||
| 131 | + if (this.dailyPaperTopicPageId.length > 0) { | ||
| 132 | + this.fetchData() | ||
| 133 | + } else { | ||
| 134 | + const dailyPaperTopicBean = await DailyPaperTopicModel.getDailyPaperTopic() | ||
| 135 | + if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) { | ||
| 136 | + SPHelper.default.saveSync('dailyPaperTopicPageId', dailyPaperTopicBean.id + ""); | ||
| 137 | + this.dailyPaperTopicPageId = dailyPaperTopicBean.id + ""; | ||
| 138 | + this.fetchData() | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + async fetchData() { | ||
| 132 | // console.info(TAG, `aboutToAppear = ` + this.dailyPaperTopicPageId) | 144 | // console.info(TAG, `aboutToAppear = ` + this.dailyPaperTopicPageId) |
| 133 | const currentTime = new Date().getTime() | 145 | const currentTime = new Date().getTime() |
| 134 | // console.log(TAG, "currentTime = " + currentTime) | 146 | // console.log(TAG, "currentTime = " + currentTime) |
| @@ -711,7 +711,7 @@ export struct TopNavigationComponentNew { | @@ -711,7 +711,7 @@ export struct TopNavigationComponentNew { | ||
| 711 | if (NetworkUtil.isNetConnected()) { | 711 | if (NetworkUtil.isNetConnected()) { |
| 712 | DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean => { | 712 | DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean => { |
| 713 | if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) { | 713 | if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) { |
| 714 | - SPHelper.default.saveSync('dailyPaperTopicPageId', dailyPaperTopicBean.id); | 714 | + SPHelper.default.saveSync('dailyPaperTopicPageId', dailyPaperTopicBean.id + ""); |
| 715 | ProcessUtils.gotoMorningEveningPaper() | 715 | ProcessUtils.gotoMorningEveningPaper() |
| 716 | } else { | 716 | } else { |
| 717 | ToastUtils.showToast('暂无早晚报信息', 1000) | 717 | ToastUtils.showToast('暂无早晚报信息', 1000) |
| @@ -5,7 +5,7 @@ import { PageRepository } from '../repository/PageRepository'; | @@ -5,7 +5,7 @@ import { PageRepository } from '../repository/PageRepository'; | ||
| 5 | 5 | ||
| 6 | const TAG = "SearcherAboutDataModel" | 6 | const TAG = "SearcherAboutDataModel" |
| 7 | 7 | ||
| 8 | -class DailyPaperTopicModel { | 8 | + class DailyPaperTopicModel { |
| 9 | private static instance: DailyPaperTopicModel; | 9 | private static instance: DailyPaperTopicModel; |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| @@ -43,7 +43,9 @@ export class NewspaperDataFetcher { | @@ -43,7 +43,9 @@ export class NewspaperDataFetcher { | ||
| 43 | 43 | ||
| 44 | let contents: ContentDTO[] = compInfo.compList[0].operDataList as ContentDTO[] | 44 | let contents: ContentDTO[] = compInfo.compList[0].operDataList as ContentDTO[] |
| 45 | if (contents && contents.length) { | 45 | if (contents && contents.length) { |
| 46 | - data.paperContents = contents.map((contentDTO) => { | 46 | + data.paperContents = contents.filter((value, index) => { |
| 47 | + return index < 4 | ||
| 48 | + }).map((contentDTO) => { | ||
| 47 | let content : FormNewspaperPaperContent = { | 49 | let content : FormNewspaperPaperContent = { |
| 48 | title: contentDTO.newsTitle, | 50 | title: contentDTO.newsTitle, |
| 49 | coverUrl: contentDTO.coverUrl, | 51 | coverUrl: contentDTO.coverUrl, |
| @@ -97,7 +97,7 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor { | @@ -97,7 +97,7 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor { | ||
| 97 | } | 97 | } |
| 98 | DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean => { | 98 | DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean => { |
| 99 | if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) { | 99 | if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) { |
| 100 | - SPHelper.default.saveSync('dailyPaperTopicPageId', dailyPaperTopicBean.id); | 100 | + SPHelper.default.saveSync('dailyPaperTopicPageId', dailyPaperTopicBean.id + ""); |
| 101 | ProcessUtils.gotoMorningEveningPaper() //跳转至早晚报页面 | 101 | ProcessUtils.gotoMorningEveningPaper() //跳转至早晚报页面 |
| 102 | } else { | 102 | } else { |
| 103 | ToastUtils.showToast('暂无早晚报信息', 1000) | 103 | ToastUtils.showToast('暂无早晚报信息', 1000) |
-
Please register or login to post a comment