王士厅
Showing 26 changed files with 504 additions and 122 deletions
@@ -67,4 +67,8 @@ export { TingyunAPM } from './src/main/ets/tingyunAPM/TingyunAPM' @@ -67,4 +67,8 @@ export { TingyunAPM } from './src/main/ets/tingyunAPM/TingyunAPM'
67 export { FastClickUtil } from './src/main/ets/utils/FastClickUtil'; 67 export { FastClickUtil } from './src/main/ets/utils/FastClickUtil';
68 68
69 // export { PublicPopupDialogView } from "./src/main/ets/pubComps/dialog/PublicPopupDialogView" 69 // export { PublicPopupDialogView } from "./src/main/ets/pubComps/dialog/PublicPopupDialogView"
70 -export { PublicDialogManager, CloseAction } from "./src/main/ets/pubComps/dialog/PublicDialogManager"  
  70 +export { PublicDialogManager, CloseAction } from "./src/main/ets/pubComps/dialog/PublicDialogManager"
  71 +
  72 +export { CrptoUtils } from "./src/main/ets/utils/CrptoUtils"
  73 +
  74 +export { FileUtils } from "./src/main/ets/utils/FileUtils"
  1 +import cryptoFramework from '@ohos.security.cryptoFramework';
  2 +import buffer from '@ohos.buffer';
  3 +
  4 +export class CrptoUtils {
  5 +
  6 + static md5(message: string) : Promise<string> {
  7 + return CrptoUtils.mdFunc(message, 'MD5')
  8 + }
  9 +
  10 + static mdFunc(message: string, algoName: string = 'MD5'): Promise<string> {
  11 + return new Promise<string>(async (reslove, fail) => {
  12 +
  13 + try {
  14 + let md = cryptoFramework.createMd(algoName);
  15 + // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制
  16 + await md.update({ data: new Uint8Array(buffer.from(message, 'utf-8').buffer) });
  17 + let mdResult = await md.digest();
  18 + // console.info('Md result:' + mdResult.data);
  19 +
  20 + // const string = mdResult.data.map((charCode, index, array) => {
  21 + // return String.fromCharCode(charCode)
  22 + // }).join("")
  23 +
  24 + let string = "";
  25 + for (let i = 0; i < mdResult.data.length; i++) {
  26 + string += mdResult.data[i].toString(16).padStart(2, "0")
  27 + }
  28 +
  29 + // const string = mdResult.data.join('')
  30 +
  31 + reslove(string)
  32 + } catch (e) {
  33 + fail(e)
  34 + }
  35 + })
  36 + }
  37 +}
  38 +
  39 +
  40 +
  41 +
  1 +
  2 +import fs from '@ohos.file.fs';
  3 +import { BusinessError } from '@kit.BasicServicesKit';
  4 +
  5 +export class FileUtils {
  6 +
  7 + // 文件是否存在,忽略错误
  8 + static fileExsit(path: string) : Promise<boolean> {
  9 + return new Promise((reslove, fail) => {
  10 + fs.stat(path).then(() => {
  11 + reslove(true)
  12 + }).catch((error: BusinessError) => {
  13 + if (error.code = 13900002) {
  14 + reslove(false)
  15 + } else {
  16 + reslove(true)
  17 + }
  18 + })
  19 + });
  20 + }
  21 +
  22 + static makeDirIfNotExsit(path: string) : Promise<void> {
  23 + return new Promise((reslove, fail) => {
  24 + fs.stat(path).then(() => {
  25 + reslove()
  26 + }).catch((error: BusinessError) => {
  27 + if (error.code = 13900002) {
  28 + fs.mkdirSync(path)
  29 + }
  30 + reslove()
  31 + })
  32 + })
  33 + }
  34 +}
@@ -49,9 +49,9 @@ export function registerRouter() { @@ -49,9 +49,9 @@ export function registerRouter() {
49 // }) 49 // })
50 50
51 Action2Page.register("JUMP_DETAIL_PAGE", (action: Action) => { 51 Action2Page.register("JUMP_DETAIL_PAGE", (action: Action) => {
52 - if (action.params?.detailPageType == 2 || action.params?.detailPageType == 6) { 52 + if (action.params?.detailPageType == 2) {
53 return WDRouterPage.detailPlayLiveCommon 53 return WDRouterPage.detailPlayLiveCommon
54 - } else if (action.params?.detailPageType == 7 || action.params?.detailPageType == 8) { 54 + } else if (action.params?.detailPageType == 1) {
55 return WDRouterPage.detailVideoListPage 55 return WDRouterPage.detailVideoListPage
56 } else if (action.params?.detailPageType == 9) { 56 } else if (action.params?.detailPageType == 9) {
57 //图集详情页 57 //图集详情页
@@ -59,16 +59,19 @@ export function registerRouter() { @@ -59,16 +59,19 @@ export function registerRouter() {
59 } else if (action.params?.detailPageType == 14 || action.params?.detailPageType == 15) { 59 } else if (action.params?.detailPageType == 14 || action.params?.detailPageType == 15) {
60 //动态详情页 60 //动态详情页
61 return WDRouterPage.dynamicDetailPage 61 return WDRouterPage.dynamicDetailPage
62 - } else if (action.params?.detailPageType == 17) {  
63 - return WDRouterPage.multiPictureDetailPage  
64 } else if (action.params?.detailPageType == 13) { 62 } else if (action.params?.detailPageType == 13) {
65 return WDRouterPage.audioDetail 63 return WDRouterPage.audioDetail
66 - } else if (action.params?.detailPageType == 18) { 64 + } else if (action.params?.detailPageType == 30) {
  65 + return WDRouterPage.themeListPage
  66 + } else if (action.params?.detailPageType == 8) {
  67 + return WDRouterPage.imageTextDetailPage
  68 + }
  69 +
  70 + //TODO: 以下两个最好改为pageID方式,以上都是有具体内容类型 对应详情页面
  71 + else if (action.params?.detailPageType == 18) {
67 return WDRouterPage.multiPictureListPage 72 return WDRouterPage.multiPictureListPage
68 } else if (action.params?.detailPageType == 19) { 73 } else if (action.params?.detailPageType == 19) {
69 return WDRouterPage.videoPlayPage 74 return WDRouterPage.videoPlayPage
70 - }else if (action.params?.detailPageType == 30) {  
71 - return WDRouterPage.themeListPage  
72 } 75 }
73 return WDRouterPage.detailPlayVodPage 76 return WDRouterPage.detailPlayVodPage
74 }) 77 })
@@ -3,6 +3,7 @@ import App from '@system.app' @@ -3,6 +3,7 @@ import App from '@system.app'
3 import { Action, Params } from 'wdBean/Index' 3 import { Action, Params } from 'wdBean/Index'
4 import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO' 4 import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO'
5 import { Logger } from 'wdKit/Index' 5 import { Logger } from 'wdKit/Index'
  6 +import { ContentType } from '../common/ContentType'
6 import { WDRouterRule } from '../router/WDRouterRule' 7 import { WDRouterRule } from '../router/WDRouterRule'
7 import { ProcessUtils } from './ProcessUtils' 8 import { ProcessUtils } from './ProcessUtils'
8 9
@@ -111,13 +112,13 @@ export class AppInnerLink { @@ -111,13 +112,13 @@ export class AppInnerLink {
111 } 112 }
112 private static contentTypeWithType(type?: string) : number | undefined { 113 private static contentTypeWithType(type?: string) : number | undefined {
113 switch (type) { 114 switch (type) {
114 - case "video": return 1  
115 - case "dynamic": return 14  
116 - case "live": return 2  
117 - case "audio": return 13  
118 - case "picture": return 9  
119 - case "article": return 8  
120 - case "ask": return 16 115 + case "video": return ContentType.Video
  116 + case "dynamic": return ContentType.DynamicImageText
  117 + case "live": return ContentType.Live
  118 + case "audio": return ContentType.Audio
  119 + case "picture": return ContentType.Pictures
  120 + case "article": return ContentType.ImageText
  121 + case "ask": return ContentType.Ask
121 } 122 }
122 return 123 return
123 } 124 }
1 import { Action, ContentDTO, Params, PhotoListBean, commentInfo } from 'wdBean'; 1 import { Action, ContentDTO, Params, PhotoListBean, commentInfo } from 'wdBean';
2 import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO'; 2 import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO';
3 -import { Logger, SPHelper } from 'wdKit'; 3 +import { Logger, NetworkUtil, SPHelper, ToastUtils } from 'wdKit';
4 import { StringUtils } from 'wdKit/src/main/ets/utils/StringUtils'; 4 import { StringUtils } from 'wdKit/src/main/ets/utils/StringUtils';
5 import { WDRouterRule, WDRouterPage } from '../../../../Index'; 5 import { WDRouterRule, WDRouterPage } from '../../../../Index';
6 import { ContentConstants, SpConstants } from 'wdConstant'; 6 import { ContentConstants, SpConstants } from 'wdConstant';
@@ -84,6 +84,13 @@ export class ProcessUtils { @@ -84,6 +84,13 @@ export class ProcessUtils {
84 Logger.error(TAG, "processPage, objectType is empty"); 84 Logger.error(TAG, "processPage, objectType is empty");
85 return; 85 return;
86 } 86 }
  87 + // 网络出小差了,请检查网络后重试
  88 + let netStatus = NetworkUtil.isNetConnected()
  89 + if(!netStatus){
  90 + ToastUtils.shortToast('网络出小差了,请检查网络后重试')
  91 + return
  92 + }
  93 +
87 let type = content.objectType; 94 let type = content.objectType;
88 if (typeof type == "number") { 95 if (typeof type == "number") {
89 type = `${type}` 96 type = `${type}`
@@ -304,7 +311,7 @@ export class ProcessUtils { @@ -304,7 +311,7 @@ export class ProcessUtils {
304 let taskAction: Action = { 311 let taskAction: Action = {
305 type: 'JUMP_DETAIL_PAGE', 312 type: 'JUMP_DETAIL_PAGE',
306 params: { 313 params: {
307 - detailPageType: 7, 314 + detailPageType: 1,
308 contentID: content?.objectId, 315 contentID: content?.objectId,
309 extra: { 316 extra: {
310 relType: content?.relType, 317 relType: content?.relType,
@@ -382,7 +389,7 @@ export class ProcessUtils { @@ -382,7 +389,7 @@ export class ProcessUtils {
382 let taskAction: Action = { 389 let taskAction: Action = {
383 type: 'JUMP_DETAIL_PAGE', 390 type: 'JUMP_DETAIL_PAGE',
384 params: { 391 params: {
385 - detailPageType: 17, 392 + detailPageType: 9,
386 contentID: content?.objectId, 393 contentID: content?.objectId,
387 extra: { 394 extra: {
388 relType: content?.relType, 395 relType: content?.relType,
@@ -10,16 +10,13 @@ export interface Params { @@ -10,16 +10,13 @@ export interface Params {
10 // 详情页类型 10 // 详情页类型
11 // 1.点播详情页 11 // 1.点播详情页
12 // 2.直播详情页 12 // 2.直播详情页
13 - // 3.图文详情页  
14 - // 4.全民播详情页  
15 - // 5.欢喜详情页  
16 - // 6.挂件详情页  
17 - // 7.沉浸式竖屏详情页  
18 - // 8.专辑竖屏详情页  
19 - // 13.音频详情页  
20 - // 17.多图(图集)详情页  
21 - // 18.大图列表页  
22 - // 19.单个视频播放页 13 + // 8.图文详情页
  14 + // 9.多图(图集)详情页
  15 + // 14和15 动态详情页
  16 + // 13 音频详情页
  17 + // 30 金刚位
  18 + // 18.大图列表页 - 图片预览 ------ 需要变更待定
  19 + // 19.单个视频播放页 - 视频播放 ----- 需要变更待定
23 detailPageType?: number; // 详情页类型 20 detailPageType?: number; // 详情页类型
24 liveStyle?: number; // 直播类型:0横屏,1竖屏 21 liveStyle?: number; // 直播类型:0横屏,1竖屏
25 creatorId?: string; //号主id 22 creatorId?: string; //号主id
@@ -25,6 +25,7 @@ import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index'; @@ -25,6 +25,7 @@ import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
25 */ 25 */
26 @Component 26 @Component
27 export struct CardParser { 27 export struct CardParser {
  28 +
28 @State pageId: string = ''; 29 @State pageId: string = '';
29 @State pageName: string = ''; 30 @State pageName: string = '';
30 @State contentDTO: ContentDTO = new ContentDTO(); 31 @State contentDTO: ContentDTO = new ContentDTO();
@@ -45,8 +45,6 @@ export struct CompParser { @@ -45,8 +45,6 @@ export struct CompParser {
45 45
46 aboutToAppear(): void { 46 aboutToAppear(): void {
47 47
48 -  
49 -  
50 console.log('CompParser', JSON.stringify(this.compDTO)) 48 console.log('CompParser', JSON.stringify(this.compDTO))
51 this.pageName = this.pageModel.pageInfo.name 49 this.pageName = this.pageModel.pageInfo.name
52 // 轮播图屏蔽音频类型稿件 50 // 轮播图屏蔽音频类型稿件
@@ -116,7 +116,7 @@ export struct Card17Component { @@ -116,7 +116,7 @@ export struct Card17Component {
116 let taskAction: Action = { 116 let taskAction: Action = {
117 type: 'JUMP_DETAIL_PAGE', 117 type: 'JUMP_DETAIL_PAGE',
118 params: { 118 params: {
119 - detailPageType: 17, 119 + detailPageType: 9,
120 contentID: this.contentDTO.objectId, 120 contentID: this.contentDTO.objectId,
121 extra: { 121 extra: {
122 relType: this.contentDTO.relType, 122 relType: this.contentDTO.relType,
@@ -50,6 +50,7 @@ export struct HomePageBottomCommentComponent { @@ -50,6 +50,7 @@ export struct HomePageBottomCommentComponent {
50 CustomPullToRefresh({ 50 CustomPullToRefresh({
51 alldata:this.data_comment, 51 alldata:this.data_comment,
52 scroller:this.scroller, 52 scroller:this.scroller,
  53 + hasMore:this.hasMore,
53 customList:()=>{ 54 customList:()=>{
54 this.ListLayout() 55 this.ListLayout()
55 }, 56 },
@@ -184,7 +185,7 @@ export struct HomePageBottomCommentComponent { @@ -184,7 +185,7 @@ export struct HomePageBottomCommentComponent {
184 185
185 this.count = this.data_comment.totalCount() 186 this.count = this.data_comment.totalCount()
186 this.commentNum = value.totalCount 187 this.commentNum = value.totalCount
187 - if (this.data_comment.totalCount() < value.totalCount) { 188 + if (value.pageNum === 1) {
188 this.curPageNum++ 189 this.curPageNum++
189 } else { 190 } else {
190 this.hasMore = false 191 this.hasMore = false
@@ -217,7 +218,7 @@ export struct HomePageBottomCommentComponent { @@ -217,7 +218,7 @@ export struct HomePageBottomCommentComponent {
217 218
218 this.count = this.data_comment.totalCount() 219 this.count = this.data_comment.totalCount()
219 this.commentNum = value.totalCount 220 this.commentNum = value.totalCount
220 - if (this.data_comment.totalCount() < value.totalCount) { 221 + if (value.pageNum === 1) {
221 this.curPageNum++ 222 this.curPageNum++
222 } else { 223 } else {
223 this.hasMore = false 224 this.hasMore = false
@@ -50,6 +50,7 @@ export struct OtherHomePageBottomCommentComponent { @@ -50,6 +50,7 @@ export struct OtherHomePageBottomCommentComponent {
50 CustomPullToRefresh({ 50 CustomPullToRefresh({
51 alldata:this.data_comment, 51 alldata:this.data_comment,
52 scroller:this.scroller, 52 scroller:this.scroller,
  53 + hasMore:this.hasMore,
53 customList:()=>{ 54 customList:()=>{
54 this.ListLayout() 55 this.ListLayout()
55 }, 56 },
@@ -69,6 +70,7 @@ export struct OtherHomePageBottomCommentComponent { @@ -69,6 +70,7 @@ export struct OtherHomePageBottomCommentComponent {
69 this.isLoading = true 70 this.isLoading = true
70 //加载分页数据 71 //加载分页数据
71 this.getNewPageData() 72 this.getNewPageData()
  73 + if(resolve) resolve('刷新成功')
72 } 74 }
73 } 75 }
74 }) 76 })
@@ -108,6 +110,13 @@ export struct OtherHomePageBottomCommentComponent { @@ -108,6 +110,13 @@ export struct OtherHomePageBottomCommentComponent {
108 } 110 }
109 } 111 }
110 } 112 }
  113 + // .onReachEnd(()=>{
  114 + // if (!this.isLoading) {
  115 + // this.isLoading = true
  116 + // //加载分页数据
  117 + // this.getNewPageData()
  118 + // }
  119 + // })
111 .cachedCount(5) 120 .cachedCount(5)
112 .layoutWeight(1) 121 .layoutWeight(1)
113 .scrollBar(BarState.Off) 122 .scrollBar(BarState.Off)
@@ -185,7 +194,7 @@ export struct OtherHomePageBottomCommentComponent { @@ -185,7 +194,7 @@ export struct OtherHomePageBottomCommentComponent {
185 194
186 this.count = this.data_comment.totalCount() 195 this.count = this.data_comment.totalCount()
187 this.commentNum = value.totalCount 196 this.commentNum = value.totalCount
188 - if (this.data_comment.totalCount() < value.totalCount) { 197 + if (value.hasNext === 1) {
189 this.curPageNum++ 198 this.curPageNum++
190 } else { 199 } else {
191 this.hasMore = false 200 this.hasMore = false
@@ -214,7 +223,7 @@ export struct OtherHomePageBottomCommentComponent { @@ -214,7 +223,7 @@ export struct OtherHomePageBottomCommentComponent {
214 223
215 this.count = this.data_comment.totalCount() 224 this.count = this.data_comment.totalCount()
216 this.commentNum = value.totalCount 225 this.commentNum = value.totalCount
217 - if (this.data_comment.totalCount() < value.totalCount) { 226 + if (value.hasNext === 1) {
218 this.curPageNum++ 227 this.curPageNum++
219 } else { 228 } else {
220 this.hasMore = false 229 this.hasMore = false
1 import { PeopleShipRecommendComponent } from './PeopleShipRecommendComponent'; 1 import { PeopleShipRecommendComponent } from './PeopleShipRecommendComponent';
2 import { PeopleShipMainViewModel } from '../../viewmodel/PeopleShipMainViewModel'; 2 import { PeopleShipMainViewModel } from '../../viewmodel/PeopleShipMainViewModel';
3 -import { HttpUtils } from 'wdNetwork/Index'; 3 +import { HttpUtils } from 'wdNetwork/Index';
4 import { Logger, DateTimeUtils, EmitterEventId, EmitterUtils } from 'wdKit'; 4 import { Logger, DateTimeUtils, EmitterEventId, EmitterUtils } from 'wdKit';
5 import { 5 import {
6 RmhRecommendDTO, 6 RmhRecommendDTO,
@@ -21,27 +21,27 @@ import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem'; @@ -21,27 +21,27 @@ import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem';
21 import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh'; 21 import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
22 import PageModel from '../../viewmodel/PageModel'; 22 import PageModel from '../../viewmodel/PageModel';
23 import PageAdModel from '../../viewmodel/PageAdvModel'; 23 import PageAdModel from '../../viewmodel/PageAdvModel';
24 -import PageHelper from '../../viewmodel/PageHelper';  
25 import { PeopleShipAttentionContentListTopComponent } from './PeopleShipAttentionContentListTopComponent' 24 import { PeopleShipAttentionContentListTopComponent } from './PeopleShipAttentionContentListTopComponent'
26 import { CardParser } from '../CardParser' 25 import { CardParser } from '../CardParser'
27 import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData'; 26 import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData';
  27 +import PageFollowHelper from '../../viewmodel/PageFollowHelper';
  28 +
28 const TAG = 'PeopleShipMainComponent'; 29 const TAG = 'PeopleShipMainComponent';
  30 +
29 /** 31 /**
30 * 人民号 --- 关注 32 * 人民号 --- 关注
31 */ 33 */
32 @Component 34 @Component
33 export struct PeopleShipMainComponent { 35 export struct PeopleShipMainComponent {
34 @State private pageModel: PageModel = new PageModel(); 36 @State private pageModel: PageModel = new PageModel();
35 - @State private pageAdvModel: PageAdModel = new PageAdModel();  
36 // 自动刷新通知 37 // 自动刷新通知
37 @Prop @Watch('onAutoRefresh') autoRefresh: number = 0 38 @Prop @Watch('onAutoRefresh') autoRefresh: number = 0
38 navIndex: number = 0; 39 navIndex: number = 0;
39 pageId: string = ""; 40 pageId: string = "";
40 channelId: string = ""; 41 channelId: string = "";
41 @Link @Watch('onChange') currentTopNavSelectedIndex: number 42 @Link @Watch('onChange') currentTopNavSelectedIndex: number
42 - private scroller: Scroller = new Scroller() 43 + // private scroller: Scroller = new Scroller()
43 private listScroller: Scroller = new Scroller() 44 private listScroller: Scroller = new Scroller()
44 -  
45 @State rmhList: RmhRecommendDTO[] = [] 45 @State rmhList: RmhRecommendDTO[] = []
46 @Provide rmhSelectedList: string[] = [] 46 @Provide rmhSelectedList: string[] = []
47 @State viewType: ViewType = ViewType.LOADING 47 @State viewType: ViewType = ViewType.LOADING
@@ -56,7 +56,6 @@ export struct PeopleShipMainComponent { @@ -56,7 +56,6 @@ export struct PeopleShipMainComponent {
56 @State private currentPage: number = 1 56 @State private currentPage: number = 1
57 @State private isLoading: boolean = false 57 @State private isLoading: boolean = false
58 @State private loadTime: string = '' 58 @State private loadTime: string = ''
59 -  
60 // 页面展示监听 59 // 页面展示监听
61 @Consume @Watch('onPageShowChange') pageShow: number 60 @Consume @Watch('onPageShowChange') pageShow: number
62 @State private pageAttentionChange: boolean = false 61 @State private pageAttentionChange: boolean = false
@@ -86,7 +85,7 @@ export struct PeopleShipMainComponent { @@ -86,7 +85,7 @@ export struct PeopleShipMainComponent {
86 if (this.followList.length == 0) { 85 if (this.followList.length == 0) {
87 CustomPullToRefresh({ 86 CustomPullToRefresh({
88 alldata: this.rmhList, 87 alldata: this.rmhList,
89 - scroller: this.scroller, 88 + scroller: this.listScroller,
90 hasMore: false, 89 hasMore: false,
91 customList: () => { 90 customList: () => {
92 this.ListLayout() 91 this.ListLayout()
@@ -96,7 +95,7 @@ export struct PeopleShipMainComponent { @@ -96,7 +95,7 @@ export struct PeopleShipMainComponent {
96 this.getData(resolve) 95 this.getData(resolve)
97 }, 96 },
98 }) 97 })
99 - }else { 98 + } else {
100 CustomPullToRefresh({ 99 CustomPullToRefresh({
101 alldata: this.attentionList, 100 alldata: this.attentionList,
102 scroller: this.listScroller, 101 scroller: this.listScroller,
@@ -108,19 +107,19 @@ export struct PeopleShipMainComponent { @@ -108,19 +107,19 @@ export struct PeopleShipMainComponent {
108 this.currentPage = 1 107 this.currentPage = 1
109 this.getData(resolve) 108 this.getData(resolve)
110 }, 109 },
111 - onLoadMore:(resolve)=> { 110 + onLoadMore: (resolve) => {
112 if (this.hasMore === false) { 111 if (this.hasMore === false) {
113 - if(resolve) { 112 + if (resolve) {
114 resolve('') 113 resolve('')
115 } 114 }
116 return 115 return
117 } 116 }
118 - if(!this.isLoading && this.hasMore){ 117 + if (!this.isLoading && this.hasMore) {
119 //加载分页数据 118 //加载分页数据
120 this.currentPage++; 119 this.currentPage++;
121 this.getAttentionContentListData(resolve) 120 this.getAttentionContentListData(resolve)
122 - }else {  
123 - if(resolve) { 121 + } else {
  122 + if (resolve) {
124 resolve('') 123 resolve('')
125 } 124 }
126 } 125 }
@@ -137,13 +136,16 @@ export struct PeopleShipMainComponent { @@ -137,13 +136,16 @@ export struct PeopleShipMainComponent {
137 136
138 @Builder 137 @Builder
139 ListLayout() { 138 ListLayout() {
140 - Scroll(this.scroller) {  
141 - // 推荐人民号  
142 - PeopleShipRecommendComponent({  
143 - rmhList: this.rmhList,  
144 - oneKeyFollow: this.oneKeyFollow,  
145 - changeButton: this.changeButton  
146 - }) 139 +
  140 + List({ scroller: this.listScroller }) {
  141 + // 头部关注列表
  142 + ListItem() {
  143 + PeopleShipRecommendComponent({
  144 + rmhList: this.rmhList,
  145 + oneKeyFollow: this.oneKeyFollow,
  146 + changeButton: this.changeButton
  147 + })
  148 + }
147 } 149 }
148 .edgeEffect(EdgeEffect.None) 150 .edgeEffect(EdgeEffect.None)
149 .scrollBar(BarState.Off) 151 .scrollBar(BarState.Off)
@@ -153,20 +155,25 @@ export struct PeopleShipMainComponent { @@ -153,20 +155,25 @@ export struct PeopleShipMainComponent {
153 155
154 @Builder 156 @Builder
155 ListAttentionLayout() { 157 ListAttentionLayout() {
156 - List({scroller: this.listScroller}){ 158 + List({ scroller: this.listScroller }) {
157 // 头部关注列表 159 // 头部关注列表
158 - ListItem(){ 160 + ListItem() {
159 PeopleShipAttentionContentListTopComponent({ 161 PeopleShipAttentionContentListTopComponent({
160 followList: this.followList 162 followList: this.followList
161 }) 163 })
162 } 164 }
  165 +
163 ForEach(this.attentionList, (item: ContentDTO) => { 166 ForEach(this.attentionList, (item: ContentDTO) => {
164 ListItem() { 167 ListItem() {
165 - CardParser({compDTO:new CompDTO, contentDTO: item }) 168 + Column(){
  169 + CardParser({ compDTO: new CompDTO, contentDTO: item })
  170 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
  171 + }.width('100%')
  172 +
166 }.width("100%") 173 }.width("100%")
167 .backgroundColor(Color.Transparent) 174 .backgroundColor(Color.Transparent)
168 175
169 - }, (item: ContentDTO, index: number) => item.objectId + index.toString()) 176 + }, (item: ContentDTO, index: number) => item.objectId + index.toString())
170 177
171 // 加载更多 178 // 加载更多
172 ListItem() { 179 ListItem() {
@@ -193,7 +200,8 @@ export struct PeopleShipMainComponent { @@ -193,7 +200,8 @@ export struct PeopleShipMainComponent {
193 } 200 }
194 201
195 onChange() { 202 onChange() {
196 - if (this.navIndex === this.currentTopNavSelectedIndex && (this.viewType == ViewType.LOADING || this.pageAttentionChange)) { 203 + if (this.navIndex === this.currentTopNavSelectedIndex &&
  204 + (this.viewType == ViewType.LOADING || this.pageAttentionChange)) {
197 this.getData(); 205 this.getData();
198 } 206 }
199 } 207 }
@@ -221,7 +229,6 @@ export struct PeopleShipMainComponent { @@ -221,7 +229,6 @@ export struct PeopleShipMainComponent {
221 this.getRmhRecommendInfo(resolve) 229 this.getRmhRecommendInfo(resolve)
222 } else { 230 } else {
223 this.followList = [] 231 this.followList = []
224 - // this.followList = followInfo.list  
225 this.followList.push(...followInfo.list) 232 this.followList.push(...followInfo.list)
226 this.attentionList = [] 233 this.attentionList = []
227 this.currentPage = 1 234 this.currentPage = 1
@@ -289,7 +296,7 @@ export struct PeopleShipMainComponent { @@ -289,7 +296,7 @@ export struct PeopleShipMainComponent {
289 } 296 }
290 //批量查询各类型内容动态数据接口 297 //批量查询各类型内容动态数据接口
291 this.checkContentInteractData(listData.list, resolve) 298 this.checkContentInteractData(listData.list, resolve)
292 - } else { 299 + } else {
293 this.hasMore = false; 300 this.hasMore = false;
294 this.resolveEnd(true, resolve) 301 this.resolveEnd(true, resolve)
295 } 302 }
@@ -319,7 +326,7 @@ export struct PeopleShipMainComponent { @@ -319,7 +326,7 @@ export struct PeopleShipMainComponent {
319 this.resolveEnd(true, resolve) 326 this.resolveEnd(true, resolve)
320 list.forEach((element: ContentDTO) => { 327 list.forEach((element: ContentDTO) => {
321 // 获取 interactData 数据 328 // 获取 interactData 数据
322 - if (listData && listData.length > 0) { 329 + if (listData && listData.length > 0) {
323 const objc = listData.find((interactModel: InteractDataDTO) => { 330 const objc = listData.find((interactModel: InteractDataDTO) => {
324 return element.objectId == interactModel.contentId 331 return element.objectId == interactModel.contentId
325 }) 332 })
@@ -343,7 +350,7 @@ export struct PeopleShipMainComponent { @@ -343,7 +350,7 @@ export struct PeopleShipMainComponent {
343 if (resolve) { 350 if (resolve) {
344 if (this.currentPage == 1 && isTop) { 351 if (this.currentPage == 1 && isTop) {
345 resolve('已更新至最新') 352 resolve('已更新至最新')
346 - }else { 353 + } else {
347 resolve('') 354 resolve('')
348 } 355 }
349 } 356 }
@@ -357,12 +364,13 @@ export struct PeopleShipMainComponent { @@ -357,12 +364,13 @@ export struct PeopleShipMainComponent {
357 364
358 // 说是首页必须要调用 365 // 说是首页必须要调用
359 async getInitData() { 366 async getInitData() {
360 - Logger.debug('PeopleShipMainComponent', `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`); 367 + Logger.debug('PeopleShipMainComponent',
  368 + `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`);
361 this.pageModel.pageId = this.pageId; 369 this.pageModel.pageId = this.pageId;
362 this.pageModel.groupId = this.pageId; 370 this.pageModel.groupId = this.pageId;
363 this.pageModel.channelId = this.channelId; 371 this.pageModel.channelId = this.channelId;
364 this.pageModel.currentPage = 1; 372 this.pageModel.currentPage = 1;
365 - PageHelper.getInitData(this.pageModel, this.pageAdvModel) 373 + PageFollowHelper.getInitData(this.pageModel)
366 } 374 }
367 375
368 // 点击一键关注 376 // 点击一键关注
@@ -388,7 +396,7 @@ export struct PeopleShipMainComponent { @@ -388,7 +396,7 @@ export struct PeopleShipMainComponent {
388 // 获取列表数据 396 // 获取列表数据
389 let objects = new AttentionBatchDTO() 397 let objects = new AttentionBatchDTO()
390 this.rmhList.forEach((element: RmhRecommendDTO) => { 398 this.rmhList.forEach((element: RmhRecommendDTO) => {
391 - if ( this.rmhSelectedList.indexOf(element.creatorId) != -1) { 399 + if (this.rmhSelectedList.indexOf(element.creatorId) != -1) {
392 const creator = new CreatorDTO(element.userType, element.userId, element.creatorId) 400 const creator = new CreatorDTO(element.userType, element.userId, element.creatorId)
393 objects.creators.push(creator) 401 objects.creators.push(creator)
394 } 402 }
@@ -413,7 +421,7 @@ export struct PeopleShipMainComponent { @@ -413,7 +421,7 @@ export struct PeopleShipMainComponent {
413 421
414 // 页面展示监听 422 // 页面展示监听
415 onPageShowChange() { 423 onPageShowChange() {
416 - if (this.navIndex === this.currentTopNavSelectedIndex && this.pageAttentionChange ) { 424 + if (this.navIndex === this.currentTopNavSelectedIndex && this.pageAttentionChange) {
417 this.getData() 425 this.getData()
418 } 426 }
419 } 427 }
@@ -56,7 +56,6 @@ export struct PeopleShipRecommendComponent { @@ -56,7 +56,6 @@ export struct PeopleShipRecommendComponent {
56 .width('100%') 56 .width('100%')
57 .alignSelf(ItemAlign.Start) 57 .alignSelf(ItemAlign.Start)
58 .margin({ 58 .margin({
59 - top: '-50vp',  
60 bottom: '10vp' 59 bottom: '10vp'
61 }) 60 })
62 61
@@ -294,11 +294,12 @@ export struct SearchResultContentComponent { @@ -294,11 +294,12 @@ export struct SearchResultContentComponent {
294 CardParser({compDTO:new CompDTO, contentDTO: item }) 294 CardParser({compDTO:new CompDTO, contentDTO: item })
295 } 295 }
296 if (index != this.data.totalCount() - 1) { 296 if (index != this.data.totalCount() - 1) {
297 - Divider()  
298 - .width('100%')  
299 - .height('1lpx')  
300 - .color($r('app.color.color_F5F5F5'))  
301 - .strokeWidth('1lpx') 297 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
  298 + // Divider()
  299 + // .width('100%')
  300 + // .height('1lpx')
  301 + // .color($r('app.color.color_F5F5F5'))
  302 + // .strokeWidth('1lpx')
302 } 303 }
303 } 304 }
304 } 305 }
1 @Component 1 @Component
2 export struct PermissionDesComponent { 2 export struct PermissionDesComponent {
3 @State translateY: number = 0 3 @State translateY: number = 0
  4 + @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
4 5
5 aboutToAppear(): void { 6 aboutToAppear(): void {
6 this.startDismiss() 7 this.startDismiss()
@@ -29,7 +30,7 @@ export struct PermissionDesComponent { @@ -29,7 +30,7 @@ export struct PermissionDesComponent {
29 // .height(60) 30 // .height(60)
30 .backgroundColor('#FFFFFF') 31 .backgroundColor('#FFFFFF')
31 .border({ radius: 5 }) 32 .border({ radius: 5 })
32 - .margin({ top: 12 }) 33 + .margin({ top: px2vp(this.topSafeHeight) })
33 .padding(12) 34 .padding(12)
34 .zIndex(20) 35 .zIndex(20)
35 } 36 }
  1 +import { CompDTO, ContentDTO, InteractDataDTO, LiveReviewDTO, LiveRoomDataBean, PageDTO, PageInfoDTO } from 'wdBean';
  2 +import { CompStyle, ViewType } from 'wdConstant/Index';
  3 +import { CollectionUtils, DateTimeUtils, LazyDataSource, Logger, NetworkUtil, StringUtils, ToastUtils } from 'wdKit';
  4 +import { closeRefresh } from '../utils/PullDownRefresh';
  5 +import PageModel from './PageModel';
  6 +import PageViewModel from './PageViewModel';
  7 +import { promptAction } from '@kit.ArkUI';
  8 +import { CompAdvBean } from 'wdBean/src/main/ets/bean/adv/AdvsRuleBean';
  9 +import PageAdModel from './PageAdvModel';
  10 +import { ArrayList } from '@kit.ArkTS';
  11 +import { WDViewDefaultType } from '../components/view/EmptyComponent';
  12 +import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean';
  13 +import { BaseDTO } from 'wdBean/src/main/ets/bean/component/BaseDTO';
  14 +import { viewBlogInsightIntentShare, ActionMode } from '../utils/InsightIntentShare'
  15 +import { common } from '@kit.AbilityKit';
  16 +import { CacheData } from 'wdNetwork/Index';
  17 +import { closeLoadMore } from '../utils/PullUpLoadMore';
  18 +
  19 +const TAG = 'PageHelper';
  20 +
  21 +
  22 +/**
  23 + * 处理返回后的数据
  24 + */
  25 +export class PageFollowHelper {
  26 + private refreshUIEnd(pageModel: PageModel, isRefreshSuccess: boolean) {
  27 + if (pageModel.loadStrategy != 2) {
  28 + return
  29 + }
  30 + closeRefresh(pageModel, isRefreshSuccess)
  31 + }
  32 +
  33 +
  34 +
  35 + /**
  36 + * 进页面请求数据
  37 + */
  38 + async getInitData(pageModel: PageModel) {
  39 + pageModel.loadStrategy = 1
  40 + let netStatus = NetworkUtil.isNetConnected()
  41 + if (netStatus) {
  42 + this.getPageInfo(pageModel)
  43 + } else if (pageModel.compList.size() > 0) {
  44 + // 加载缓存数据了,不用无网络提示
  45 + } else {
  46 + pageModel.viewType = ViewType.EMPTY;
  47 + pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoNetwork;
  48 + }
  49 + }
  50 +
  51 + getPageInfo(pageModel: PageModel) {
  52 + pageModel.currentPage = 1;
  53 + Logger.debug(TAG, 'getPageInfo')
  54 + PageViewModel.getPageInfo(pageModel.pageId).then(pageInfo => {
  55 + Logger.debug(TAG, 'getPageInfo back: ' + JSON.stringify(pageInfo))
  56 + if (pageInfo == null) {
  57 + pageModel.viewType = ViewType.EMPTY;
  58 + pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoContent1;
  59 + return;
  60 + }
  61 + pageModel.pageInfo = pageInfo;
  62 +
  63 + Logger.debug(TAG, 'getPageInfo go on')
  64 + }).catch(() => {
  65 + this.refreshUIEnd(pageModel, false)
  66 + if (this.isPageLoaded(pageModel)) {
  67 + return
  68 + }
  69 + pageModel.viewType = ViewType.EMPTY;
  70 + pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_ContentFailed;
  71 + })
  72 + }
  73 +
  74 + private isPageLoaded(pageModel: PageModel) {
  75 + if (pageModel.compList.size() > 0) {
  76 + return true
  77 + }
  78 + return false
  79 + }
  80 +}
  81 +
  82 +
  83 +
  84 +
  85 +let pageHelper = new PageFollowHelper();
  86 +
  87 +export default pageHelper as PageFollowHelper;
@@ -115,7 +115,7 @@ struct LoginPage { @@ -115,7 +115,7 @@ struct LoginPage {
115 Image($r("app.media.login_logo")) 115 Image($r("app.media.login_logo"))
116 .width(120) 116 .width(120)
117 .height(66) 117 .height(66)
118 - .margin({ top: 78 }) 118 + .margin({ top: 78 + px2vp(this.topSafeHeight) })
119 .align(Alignment.Center) 119 .align(Alignment.Center)
120 120
121 LoginInputComponent({ 121 LoginInputComponent({
@@ -225,7 +225,7 @@ struct LoginPage { @@ -225,7 +225,7 @@ struct LoginPage {
225 Image($r('app.media.login_closed')) 225 Image($r('app.media.login_closed'))
226 .width(24) 226 .width(24)
227 .height(24) 227 .height(24)
228 - .margin({ top: 10, right: 15 }) 228 + .margin({ top:px2vp(this.topSafeHeight), right: 15 })
229 .alignRules({ 229 .alignRules({
230 top: { anchor: "__container__", align: VerticalAlign.Top }, 230 top: { anchor: "__container__", align: VerticalAlign.Top },
231 right: { anchor: "__container__", align: HorizontalAlign.End } 231 right: { anchor: "__container__", align: HorizontalAlign.End }
@@ -249,7 +249,7 @@ struct LoginPage { @@ -249,7 +249,7 @@ struct LoginPage {
249 .backgroundColor(Color.White) 249 .backgroundColor(Color.White)
250 }.width("100%") 250 }.width("100%")
251 .height("100%") 251 .height("100%")
252 - .padding({top:px2vp(this.topSafeHeight),bottom:px2vp(this.bottomSafeHeight)}) 252 + // .padding({top:px2vp(this.topSafeHeight),bottom:px2vp(this.bottomSafeHeight)})
253 253
254 } 254 }
255 255
@@ -4,7 +4,7 @@ import { ContentType } from 'wdRouter/Index'; @@ -4,7 +4,7 @@ import { ContentType } from 'wdRouter/Index';
4 4
5 export class DeepLinkUtil { 5 export class DeepLinkUtil {
6 6
7 - private static DEEP_LINK_PREFIX = "rmrbapp:rmrb.app/openwith" 7 + private static DEEP_LINK_PREFIX = "rmrbapp://rmrb.app/openwith"
8 8
9 static generateDeepLinkWithConent(content: ContentDetailDTO): string { 9 static generateDeepLinkWithConent(content: ContentDetailDTO): string {
10 10
@@ -23,7 +23,7 @@ export class DeepLinkUtil { @@ -23,7 +23,7 @@ export class DeepLinkUtil {
23 private static generate(contentType: number, contentId?: string, relId?: string, link?: string): string { 23 private static generate(contentType: number, contentId?: string, relId?: string, link?: string): string {
24 let deeplink = DeepLinkUtil.DEEP_LINK_PREFIX 24 let deeplink = DeepLinkUtil.DEEP_LINK_PREFIX
25 25
26 - let pubParam = `&contentId=${contentId}}&relId=${relId}&skipType=1` 26 + let pubParam = `&contentId=${contentId}&relId=${relId}&skipType=1`
27 27
28 let type: ContentType = Number(contentType) 28 let type: ContentType = Number(contentType)
29 switch (type) { 29 switch (type) {
@@ -38,7 +38,7 @@ export class DeepLinkUtil { @@ -38,7 +38,7 @@ export class DeepLinkUtil {
38 deeplink += "?type=article&subType=h5" 38 deeplink += "?type=article&subType=h5"
39 deeplink += "&url=" + encodeURIComponent(link) 39 deeplink += "&url=" + encodeURIComponent(link)
40 } else { 40 } else {
41 - deeplink += "type=article&subType=h5_template_article" 41 + deeplink += "?type=article&subType=h5_template_article"
42 } 42 }
43 break 43 break
44 case ContentType.DynamicImageText: 44 case ContentType.DynamicImageText:
1 import { formBindingData, FormExtensionAbility, formInfo, formProvider } from '@kit.FormKit'; 1 import { formBindingData, FormExtensionAbility, formInfo, formProvider } from '@kit.FormKit';
2 import { Want } from '@kit.AbilityKit'; 2 import { Want } from '@kit.AbilityKit';
3 -import { Logger, NetworkManager, SPHelper, StringUtils } from 'wdKit/Index'; 3 +import { FileUtils, Logger, NetworkManager, SPHelper, StringUtils } from 'wdKit/Index';
4 import { BusinessError } from '@kit.BasicServicesKit'; 4 import { BusinessError } from '@kit.BasicServicesKit';
5 -import { FormDataType, NewspaperDataFetcher } from './NewspaperDataFetcher'; 5 +import { NewspaperDataFetcher } from './NewspaperDataFetcher';
6 import { JSON } from '@kit.ArkTS'; 6 import { JSON } from '@kit.ArkTS';
7 -import { FormNewspaperPaperType } from '../dailynewspaperwidget/common/NewspaperWidgetData'; 7 +import { FormNewspaperData, FormNewspaperPaperType } from '../dailynewspaperwidget/common/NewspaperWidgetData';
8 import { HostEnum, HostManager, WDHttp } from 'wdNetwork/Index'; 8 import { HostEnum, HostManager, WDHttp } from 'wdNetwork/Index';
  9 +import fs from '@ohos.file.fs';
9 10
10 const TAG = "DailyNewspaperFormAbility" 11 const TAG = "DailyNewspaperFormAbility"
11 12
12 export default class DailyNewspaperFormAbility extends FormExtensionAbility { 13 export default class DailyNewspaperFormAbility extends FormExtensionAbility {
  14 + lastDatas: Record<string, FormNewspaperData> = {}
  15 +
13 onAddForm(want: Want) { 16 onAddForm(want: Want) {
14 Logger.debug(TAG, "onAddForm with " + JSON.stringify(want)) 17 Logger.debug(TAG, "onAddForm with " + JSON.stringify(want))
15 18
16 this.initApp() 19 this.initApp()
17 - 20 +
18 if (want.parameters) { 21 if (want.parameters) {
19 let formId = want.parameters[formInfo.FormParam.IDENTITY_KEY] as string 22 let formId = want.parameters[formInfo.FormParam.IDENTITY_KEY] as string
20 let isTempCard = want.parameters[formInfo.FormParam.TEMPORARY_KEY] as boolean 23 let isTempCard = want.parameters[formInfo.FormParam.TEMPORARY_KEY] as boolean
21 if (isTempCard === false) { // 如果为常态卡片,直接进行信息持久化 24 if (isTempCard === false) { // 如果为常态卡片,直接进行信息持久化
22 25
23 - Logger.debug(TAG, "开始刷新数据");  
24 - NewspaperDataFetcher.refreshDailyPaper().then((data) => {  
25 -  
26 - let formData = formBindingData.createFormBindingData(data);  
27 - formProvider.updateForm(formId, formData).catch((err: BusinessError) => {  
28 - Logger.debug(TAG, ` xFailed to updateForm. Code: ${err.code}, message: ${err.message}`);  
29 - });  
30 - }) 26 + this.fetchAndRefreshData(formId)
31 } 27 }
32 } 28 }
33 29
34 - let obj: FormDataType = {} 30 + let obj: FormNewspaperData = {} as FormNewspaperData
35 obj.paperType = FormNewspaperPaperType.unknown 31 obj.paperType = FormNewspaperPaperType.unknown
36 let formData = formBindingData.createFormBindingData(obj); 32 let formData = formBindingData.createFormBindingData(obj);
37 return formData; 33 return formData;
@@ -45,13 +41,9 @@ export default class DailyNewspaperFormAbility extends FormExtensionAbility { @@ -45,13 +41,9 @@ export default class DailyNewspaperFormAbility extends FormExtensionAbility {
45 onUpdateForm(formId: string) { 41 onUpdateForm(formId: string) {
46 // 若卡片支持定时更新/定点更新/卡片使用方主动请求更新功能,则提供方需要重写该方法以支持数据更新 42 // 若卡片支持定时更新/定点更新/卡片使用方主动请求更新功能,则提供方需要重写该方法以支持数据更新
47 Logger.debug(TAG, 'onUpdateForm ' + formId); 43 Logger.debug(TAG, 'onUpdateForm ' + formId);
48 - NewspaperDataFetcher.refreshDailyPaper().then((data) => {  
49 44
50 - let formData = formBindingData.createFormBindingData(data);  
51 - formProvider.updateForm(formId, formData).catch((err: BusinessError) => {  
52 - Logger.debug(TAG, ` xFailed to updateForm. Code: ${err.code}, message: ${err.message}`);  
53 - });  
54 - }) 45 + this.initApp()
  46 + this.fetchAndRefreshData(formId)
55 } 47 }
56 48
57 onFormEvent(formId: string, message: string) { 49 onFormEvent(formId: string, message: string) {
@@ -61,7 +53,9 @@ export default class DailyNewspaperFormAbility extends FormExtensionAbility { @@ -61,7 +53,9 @@ export default class DailyNewspaperFormAbility extends FormExtensionAbility {
61 53
62 onRemoveForm(formId: string) { 54 onRemoveForm(formId: string) {
63 // 当对应的卡片删除时触发的回调,入参是被删除的卡片ID 55 // 当对应的卡片删除时触发的回调,入参是被删除的卡片ID
64 - Logger.debug(TAG, 'onRemoveForm'); 56 + Logger.debug(TAG, 'onRemoveForm / formId: ' + formId);
  57 + let data = this.lastDatas[formId]
  58 + NewspaperDataFetcher.closeFilesWith(data)
65 } 59 }
66 60
67 // onConfigurationUpdate(config: Configuration) { 61 // onConfigurationUpdate(config: Configuration) {
@@ -75,6 +69,32 @@ export default class DailyNewspaperFormAbility extends FormExtensionAbility { @@ -75,6 +69,32 @@ export default class DailyNewspaperFormAbility extends FormExtensionAbility {
75 return formInfo.FormState.READY; 69 return formInfo.FormState.READY;
76 } 70 }
77 71
  72 + fetchAndRefreshData(formId: string) {
  73 + Logger.debug(TAG, "开始刷新数据");
  74 + NewspaperDataFetcher.refreshDailyPaper().then(async (data) => {
  75 +
  76 + let formData = formBindingData.createFormBindingData(data);
  77 + formProvider.updateForm(formId, formData).then(() => {
  78 + this.lastDatas[formId] = data
  79 + }).catch((err: BusinessError) => {
  80 + Logger.debug(TAG, ` xFailed to updateForm. Code: ${err.code}, message: ${err.message}`);
  81 + });
  82 +
  83 + let fileDir = this.context.getApplicationContext().filesDir + "/widget-daily-newspaper"
  84 + await FileUtils.makeDirIfNotExsit(fileDir)
  85 +
  86 + NewspaperDataFetcher.dealWithPictures(data, formId, fileDir, (data) => {
  87 + Logger.debug(TAG, `refresh ui with new pictuers`);
  88 + let formData = formBindingData.createFormBindingData(data);
  89 + formProvider.updateForm(formId, formData).then(() => {
  90 + this.lastDatas[formId] = data
  91 + }).catch((err: BusinessError) => {
  92 + Logger.error(TAG, ` xFailed to updateForm. Code: ${err.code}, message: ${err.message}`);
  93 + });
  94 + })
  95 + })
  96 + }
  97 +
78 initApp() { 98 initApp() {
79 // KV存储 99 // KV存储
80 SPHelper.init(this.context); 100 SPHelper.init(this.context);
1 import { CompInfoBean, ContentDTO, PageInfoBean } from 'wdBean/Index'; 1 import { CompInfoBean, ContentDTO, PageInfoBean } from 'wdBean/Index';
2 import { MorningEveningViewModel } from 'wdComponent/Index'; 2 import { MorningEveningViewModel } from 'wdComponent/Index';
3 -import { Logger } from 'wdKit/Index'; 3 +import { CrptoUtils, FileUtils, Logger } from 'wdKit/Index';
4 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork/Index'; 4 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork/Index';
5 import { DeepLinkUtil } from 'wdShare/Index' 5 import { DeepLinkUtil } from 'wdShare/Index'
6 -import { FormNewspaperPaperType, FormNewspaperPaperInfo, FormNewspaperPaperContent } from "../dailynewspaperwidget/common/NewspaperWidgetData" 6 +import { FormNewspaperPaperType, FormNewspaperPaperInfo, FormNewspaperPaperContent,
  7 + FormNewspaperData } from "../dailynewspaperwidget/common/NewspaperWidgetData"
  8 +import { http } from '@kit.NetworkKit';
  9 +import fs from '@ohos.file.fs';
  10 +import { BusinessError } from '@kit.BasicServicesKit';
  11 +import { JSON } from '@kit.ArkTS';
7 12
8 const TAG = "NewspaperDataFetcher" 13 const TAG = "NewspaperDataFetcher"
9 14
10 -export type FormDataType = Record<string, FormNewspaperPaperType | FormNewspaperPaperInfo | FormNewspaperPaperContent[]> 15 +// export type FormDataType = Record<string, FormNewspaperPaperType | FormNewspaperPaperInfo | FormNewspaperPaperContent[]>
11 16
12 export class NewspaperDataFetcher { 17 export class NewspaperDataFetcher {
13 18
14 - public static async refreshDailyPaper(): Promise<FormDataType> {  
15 - return new Promise<FormDataType>(async (reslove, fail) => { 19 + public static async refreshDailyPaper(): Promise<FormNewspaperData> {
  20 + return new Promise<FormNewspaperData>(async (reslove, fail) => {
16 21
17 - let data: FormDataType = { 'paperType': FormNewspaperPaperType.unknown } 22 + let data: FormNewspaperData = new FormNewspaperData()
18 data.paperInfo = { showLeftImage: false } 23 data.paperInfo = { showLeftImage: false }
19 24
20 try { 25 try {
21 let page: PageInfoBean = await MorningEveningViewModel.getDailyPaperTopic() 26 let page: PageInfoBean = await MorningEveningViewModel.getDailyPaperTopic()
22 - data.paperType = page.topicInfo?.frontFlag || FormNewspaperPaperType.unknown 27 + data.paperType = page.topicInfo?.topicPattern || FormNewspaperPaperType.unknown
23 28
24 let currentTime = new Date().getTime() 29 let currentTime = new Date().getTime()
25 let compInfo = await MorningEveningViewModel.getMorningEveningCompInfo( 30 let compInfo = await MorningEveningViewModel.getMorningEveningCompInfo(
@@ -29,7 +34,7 @@ export class NewspaperDataFetcher { @@ -29,7 +34,7 @@ export class NewspaperDataFetcher {
29 page.topicInfo?.topicId 34 page.topicInfo?.topicId
30 ) 35 )
31 36
32 - if (page.topicInfo.frontLinkObject) { 37 + if (page.topicInfo?.frontFlag && page.topicInfo.frontLinkObject) {
33 data.paperInfo.showLeftImage = true 38 data.paperInfo.showLeftImage = true
34 data.paperInfo.leftImageUrl = page.topicInfo.frontLinkObject.coverUrl 39 data.paperInfo.leftImageUrl = page.topicInfo.frontLinkObject.coverUrl
35 data.paperInfo.leftTitle = page.topicInfo.frontLinkObject.title 40 data.paperInfo.leftTitle = page.topicInfo.frontLinkObject.title
@@ -60,7 +65,7 @@ export class NewspaperDataFetcher { @@ -60,7 +65,7 @@ export class NewspaperDataFetcher {
60 }) 65 })
61 } 66 }
62 67
63 - static fakeData(): FormDataType { 68 + static fakeData(): FormNewspaperData {
64 let data : FormNewspaperPaperContent = { 69 let data : FormNewspaperPaperContent = {
65 title: "标题标题标题标题标题标题标题标题", 70 title: "标题标题标题标题标题标题标题标题",
66 coverUrl: "https://" 71 coverUrl: "https://"
@@ -72,6 +77,135 @@ export class NewspaperDataFetcher { @@ -72,6 +77,135 @@ export class NewspaperDataFetcher {
72 leftTitle: "leftTitleleftTitleleftTitleleftTitleleftTitleleftTitle" 77 leftTitle: "leftTitleleftTitleleftTitleleftTitleleftTitleleftTitle"
73 }, 78 },
74 "paperContents": [data, data, data] 79 "paperContents": [data, data, data]
  80 + } as FormNewspaperData
  81 + }
  82 +
  83 + static dealWithPictures(data: FormNewspaperData, formId: string ,tempDir: string, refreshCallback:(data: FormNewspaperData) => void) {
  84 +
  85 + let donwloadCount = data.paperContents.filter((value) => {
  86 + return value.coverUrl && value.coverUrl.length > 0
  87 + }).length
  88 +
  89 + let fileFDs: Record<string, string | number> = {};
  90 + if (data.paperInfo.leftImageUrl) {
  91 + donwloadCount += 1
  92 +
  93 + CrptoUtils.md5(data.paperInfo.leftImageUrl).then((md5String) => {
  94 +
  95 + const fileName = formId + "file" + md5String;
  96 + const filePath = tempDir + "/" + fileName
  97 + NewspaperDataFetcher.downloadUrlToPath(data.paperInfo.leftImageUrl!, filePath).then(() => {
  98 + let file = fs.openSync(filePath)
  99 + fileFDs[fileName] = file.fd
  100 + data.paperInfo.localLeftImageFileName = fileName
  101 + data.formImages = fileFDs
  102 +
  103 + if (--donwloadCount == 0) { refreshCallback(data) }
  104 + }).catch((e : BusinessError) => {
  105 + Logger.debug(TAG, "download file failed.");
  106 + if (--donwloadCount == 0) { refreshCallback(data) }
  107 + })
  108 + }).catch((e: BusinessError) => {
  109 + if (--donwloadCount == 0) { refreshCallback(data) }
  110 + })
  111 + }
  112 +
  113 +
  114 + for (let index = 0; index < data.paperContents.length; index++) {
  115 + const content = data.paperContents[index];
  116 + if (!content.coverUrl || content.coverUrl.length == 0) {
  117 + continue
  118 + }
  119 +
  120 + CrptoUtils.md5(content.coverUrl).then((md5String) => {
  121 + const fileName = formId + "file" + md5String;
  122 + const filePath = tempDir + "/" + fileName
  123 + NewspaperDataFetcher.downloadUrlToPath(content.coverUrl!, filePath).then(() => {
  124 + Logger.debug(TAG, "open file for display ");
  125 + let file = fs.openSync(filePath)
  126 + fileFDs[fileName] = file.fd
  127 + data.paperContents[index].localCoverFileName = fileName
  128 + data.formImages = fileFDs
  129 +
  130 + if (--donwloadCount == 0) { refreshCallback(data) }
  131 + }).catch((e : BusinessError) => {
  132 + Logger.debug(TAG, "download file failed." + JSON.stringify(e));
  133 + if (--donwloadCount == 0) { refreshCallback(data) }
  134 + })
  135 + }).catch((e: BusinessError) => {
  136 + if (--donwloadCount == 0) { refreshCallback(data) }
  137 + })
75 } 138 }
76 } 139 }
  140 +
  141 + static closeFilesWith(data?: FormNewspaperData) {
  142 + if (data && data.formImages) {
  143 + for (const obj of Object.entries(data.formImages)) {
  144 + const fileName = obj[0]
  145 + let fd: number = obj[1] as number
  146 + fs.close(fd)
  147 + }
  148 + }
  149 + }
  150 +
  151 + static downloadUrlToPath(url: string, toFilePath: string): Promise<void> {
  152 + Logger.debug(TAG, "will donwload url:" + url + " ======> " + toFilePath);
  153 +
  154 + return new Promise((reslove, fail) => {
  155 +
  156 + FileUtils.fileExsit(toFilePath).then((exsit: boolean) => {
  157 + if (exsit) {
  158 + Logger.debug(TAG, "file is exsit. " + toFilePath);
  159 + reslove()
  160 + return
  161 + }
  162 +
  163 + NewspaperDataFetcher.downloadUrlToPathWithout(url, toFilePath).then(() => {
  164 + reslove()
  165 + }).catch((e: BusinessError) => {
  166 + fail(e)
  167 + })
  168 + }).catch((e: BusinessError) => {
  169 + NewspaperDataFetcher.downloadUrlToPathWithout(url, toFilePath).then(() => {
  170 + reslove()
  171 + }).catch((e: BusinessError) => {
  172 + fail(e)
  173 + })
  174 + })
  175 + })
  176 + }
  177 +
  178 + static downloadUrlToPathWithout(url: string, toFilePath: string): Promise<void> {
  179 + Logger.debug(TAG, "will donwload url:" + url + " ======> " + toFilePath);
  180 +
  181 + return new Promise((reslove, fail) => {
  182 +
  183 + let httpRequest = http.createHttp()
  184 + httpRequest.request(url, (err, data) => {
  185 +
  186 + if (!err && data.responseCode == http.ResponseCode.OK) {
  187 + let imgFile = fs.openSync(toFilePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
  188 + let wroteLength = 0
  189 + fs.write(imgFile.fd, data.result as ArrayBuffer).then((writeLen: number) => {
  190 + Logger.debug(TAG, "write data to file succeed and size is:" + writeLen);
  191 + wroteLength = writeLen
  192 + }).catch((err: BusinessError) => {
  193 + Logger.error(TAG, "write data to file failed with error message: " + err.message + ", error code: " + err.code);
  194 + }).finally(() => {
  195 + fs.closeSync(imgFile);
  196 + httpRequest.destroy()
  197 +
  198 + wroteLength > 0 ? reslove() : fail("failed")
  199 + });
  200 + return
  201 + }
  202 +
  203 + httpRequest.destroy()
  204 + fail("failed")
  205 + });
  206 +
  207 + })
  208 + }
  209 +
  210 +
77 } 211 }
@@ -11,6 +11,8 @@ export class FormNewspaperPaperInfo { @@ -11,6 +11,8 @@ export class FormNewspaperPaperInfo {
11 showLeftImage: boolean = false 11 showLeftImage: boolean = false
12 12
13 leftImageUrl?: string 13 leftImageUrl?: string
  14 + localLeftImageFileName?: ResourceStr // 传递图片用
  15 + localLeftImageFileFD? : number // 传递图片用
14 leftTitle?: string 16 leftTitle?: string
15 leftDeepLink?: string 17 leftDeepLink?: string
16 18
@@ -20,5 +22,15 @@ export class FormNewspaperPaperInfo { @@ -20,5 +22,15 @@ export class FormNewspaperPaperInfo {
20 export class FormNewspaperPaperContent { 22 export class FormNewspaperPaperContent {
21 title: string = "" 23 title: string = ""
22 coverUrl?: string 24 coverUrl?: string
  25 + localCoverFileName?: ResourceStr // 传递图片用
  26 + localCoverFileFD? : number // 传递图片用
23 deepLink: string = "" 27 deepLink: string = ""
24 } 28 }
  29 +
  30 +export class FormNewspaperData {
  31 + paperType: FormNewspaperPaperType = FormNewspaperPaperType.unknown
  32 + paperInfo: FormNewspaperPaperInfo = {} as FormNewspaperPaperInfo
  33 + paperContents: FormNewspaperPaperContent[] = []
  34 +
  35 + formImages: Record<string, string | number> = {}
  36 +}
@@ -43,8 +43,8 @@ struct DailyNewspaperWidgetCard { @@ -43,8 +43,8 @@ struct DailyNewspaperWidgetCard {
43 43
44 @Builder leftImageView() { 44 @Builder leftImageView() {
45 Stack({ alignContent: Alignment.Bottom }) { 45 Stack({ alignContent: Alignment.Bottom }) {
46 - Image(this.paperInfo.leftImageUrl)  
47 - // Image($r("app.media.desktop_card_comp_place_holder_16_9")) 46 + Image("memory://" + this.paperInfo.localLeftImageFileName)
  47 + // Image(this.paperInfo.leftImageUrl)
48 .alt($r("app.media.desktop_card_comp_place_holder_16_9")) 48 .alt($r("app.media.desktop_card_comp_place_holder_16_9"))
49 .objectFit(ImageFit.Cover) 49 .objectFit(ImageFit.Cover)
50 .aspectRatio(87/116) 50 .aspectRatio(87/116)
@@ -109,8 +109,8 @@ struct ContentCellView { @@ -109,8 +109,8 @@ struct ContentCellView {
109 bottom: this.hasImage ? 0 : 6}) 109 bottom: this.hasImage ? 0 : 6})
110 110
111 if (this.hasImage) { 111 if (this.hasImage) {
112 - Image(this.content.coverUrl)  
113 - // Image($r("app.media.desktop_card_comp_place_holder_3_4")) 112 + Image("memory://" + this.content.localCoverFileName)
  113 + // Image(this.content.coverUrl)
114 .alt($r("app.media.desktop_card_comp_place_holder_3_4")) 114 .alt($r("app.media.desktop_card_comp_place_holder_3_4"))
115 .objectFit(ImageFit.Cover) 115 .objectFit(ImageFit.Cover)
116 .height(40) 116 .height(40)
@@ -151,14 +151,12 @@ function jumpWithDeepLink(deepLink: string, component: Object) { @@ -151,14 +151,12 @@ function jumpWithDeepLink(deepLink: string, component: Object) {
151 if (deepLink.length == 0) { 151 if (deepLink.length == 0) {
152 return 152 return
153 } 153 }
154 - const deepLinkKey: string = NewspaperWidgetCommon.JumpParam.DeepLinkKey  
155 - const fromDailyNewspaperKey: string = NewspaperWidgetCommon.JumpParam.FromNewspaperWidgetKey  
156 postCardAction(component, { 154 postCardAction(component, {
157 action: NewspaperWidgetCommon.PosterCardAction.ActionRouter, 155 action: NewspaperWidgetCommon.PosterCardAction.ActionRouter,
158 abilityName: NewspaperWidgetCommon.PosterCardAction.MainAbilityName, 156 abilityName: NewspaperWidgetCommon.PosterCardAction.MainAbilityName,
159 params: { 157 params: {
160 - deepLinkKey: deepLink,  
161 - fromDailyNewspaperKey: true 158 + "newspaper.widget.jump.deeplink": deepLink,
  159 + "newspaper.widget.jump.fromNewspaperWidget": 1
162 } 160 }
163 }); 161 });
164 } 162 }
@@ -53,7 +53,7 @@ export struct BottomNavigationComponent { @@ -53,7 +53,7 @@ export struct BottomNavigationComponent {
53 // 自动刷新触发(双击tab自动刷新) 53 // 自动刷新触发(双击tab自动刷新)
54 @State autoRefresh: number = 0 54 @State autoRefresh: number = 0
55 // 顶导数据,从接口获取 TODO 顶导业务逻辑没看懂,暂时不替换顶导list。频道管理数据待梳理 55 // 顶导数据,从接口获取 TODO 顶导业务逻辑没看懂,暂时不替换顶导list。频道管理数据待梳理
56 - @State topNavMap: Record<string, TopNavDTO[]> = {} 56 + // @State topNavMap: Record<string, TopNavDTO[]> = {}
57 57
58 async aboutToAppear() { 58 async aboutToAppear() {
59 Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`); 59 Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`);
@@ -12,13 +12,14 @@ import { DeviceUtil, @@ -12,13 +12,14 @@ import { DeviceUtil,
12 UmengStats } from 'wdKit/Index' 12 UmengStats } from 'wdKit/Index'
13 import { LoginModule } from 'wdLogin/Index' 13 import { LoginModule } from 'wdLogin/Index'
14 import { HostEnum, HostManager, WDHttp } from 'wdNetwork/Index' 14 import { HostEnum, HostManager, WDHttp } from 'wdNetwork/Index'
15 -import { registerRouter } from 'wdRouter/Index' 15 +import { AppInnerLink, registerRouter } from 'wdRouter/Index'
16 import { TrackingModule } from 'wdTracking/Index' 16 import { TrackingModule } from 'wdTracking/Index'
17 import { JSON } from '@kit.ArkTS' 17 import { JSON } from '@kit.ArkTS'
18 import app from '@system.app' 18 import app from '@system.app'
19 import { GetuiPush, HWLocationUtils } from 'wdHwAbility/Index' 19 import { GetuiPush, HWLocationUtils } from 'wdHwAbility/Index'
20 import { ImageKnife, ImageKnifeGlobal } from '@ohos/imageknife' 20 import { ImageKnife, ImageKnifeGlobal } from '@ohos/imageknife'
21 import { webview } from '@kit.ArkWeb' 21 import { webview } from '@kit.ArkWeb'
  22 +import { NewspaperWidgetCommon } from '../dailynewspaperwidget/common/NewspaperWidgetCommon'
22 23
23 const TAG = "[StartupManager]" 24 const TAG = "[StartupManager]"
24 25
@@ -26,6 +27,7 @@ const TAG = "[StartupManager]" @@ -26,6 +27,7 @@ const TAG = "[StartupManager]"
26 export class StartupManager { 27 export class StartupManager {
27 28
28 private context?: common.UIAbilityContext 29 private context?: common.UIAbilityContext
  30 + private lastStartupWant?: Want
29 31
30 private constructor() { 32 private constructor() {
31 } 33 }
@@ -74,10 +76,14 @@ export class StartupManager { @@ -74,10 +76,14 @@ export class StartupManager {
74 // 通知栏点击后启动 76 // 通知栏点击后启动
75 GetuiPush.sharedInstance().onWant(want) 77 GetuiPush.sharedInstance().onWant(want)
76 Logger.debug(TAG, "App onCreate: finised") 78 Logger.debug(TAG, "App onCreate: finised")
  79 +
  80 + this.lastStartupWant = want
77 } 81 }
78 82
79 appOnNewWant(want: Want, launchParam: AbilityConstant.LaunchParam) { 83 appOnNewWant(want: Want, launchParam: AbilityConstant.LaunchParam) {
80 GetuiPush.sharedInstance().onNewWant(want) 84 GetuiPush.sharedInstance().onNewWant(want)
  85 +
  86 + this.dealWithDeepLink(want)
81 } 87 }
82 88
83 appOnDestory() { 89 appOnDestory() {
@@ -124,6 +130,10 @@ export class StartupManager { @@ -124,6 +130,10 @@ export class StartupManager {
124 //TODO: 130 //TODO:
125 // 提前初始化webview 131 // 提前初始化webview
126 webview.WebviewController.initializeWebEngine() 132 webview.WebviewController.initializeWebEngine()
  133 +
  134 + if (this.lastStartupWant && this.dealWithDeepLink(this.lastStartupWant)) {
  135 + this.lastStartupWant = undefined
  136 + }
127 resolve() 137 resolve()
128 }) 138 })
129 } 139 }
@@ -195,4 +205,20 @@ export class StartupManager { @@ -195,4 +205,20 @@ export class StartupManager {
195 private initOthers() { 205 private initOthers() {
196 206
197 } 207 }
  208 +
  209 + private dealWithDeepLink(want: Want): boolean {
  210 +
  211 + if (!want.parameters) {
  212 + return false
  213 + }
  214 +
  215 + let deepLink = want.parameters[NewspaperWidgetCommon.JumpParam.DeepLinkKey] as string
  216 +
  217 + if (deepLink && deepLink.length) {
  218 +
  219 + AppInnerLink.jumpWithLink(deepLink)
  220 + return true
  221 + }
  222 + return false
  223 + }
198 } 224 }
@@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
14 "isDynamic": true, 14 "isDynamic": true,
15 "isDefault": true, 15 "isDefault": true,
16 "updateEnabled": true, 16 "updateEnabled": true,
17 - "scheduledUpdateTime": "10:30",  
18 - "updateDuration": 1, 17 + "scheduledUpdateTime": "18:26",
  18 + "updateDuration": 4,
19 "defaultDimension": "2*4", 19 "defaultDimension": "2*4",
20 "supportDimensions": [ 20 "supportDimensions": [
21 "2*4" 21 "2*4"