Showing
6 changed files
with
148 additions
and
3 deletions
| @@ -15,3 +15,5 @@ export { AssignChannelParam } from './src/main/ets/utils/HomeChannelUtils'; | @@ -15,3 +15,5 @@ export { AssignChannelParam } from './src/main/ets/utils/HomeChannelUtils'; | ||
| 15 | export { RouterJumpInterceptor, JumpInterceptorAction } from './src/main/ets/router/RouterJumpInterceptor' | 15 | export { RouterJumpInterceptor, JumpInterceptorAction } from './src/main/ets/router/RouterJumpInterceptor' |
| 16 | 16 | ||
| 17 | export { AppInnerLink } from './src/main/ets/utils/AppInnerLink' | 17 | export { AppInnerLink } from './src/main/ets/utils/AppInnerLink' |
| 18 | + | ||
| 19 | +export { ContentType } from './src/main/ets/common/ContentType' |
| 1 | +export enum ContentType { | ||
| 2 | + | ||
| 3 | + /// 不跳转 | ||
| 4 | + Unknown = 0, | ||
| 5 | + ///点播 | ||
| 6 | + Video = 1, | ||
| 7 | + | ||
| 8 | + ///直播 | ||
| 9 | + Live = 2, | ||
| 10 | + | ||
| 11 | + ///活动 | ||
| 12 | + Activity = 3, | ||
| 13 | + | ||
| 14 | + ///信息流广告 | ||
| 15 | + InfoflowAD = 4, | ||
| 16 | + | ||
| 17 | + ///专题 | ||
| 18 | + Subject = 5, | ||
| 19 | + | ||
| 20 | + ///链接 | ||
| 21 | + Link = 6, | ||
| 22 | + | ||
| 23 | + ///榜单 | ||
| 24 | + RankList = 7, | ||
| 25 | + | ||
| 26 | + /// 图文 | ||
| 27 | + ImageText = 8, | ||
| 28 | + /// 组图 | ||
| 29 | + Pictures = 9, | ||
| 30 | + | ||
| 31 | + /// H5新闻 (仅海外版存在,视界和中文端无此类型。中文端按照图文8类型+link) | ||
| 32 | + H5News = 10, | ||
| 33 | + /// 频道 | ||
| 34 | + Channel = 11, | ||
| 35 | + ///组件 | ||
| 36 | + Module = 12, | ||
| 37 | + ///音频 | ||
| 38 | + Audio = 13, | ||
| 39 | + ///动态图文 | ||
| 40 | + DynamicImageText = 14, | ||
| 41 | + | ||
| 42 | + ///动态视频 | ||
| 43 | + DynamicVideo = 15, | ||
| 44 | + | ||
| 45 | + ///问政留言 | ||
| 46 | + Ask = 16, | ||
| 47 | + | ||
| 48 | + /// 金刚位 | ||
| 49 | + KeyPosition = 30, | ||
| 50 | + | ||
| 51 | + /// 合集 | ||
| 52 | + Serials = 101, | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + | ||
| 56 | +} |
| @@ -39,6 +39,8 @@ export interface ShareContentLink { | @@ -39,6 +39,8 @@ export interface ShareContentLink { | ||
| 39 | desc?: string | 39 | desc?: string |
| 40 | link: string | 40 | link: string |
| 41 | icon?: string | 41 | icon?: string |
| 42 | + deeplink: string // 根据内容详情,生成的深度链接 如:rmrbapp://rmrb.app/openwith?type=article&subType=h5_template_article&contentId=30000762651&relId=500000038702&skipType=1&relType=1 | ||
| 43 | + | ||
| 42 | } | 44 | } |
| 43 | 45 | ||
| 44 | export type ShareContent = ShareContentText | ShareContentImageAndText | ShareContentLink | 46 | export type ShareContent = ShareContentText | ShareContentImageAndText | ShareContentLink |
| @@ -6,6 +6,9 @@ import { AsyncCallback } from '@kit.BasicServicesKit'; | @@ -6,6 +6,9 @@ import { AsyncCallback } from '@kit.BasicServicesKit'; | ||
| 6 | import { common } from '@kit.AbilityKit'; | 6 | import { common } from '@kit.AbilityKit'; |
| 7 | import { systemShare } from '@kit.ShareKit'; | 7 | import { systemShare } from '@kit.ShareKit'; |
| 8 | import { uniformTypeDescriptor as utd } from '@kit.ArkData'; | 8 | import { uniformTypeDescriptor as utd } from '@kit.ArkData'; |
| 9 | +import { JSON } from '@kit.ArkTS'; | ||
| 10 | + | ||
| 11 | +const TAG = "WDSystemShare" | ||
| 9 | 12 | ||
| 10 | export class WDSystemShare implements WDShareInterface { | 13 | export class WDSystemShare implements WDShareInterface { |
| 11 | 14 | ||
| @@ -14,7 +17,8 @@ export class WDSystemShare implements WDShareInterface { | @@ -14,7 +17,8 @@ export class WDSystemShare implements WDShareInterface { | ||
| 14 | return new Promise((resolve, fail) => { | 17 | return new Promise((resolve, fail) => { |
| 15 | try { | 18 | try { |
| 16 | 19 | ||
| 17 | - let controller: systemShare.ShareController = new systemShare.ShareController(this.getShareData(content, contentType)); | 20 | + let data = this.getShareData(content, contentType) |
| 21 | + let controller: systemShare.ShareController = new systemShare.ShareController(data); | ||
| 18 | let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext | 22 | let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext |
| 19 | 23 | ||
| 20 | controller.on('dismiss', () => { | 24 | controller.on('dismiss', () => { |
| @@ -53,7 +57,7 @@ export class WDSystemShare implements WDShareInterface { | @@ -53,7 +57,7 @@ export class WDSystemShare implements WDShareInterface { | ||
| 53 | }); | 57 | }); |
| 54 | data.addRecord({ | 58 | data.addRecord({ |
| 55 | utd: utd.UniformDataType.PNG, | 59 | utd: utd.UniformDataType.PNG, |
| 56 | - uri: imageAndText.imgURI | 60 | + uri: imageAndText.imgURI // 这里必须为本地连接 |
| 57 | }); | 61 | }); |
| 58 | return data | 62 | return data |
| 59 | } | 63 | } |
| @@ -64,6 +68,8 @@ export class WDSystemShare implements WDShareInterface { | @@ -64,6 +68,8 @@ export class WDSystemShare implements WDShareInterface { | ||
| 64 | utd: utd.UniformDataType.PLAIN_TEXT, | 68 | utd: utd.UniformDataType.PLAIN_TEXT, |
| 65 | content: link.title | 69 | content: link.title |
| 66 | }); | 70 | }); |
| 71 | + let shareLink = this.generateShareLink(link) | ||
| 72 | + console.log("分享 shareLink ==> " + shareLink) | ||
| 67 | data.addRecord({ | 73 | data.addRecord({ |
| 68 | utd: utd.UniformDataType.HYPERLINK, | 74 | utd: utd.UniformDataType.HYPERLINK, |
| 69 | // uri: link.link // SDK 设计 不能传这里 | 75 | // uri: link.link // SDK 设计 不能传这里 |
| @@ -72,5 +78,16 @@ export class WDSystemShare implements WDShareInterface { | @@ -72,5 +78,16 @@ export class WDSystemShare implements WDShareInterface { | ||
| 72 | return data | 78 | return data |
| 73 | } | 79 | } |
| 74 | 80 | ||
| 75 | - | 81 | + generateShareLink(shareContent: ShareContentLink) { |
| 82 | + let link = "https://peopledailychinahosactivity.drcn.agconnect.link/?deeplink=" + encodeURI(shareContent.deeplink) | ||
| 83 | + link += "&harmonyos_deeplink=" + encodeURI(shareContent.deeplink) | ||
| 84 | + link += "&harmonyos_package_name=com.peopledailychina.hosactivity" | ||
| 85 | + link += "&harmonyos_fallback_url=" + encodeURI(shareContent.link) | ||
| 86 | + link += "&landing_page_type=1" | ||
| 87 | + // link += "&social_desc=" + encodeURIComponent(shareContent.desc || " ") | ||
| 88 | + // link += "&social_image=" + encodeURI(shareContent.icon || " ") | ||
| 89 | + // link += "&social_title=" + encodeURIComponent(shareContent.title) | ||
| 90 | + link += "®ion_id=0" | ||
| 91 | + return link | ||
| 92 | + } | ||
| 76 | } | 93 | } |
| @@ -2,6 +2,7 @@ import { ContentDetailDTO, ContentDTO, PageInfoDTO, ShareInfoDTO, TopicInfo } fr | @@ -2,6 +2,7 @@ import { ContentDetailDTO, ContentDTO, PageInfoDTO, ShareInfoDTO, TopicInfo } fr | ||
| 2 | import { SharePosterItemBean } from 'wdBean/src/main/ets/bean/detail/SharePosterItemBean'; | 2 | import { SharePosterItemBean } from 'wdBean/src/main/ets/bean/detail/SharePosterItemBean'; |
| 3 | import { ShareScene, ShareType, WDShareBase } from 'wdShareBase/Index'; | 3 | import { ShareScene, ShareType, WDShareBase } from 'wdShareBase/Index'; |
| 4 | import { ShareContentType } from 'wdShareBase/src/main/ets/Constant'; | 4 | import { ShareContentType } from 'wdShareBase/src/main/ets/Constant'; |
| 5 | +import { DeepLinkUtil } from './utils/DeepLinkUtil'; | ||
| 5 | 6 | ||
| 6 | export class WDShare { | 7 | export class WDShare { |
| 7 | 8 | ||
| @@ -17,6 +18,7 @@ export class WDShare { | @@ -17,6 +18,7 @@ export class WDShare { | ||
| 17 | title: content.shareInfo.shareTitle, | 18 | title: content.shareInfo.shareTitle, |
| 18 | desc: content.shareInfo.shareSummary, | 19 | desc: content.shareInfo.shareSummary, |
| 19 | link: content.shareInfo.shareUrl, | 20 | link: content.shareInfo.shareUrl, |
| 21 | + deeplink:DeepLinkUtil.generateDeepLinkWithConent(content), | ||
| 20 | } | 22 | } |
| 21 | }) | 23 | }) |
| 22 | } | 24 | } |
| @@ -32,6 +34,7 @@ export class WDShare { | @@ -32,6 +34,7 @@ export class WDShare { | ||
| 32 | title: program.shareInfo.shareTitle, | 34 | title: program.shareInfo.shareTitle, |
| 33 | desc: program.shareInfo.shareSummary, | 35 | desc: program.shareInfo.shareSummary, |
| 34 | link: program.shareInfo.shareUrl, | 36 | link: program.shareInfo.shareUrl, |
| 37 | + deeplink:DeepLinkUtil.generateDeepLinkWithProgram(program), | ||
| 35 | } | 38 | } |
| 36 | }) | 39 | }) |
| 37 | } | 40 | } |
| 1 | +import { ContentDetailDTO, ContentDTO } from 'wdBean/Index'; | ||
| 2 | +import { BreakpointSystem } from 'wdKit/Index'; | ||
| 3 | +import { ContentType } from 'wdRouter/Index'; | ||
| 4 | + | ||
| 5 | +export class DeepLinkUtil { | ||
| 6 | + | ||
| 7 | + private static DEEP_LINK_PREFIX = "rmrbapp:rmrb.app/openwith" | ||
| 8 | + | ||
| 9 | + static generateDeepLinkWithConent(content: ContentDetailDTO): string { | ||
| 10 | + | ||
| 11 | + return DeepLinkUtil.generate(content.newsType, content.newsId +'', content.reLInfo?.relId, content.newsLinkUrl) | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + static generateDeepLinkWithProgram(content: ContentDTO) { | ||
| 15 | + | ||
| 16 | + return DeepLinkUtil.generate(Number(content.objectType), content.objectId +'', content.relId, content.linkUrl) | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + private static generate(contentType: number, contentId?: string, relId?: string, link?: string): string { | ||
| 20 | + let deeplink = DeepLinkUtil.DEEP_LINK_PREFIX | ||
| 21 | + | ||
| 22 | + let pubParam = `&contentId=${contentId}}&relId=${relId}&skipType=1` | ||
| 23 | + | ||
| 24 | + let type: ContentType = Number(contentType) | ||
| 25 | + switch (type) { | ||
| 26 | + case ContentType.Video: | ||
| 27 | + deeplink += "?type=video&subType=vod_video" | ||
| 28 | + break | ||
| 29 | + case ContentType.Live: | ||
| 30 | + deeplink += "?type=live" | ||
| 31 | + break | ||
| 32 | + case ContentType.ImageText: | ||
| 33 | + if (link && link.length) { | ||
| 34 | + deeplink += "?type=article&subType=h5" | ||
| 35 | + deeplink += "&url=" + encodeURIComponent(link) | ||
| 36 | + } else { | ||
| 37 | + deeplink += "type=article&subType=h5_template_article" | ||
| 38 | + } | ||
| 39 | + break | ||
| 40 | + case ContentType.DynamicImageText: | ||
| 41 | + deeplink += "?type=dynamic" | ||
| 42 | + break | ||
| 43 | + case ContentType.DynamicVideo: | ||
| 44 | + deeplink += "?type=dynamic" | ||
| 45 | + break | ||
| 46 | + case ContentType.Pictures: | ||
| 47 | + deeplink += "?type=picture" | ||
| 48 | + break | ||
| 49 | + case ContentType.Audio: | ||
| 50 | + deeplink += "?type=audio" | ||
| 51 | + break | ||
| 52 | + case ContentType.Ask: | ||
| 53 | + deeplink += "?type=ask" | ||
| 54 | + break | ||
| 55 | + default: | ||
| 56 | + pubParam = "" | ||
| 57 | + break; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + deeplink += pubParam | ||
| 61 | + return deeplink | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + | ||
| 65 | +} |
-
Please register or login to post a comment