yangchenggong1_wd

预约本地数据

  1 +
1 @Entry 2 @Entry
2 @Component 3 @Component
3 struct TestPage { 4 struct TestPage {
4 - @State message: string = 'Hello World'  
5 5
6 build() { 6 build() {
7 - Row() {  
8 - Column() {  
9 - Text(this.message)  
10 - .fontSize(50)  
11 - .fontWeight(FontWeight.Bold)  
12 - }  
13 - .width('100%') 7 + Column() {
14 } 8 }
  9 + .width('100%')
15 .height('100%') 10 .height('100%')
16 } 11 }
17 } 12 }
  1 +{
  2 + "code": "0",
  3 + "data": {
  4 + "list": [{
  5 + "appStyle": "15",
  6 + "imageUrl": ["https://sitcontentjdcdn.aikan.pdnews.cn/sjbj-20231204/image/live/563cc8ce1ecc43b288f6cf60da66579c.jpeg?x-oss-process=image/resize,l_550,m_fill,h_450,w_800/quality,q_90/format,jpg"],
  7 + "liveId": 20000007348,
  8 + "planStartTime": "2023-12-05 15:26:10",
  9 + "relId": "500000017021",
  10 + "relType": 1,
  11 + "startTime": "",
  12 + "status": "wait",
  13 + "title": "视界运营位加权-加权中删除"
  14 + }, {
  15 + "appStyle": "null",
  16 + "imageUrl": ["https://sitcontentjdcdn.aikan.pdnews.cn/sjbj-20230914/image/display/9af825a00abf490d8a8698f4fc079447.jpg?x-oss-process=image/resize,l_550,m_fill,h_450,w_800/quality,q_90/format,jpg"],
  17 + "liveId": 20000007492,
  18 + "planStartTime": "2024-01-12 20:00:00",
  19 + "relId": "500000020284",
  20 + "relType": 1,
  21 + "startTime": "",
  22 + "status": "wait",
  23 + "title": "QA|汉阴县凤堰古梯田"
  24 + }, {
  25 + "appStyle": "null",
  26 + "imageUrl": ["https://sitcontentjdcdn.aikan.pdnews.cn/sjbj-20230915/image/display/e908748c62a44109bbb7214f3fed458c.jpg?x-oss-process=image/resize,l_550,m_fill,h_450,w_800/quality,q_90/format,jpg"],
  27 + "liveId": 20000007493,
  28 + "planStartTime": "2024-01-12 20:00:00",
  29 + "relId": "500000020286",
  30 + "relType": 1,
  31 + "startTime": "",
  32 + "status": "wait",
  33 + "title": "二十四节气-夏至"
  34 + }, {
  35 + "appStyle": "null",
  36 + "imageUrl": ["https://sitcontentjdcdn.aikan.pdnews.cn/sjbj-20240118/image/display/732d6166103d4d2f9fbf512b128a3486.jpeg?x-oss-process=image/resize,l_550,m_fill,h_450,w_800/quality,q_90/format,jpg"],
  37 + "liveId": 20000007495,
  38 + "planStartTime": "2024-01-18 10:51:33",
  39 + "relId": "500000030122",
  40 + "relType": 1,
  41 + "startTime": "",
  42 + "status": "wait",
  43 + "title": "01181050文字直播没有预告片"
  44 + }, {
  45 + "appStyle": "null",
  46 + "imageUrl": ["https://sitcontentjdcdn.aikan.pdnews.cn/sjbj-20240127/image/live/6359d000bba24812b7ca1765bb106a49.png?x-oss-process=image/resize,l_550,m_fill,h_450,w_800/quality,q_90/format,jpg"],
  47 + "liveId": 20000007519,
  48 + "planStartTime": "2024-02-27 18:18:16",
  49 + "relId": "500000034054",
  50 + "relType": 1,
  51 + "startTime": "",
  52 + "status": "wait",
  53 + "title": "错搞民宿33"
  54 + }, {
  55 + "appStyle": "15",
  56 + "imageUrl": ["https://sitcontentjdcdn.aikan.pdnews.cn/sjbj-20240228/image/live/e6998ab547af472dbc19ba2fd68959b9.jpeg?x-oss-process=image/resize,l_550,m_fill,h_450,w_800/quality,q_90/format,jpg"],
  57 + "liveId": 20000007521,
  58 + "planStartTime": "2024-02-28 19:01:50",
  59 + "relId": "500000034162",
  60 + "relType": 1,
  61 + "startTime": "",
  62 + "status": "wait",
  63 + "title": "保存编辑弹幕开关"
  64 + }],
  65 + "pageNum": 1,
  66 + "pageSize": 20,
  67 + "totalCount": 6
  68 + },
  69 + "message": "Success",
  70 + "requestId": "65289f1217934cffb7587ff4d6ce4689",
  71 + "success": true,
  72 + "timestamp": 1710555152344
  73 +}
@@ -58,7 +58,7 @@ export struct AppointmentListUI{ @@ -58,7 +58,7 @@ export struct AppointmentListUI{
58 getNewPageData(){ 58 getNewPageData(){
59 this.isLoading = true 59 this.isLoading = true
60 if(this.hasMore){ 60 if(this.hasMore){
61 - MinePageDatasModel.getAppointmentListData("20",`${this.curPageNum}`).then((value)=>{ 61 + MinePageDatasModel.getAppointmentListData("20",`${this.curPageNum}`,getContext(this)).then((value)=>{
62 if (!this.data || value.list.length == 0){ 62 if (!this.data || value.list.length == 0){
63 this.hasMore = false 63 this.hasMore = false
64 }else{ 64 }else{
@@ -6,7 +6,7 @@ import { HttpUrlUtils } from '../network/HttpUrlUtils'; @@ -6,7 +6,7 @@ import { HttpUrlUtils } from '../network/HttpUrlUtils';
6 import HashMap from '@ohos.util.HashMap'; 6 import HashMap from '@ohos.util.HashMap';
7 import { ResponseDTO, WDHttp } from 'wdNetwork'; 7 import { ResponseDTO, WDHttp } from 'wdNetwork';
8 import { MineAppointmentListItem } from '../viewmodel/MineAppointmentListItem'; 8 import { MineAppointmentListItem } from '../viewmodel/MineAppointmentListItem';
9 -import { Logger } from 'wdKit'; 9 +import { Logger, ResourcesUtils } from 'wdKit';
10 const TAG = "MinePageDatasModel" 10 const TAG = "MinePageDatasModel"
11 11
12 /** 12 /**
@@ -90,12 +90,13 @@ class MinePageDatasModel{ @@ -90,12 +90,13 @@ class MinePageDatasModel{
90 return WDHttp.get<ResponseDTO<MineAppointmentListItem>>(url, headers) 90 return WDHttp.get<ResponseDTO<MineAppointmentListItem>>(url, headers)
91 }; 91 };
92 92
93 - getAppointmentListData(pageSize:string,pageNum:string): Promise<MineAppointmentListItem> { 93 + getAppointmentListData(pageSize:string,pageNum:string,context?: Context): Promise<MineAppointmentListItem> {
94 return new Promise<MineAppointmentListItem>((success, error) => { 94 return new Promise<MineAppointmentListItem>((success, error) => {
95 Logger.info(TAG, `getAppointmentList start`); 95 Logger.info(TAG, `getAppointmentList start`);
96 this.fetchAppointmentListData(pageSize,pageNum).then((navResDTO: ResponseDTO<MineAppointmentListItem>) => { 96 this.fetchAppointmentListData(pageSize,pageNum).then((navResDTO: ResponseDTO<MineAppointmentListItem>) => {
97 if (!navResDTO) { 97 if (!navResDTO) {
98 error("page data invalid"); 98 error("page data invalid");
  99 + success(this.getAppointmentListDataLocal(context))
99 return 100 return
100 } 101 }
101 Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp); 102 Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
@@ -103,11 +104,24 @@ class MinePageDatasModel{ @@ -103,11 +104,24 @@ class MinePageDatasModel{
103 success(navigationBean); 104 success(navigationBean);
104 }).catch((err: Error) => { 105 }).catch((err: Error) => {
105 Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`); 106 Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
106 - error(err); 107 + // error(err);
  108 + success(this.getAppointmentListDataLocal(context))
107 }) 109 })
108 }) 110 })
109 } 111 }
110 112
  113 + async getAppointmentListDataLocal(context?: Context): Promise<MineAppointmentListItem> {
  114 + Logger.info(TAG, `getBottomNavDataMock start`);
  115 + let compRes: ResponseDTO<MineAppointmentListItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineAppointmentListItem>>('appointment_list_data.json', context);
  116 + if (!compRes || !compRes.data) {
  117 + Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`);
  118 + return null
  119 + }
  120 + Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
  121 + return compRes.data
  122 + }
  123 +
  124 +
111 } 125 }
112 126
113 const minePageDatasModel = MinePageDatasModel.getInstance() 127 const minePageDatasModel = MinePageDatasModel.getInstance()