DailyPaperTopicModel.ets
2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { PageInfoBean } from 'wdBean/Index';
import { Logger } from 'wdKit/Index';
import { ResponseDTO } from 'wdNetwork/Index';
import { PageRepository } from '../repository/PageRepository';
const TAG = "SearcherAboutDataModel"
class DailyPaperTopicModel {
private static instance: DailyPaperTopicModel;
/**
* 单例模式
* @returns
*/
public static getInstance(): DailyPaperTopicModel {
if (!DailyPaperTopicModel.instance) {
DailyPaperTopicModel.instance = new DailyPaperTopicModel();
}
return DailyPaperTopicModel.instance;
}
/**
* 首页 搜索提示滚动内容
*/
// getSearchHintData(context: Context): Promise<string[]> {
// return new Promise<string[]>((success, error) => {
// Logger.info(TAG, `getSearchHintData start`);
// this.fetchSearchHintData().then((navResDTO: ResponseDTO<string[]>) => {
// // if (!navResDTO || navResDTO.code != 0) {
// // success(this.getSearchHintDataLocal(context))
// // return
// // }
// Logger.info(TAG, "getSearchHintData then,SearchHintDataResDTO.timeStamp:" + navResDTO.timestamp);
// let navigationBean = navResDTO.data as string[]
// success(navigationBean);
// }).catch((err: Error) => {
// Logger.error(TAG, `fetchSearchHintData catch, error.name : ${err.name}, error.message:${err.message}`);
// success(this.getSearchHintDataLocal(context))
// })
// })
// }
public async getDailyPaperTopic(): Promise<PageInfoBean> {
return new Promise<PageInfoBean>((success, error) => {
Logger.info(TAG, `getDailyPaperTopic pageInfo start`);
PageRepository.fetchDailyPaperTopic()
.then((resDTO: ResponseDTO<PageInfoBean>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getDailyPaperTopic then navResDTO is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getDailyPaperTopic then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
return
}
// let navResStr = JSON.stringify(navResDTO);
Logger.info(TAG, "getDailyPaperTopic then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO.data);
})
.catch((err: Error) => {
Logger.error(TAG, `getDailyPaperTopic catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
}
const dailyPaperTopicModel = DailyPaperTopicModel.getInstance()
export default dailyPaperTopicModel as DailyPaperTopicModel