WDShare.ets
4.44 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import { ContentDetailDTO, ContentDTO, PageInfoDTO, ShareInfoDTO, TopicInfo } from 'wdBean/Index';
import { SharePosterItemBean } from 'wdBean/src/main/ets/bean/detail/SharePosterItemBean';
import { ShareScene, ShareType, WDShareBase } from 'wdShareBase/Index';
import { ShareContentType } from 'wdShareBase/src/main/ets/Constant';
import { bundleManager } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { AppInnerLinkGenerator } from 'wdRouter';
export class WDShare {
static shareContent(content: ContentDetailDTO, pageName: string ="", pageId: string = "") {
//TODO: 处理分享弹框交互和 海报逻辑
WDShareBase.getInstance().share({
to: ShareType.System,
scene: ShareScene.System,
type: ShareContentType.Link,
obj: {
title: content.shareInfo.shareTitle,
desc: content.shareInfo.shareSummary,
link: content.shareInfo.shareUrl,
deeplink:AppInnerLinkGenerator.generateDeepLinkWithConent(content),
}
})
}
static shareProgram(program: ContentDTO, pageName: string ="", pageId: string = "") {
//TODO: 处理分享弹框交互和 海报逻辑
WDShareBase.getInstance().share({
to: ShareType.System,
scene: ShareScene.System,
type: ShareContentType.Link,
obj: {
title: program.shareInfo.shareTitle,
desc: program.shareInfo.shareSummary,
link: program.shareInfo.shareUrl,
deeplink:AppInnerLinkGenerator.generateDeepLinkWithProgram(program),
}
})
}
static shareSubject(subject: PageInfoDTO) {
}
//专题分享数据转换
static setTopicBeanToShareBean(shareBean: ShareInfoDTO, topicInfoBean?: TopicInfo){
shareBean.appCustomTopicType = topicInfoBean?.topicType+''
//21:文章专题,22:音频专题,23:直播专题,24:话题专题,25:早晚报专题,26:时间链
if(25 == topicInfoBean?.topicType){
shareBean.appCustomShowPosterType = 6
shareBean.appCustomTopicPattern = topicInfoBean.topicPattern
shareBean.appCustomPublishTime = topicInfoBean.topicDate
if(topicInfoBean.frontLinkObject == null){
shareBean.appCustomIsFrontDaily = false
if(topicInfoBean.shareContentList != null && topicInfoBean.shareContentList.length>0){
shareBean.appCustomSharePosterItemList = [] as SharePosterItemBean[]
shareBean.appCustomSharePosterItemList.length = topicInfoBean.shareContentList.length
for (let index = 0; index < topicInfoBean.shareContentList.length; index++) {
let element = topicInfoBean.shareContentList[index]
if(element != null){
shareBean.appCustomSharePosterItemList[index] = {
title:topicInfoBean.shareContentList[index].newsTitle,
imageUrl:topicInfoBean.shareContentList[index].coverUrl,
} as SharePosterItemBean
}
}
}
}else{
shareBean.appCustomIsFrontDaily = true
shareBean.sharePosterCoverUrl = topicInfoBean.frontLinkObject.coverUrl
shareBean.appCustomPosterSummary = topicInfoBean.frontLinkObject.summary
}
}else{
//文章/直播/话题专题(H5普通文章专题,包含时间链)
shareBean.appCustomShowPosterType = 8
//海报的头图
shareBean.sharePosterCoverUrl = topicInfoBean?.backgroundImgUrl || ''
shareBean.appCustomIsFrontDaily = false
shareBean.appCustomPosterTitle = topicInfoBean?.title || ''
shareBean.appCustomPosterSummary = topicInfoBean?.summary || ''
if(topicInfoBean?.shareContentList != null && topicInfoBean?.shareContentList && topicInfoBean.shareContentList.length > 0){
shareBean.appCustomSharePosterItemList = [] as SharePosterItemBean[]
shareBean.appCustomSharePosterItemList.length = topicInfoBean.shareContentList.length
for (let index = 0; index < topicInfoBean.shareContentList.length; index++) {
let element = topicInfoBean.shareContentList[index]
if(element != null){
shareBean.appCustomSharePosterItemList[index] = {
title:topicInfoBean.shareContentList[index].newsTitle,
imageUrl:topicInfoBean.shareContentList[index].coverUrl,
timeNode:topicInfoBean.shareContentList[index].publishTime,
timeBlurred:topicInfoBean.shareContentList[index].timeBlurred
} as SharePosterItemBean
}
}
}
}
}
}