xugenyuan

ref |> 调整早晚报和桌面组件数据和加载逻辑

Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
... ... @@ -27,8 +27,7 @@ import { common } from '@kit.AbilityKit';
import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent';
import { EmitterEventId, EmitterUtils } from 'wdKit/Index'
import { ColorUtils } from '../../utils/ColorUtils';
import { SpConstants } from 'wdConstant';
import DailyPaperTopicModel from '../../model/DailyPaperTopicModel';
const TAG = 'MorningEveningPaperComponent';
... ... @@ -129,6 +128,19 @@ export struct MorningEveningPaperComponent {
async aboutToAppear() {
this.dailyPaperTopicPageId = await SPHelper.default.getSync('dailyPaperTopicPageId', "") as string
if (this.dailyPaperTopicPageId.length > 0) {
this.fetchData()
} else {
const dailyPaperTopicBean = await DailyPaperTopicModel.getDailyPaperTopic()
if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) {
SPHelper.default.saveSync('dailyPaperTopicPageId', dailyPaperTopicBean.id + "");
this.dailyPaperTopicPageId = dailyPaperTopicBean.id + "";
this.fetchData()
}
}
}
async fetchData() {
// console.info(TAG, `aboutToAppear = ` + this.dailyPaperTopicPageId)
const currentTime = new Date().getTime()
// console.log(TAG, "currentTime = " + currentTime)
... ...
... ... @@ -711,7 +711,7 @@ export struct TopNavigationComponentNew {
if (NetworkUtil.isNetConnected()) {
DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean => {
if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) {
SPHelper.default.saveSync('dailyPaperTopicPageId', dailyPaperTopicBean.id);
SPHelper.default.saveSync('dailyPaperTopicPageId', dailyPaperTopicBean.id + "");
ProcessUtils.gotoMorningEveningPaper()
} else {
ToastUtils.showToast('暂无早晚报信息', 1000)
... ...
... ... @@ -5,7 +5,7 @@ import { PageRepository } from '../repository/PageRepository';
const TAG = "SearcherAboutDataModel"
class DailyPaperTopicModel {
class DailyPaperTopicModel {
private static instance: DailyPaperTopicModel;
/**
... ...
... ... @@ -43,7 +43,9 @@ export class NewspaperDataFetcher {
let contents: ContentDTO[] = compInfo.compList[0].operDataList as ContentDTO[]
if (contents && contents.length) {
data.paperContents = contents.map((contentDTO) => {
data.paperContents = contents.filter((value, index) => {
return index < 4
}).map((contentDTO) => {
let content : FormNewspaperPaperContent = {
title: contentDTO.newsTitle,
coverUrl: contentDTO.coverUrl,
... ...
... ... @@ -97,7 +97,7 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
}
DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean => {
if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) {
SPHelper.default.saveSync('dailyPaperTopicPageId', dailyPaperTopicBean.id);
SPHelper.default.saveSync('dailyPaperTopicPageId', dailyPaperTopicBean.id + "");
ProcessUtils.gotoMorningEveningPaper() //跳转至早晚报页面
} else {
ToastUtils.showToast('暂无早晚报信息', 1000)
... ...