Showing
6 changed files
with
47 additions
and
83 deletions
| @@ -44,7 +44,7 @@ export struct CardParser { | @@ -44,7 +44,7 @@ export struct CardParser { | ||
| 44 | } else if (contentDTO.appStyle === CompStyle.Card_04) { | 44 | } else if (contentDTO.appStyle === CompStyle.Card_04) { |
| 45 | Card4Component({ compDTO: this.compDTO, contentDTO }) | 45 | Card4Component({ compDTO: this.compDTO, contentDTO }) |
| 46 | } else if (contentDTO.appStyle === CompStyle.Card_05) { | 46 | } else if (contentDTO.appStyle === CompStyle.Card_05) { |
| 47 | - Card5Component({ contentDTO, titleShowPolicy: this.compDTO.titleShowPolicy }) | 47 | + Card5Component({ contentDTO, titleShowPolicy: this.compDTO.titleShowPolicy, compDTO: this.compDTO }) |
| 48 | } else if (contentDTO.appStyle === CompStyle.Card_06 || contentDTO.appStyle === CompStyle | 48 | } else if (contentDTO.appStyle === CompStyle.Card_06 || contentDTO.appStyle === CompStyle |
| 49 | .Card_13) { | 49 | .Card_13) { |
| 50 | Card6Component({ compDTO: this.compDTO, contentDTO: this.contentDTO }) | 50 | Card6Component({ compDTO: this.compDTO, contentDTO: this.contentDTO }) |
| @@ -20,7 +20,7 @@ export struct SpacialTopicPageComponent { | @@ -20,7 +20,7 @@ export struct SpacialTopicPageComponent { | ||
| 20 | action: Action = {} as Action | 20 | action: Action = {} as Action |
| 21 | @State webUrl: string = ''; | 21 | @State webUrl: string = ''; |
| 22 | @State isPageEnd: boolean = false | 22 | @State isPageEnd: boolean = false |
| 23 | - @State reload: number = 0; | 23 | + @Prop reload: number = 0; |
| 24 | @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO | 24 | @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO |
| 25 | private h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean | 25 | private h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean |
| 26 | private webPrepared = false; | 26 | private webPrepared = false; |
| @@ -134,13 +134,6 @@ export struct SpacialTopicPageComponent { | @@ -134,13 +134,6 @@ export struct SpacialTopicPageComponent { | ||
| 134 | }.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT) | 134 | }.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT) |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | - onPageShow() { | ||
| 138 | - if (!this.action?.params?.backVisibility) { | ||
| 139 | - WindowModel.shared.setWindowLayoutFullScreen(true) | ||
| 140 | - } | ||
| 141 | - this.reload++ | ||
| 142 | - } | ||
| 143 | - | ||
| 144 | aboutToAppear() { | 137 | aboutToAppear() { |
| 145 | if (!this.action?.params?.backVisibility) { | 138 | if (!this.action?.params?.backVisibility) { |
| 146 | WindowModel.shared.setWindowLayoutFullScreen(true) | 139 | WindowModel.shared.setWindowLayoutFullScreen(true) |
| @@ -149,12 +142,6 @@ export struct SpacialTopicPageComponent { | @@ -149,12 +142,6 @@ export struct SpacialTopicPageComponent { | ||
| 149 | this.getDetail() | 142 | this.getDetail() |
| 150 | } | 143 | } |
| 151 | 144 | ||
| 152 | - onPageHide() { | ||
| 153 | - if (!this.action?.params?.backVisibility) { | ||
| 154 | - WindowModel.shared.setWindowLayoutFullScreen(false) | ||
| 155 | - } | ||
| 156 | - } | ||
| 157 | - | ||
| 158 | aboutToDisappear() { | 145 | aboutToDisappear() { |
| 159 | if (!this.action?.params?.backVisibility) { | 146 | if (!this.action?.params?.backVisibility) { |
| 160 | WindowModel.shared.setWindowLayoutFullScreen(false) | 147 | WindowModel.shared.setWindowLayoutFullScreen(false) |
| @@ -7,8 +7,6 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; | @@ -7,8 +7,6 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; | ||
| 7 | import { Notes } from './notes'; | 7 | import { Notes } from './notes'; |
| 8 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | 8 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; |
| 9 | // import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; | 9 | // import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; |
| 10 | -import { viewBlogInsightIntentShare, ActionMode } from '../../utils/InsightIntentShare' | ||
| 11 | -import { common } from '@kit.AbilityKit'; | ||
| 12 | const TAG: string = 'Card2Component'; | 10 | const TAG: string = 'Card2Component'; |
| 13 | 11 | ||
| 14 | /** | 12 | /** |
| @@ -111,11 +109,6 @@ export struct Card2Component { | @@ -111,11 +109,6 @@ export struct Card2Component { | ||
| 111 | this.clicked = true; | 109 | this.clicked = true; |
| 112 | // persistentStorage(this.contentDTO.objectId); | 110 | // persistentStorage(this.contentDTO.objectId); |
| 113 | ProcessUtils.processPage(this.contentDTO) | 111 | ProcessUtils.processPage(this.contentDTO) |
| 114 | - | ||
| 115 | - if (this.contentDTO?.channelId === '2001' || this.contentDTO?.channelId === '2002') { | ||
| 116 | - let context = getContext(this) as common.UIAbilityContext; | ||
| 117 | - viewBlogInsightIntentShare(context, this.contentDTO?.channelId, [this.compDTO], ActionMode.EXECUTED) | ||
| 118 | - } | ||
| 119 | }) | 112 | }) |
| 120 | } | 113 | } |
| 121 | } | 114 | } |
| 1 | -import { ContentDTO } from 'wdBean'; | 1 | +import { ContentDTO, CompDTO } from 'wdBean'; |
| 2 | import { CommonConstants } from 'wdConstant'; | 2 | import { CommonConstants } from 'wdConstant'; |
| 3 | import { ProcessUtils } from 'wdRouter'; | 3 | import { ProcessUtils } from 'wdRouter'; |
| 4 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | 4 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; |
| 5 | import { Notes } from './notes'; | 5 | import { Notes } from './notes'; |
| 6 | +import { viewBlogInsightIntentShare, ActionMode } from '../../utils/InsightIntentShare' | ||
| 7 | +import { common } from '@kit.AbilityKit'; | ||
| 6 | 8 | ||
| 7 | const TAG: string = 'Card5Component'; | 9 | const TAG: string = 'Card5Component'; |
| 8 | 10 | ||
| @@ -13,6 +15,7 @@ const TAG: string = 'Card5Component'; | @@ -13,6 +15,7 @@ const TAG: string = 'Card5Component'; | ||
| 13 | export struct Card5Component { | 15 | export struct Card5Component { |
| 14 | @State contentDTO: ContentDTO = new ContentDTO(); | 16 | @State contentDTO: ContentDTO = new ContentDTO(); |
| 15 | @Prop titleShowPolicy: number | string | 17 | @Prop titleShowPolicy: number | string |
| 18 | + @Prop compDTO: CompDTO = {} as CompDTO | ||
| 16 | @State loadImg: boolean = false; | 19 | @State loadImg: boolean = false; |
| 17 | @State clicked: boolean = false; | 20 | @State clicked: boolean = false; |
| 18 | @State titleMarked: boolean = false; | 21 | @State titleMarked: boolean = false; |
| @@ -97,6 +100,8 @@ export struct Card5Component { | @@ -97,6 +100,8 @@ export struct Card5Component { | ||
| 97 | .onClick((event: ClickEvent) => { | 100 | .onClick((event: ClickEvent) => { |
| 98 | this.clicked = true; | 101 | this.clicked = true; |
| 99 | ProcessUtils.processPage(this.contentDTO) | 102 | ProcessUtils.processPage(this.contentDTO) |
| 103 | + let context = getContext(this) as common.UIAbilityContext; | ||
| 104 | + viewBlogInsightIntentShare(context, this.contentDTO?.channelId, [this.compDTO], ActionMode.EXECUTED) | ||
| 100 | }) | 105 | }) |
| 101 | 106 | ||
| 102 | } | 107 | } |
| 1 | import { common } from '@kit.AbilityKit'; | 1 | import { common } from '@kit.AbilityKit'; |
| 2 | import { insightIntent } from '@kit.IntentsKit'; | 2 | import { insightIntent } from '@kit.IntentsKit'; |
| 3 | +import { BusinessError } from '@kit.BasicServicesKit'; | ||
| 3 | import { CompDTO, CompList, ContentDTO, PageInfoBean } from 'wdBean'; | 4 | import { CompDTO, CompList, ContentDTO, PageInfoBean } from 'wdBean'; |
| 4 | 5 | ||
| 5 | -function generateUniqueId() { | ||
| 6 | - // 生成当前时间戳 | ||
| 7 | - let timestamp = new Date().getTime(); | ||
| 8 | - | ||
| 9 | - // 将时间戳转换成16进制字符串 | ||
| 10 | - let hexString = timestamp.toString(16); | ||
| 11 | - | ||
| 12 | - // 确保字符串长度为16位,不足的话在前面补0 | ||
| 13 | - while (hexString.length < 16) { | ||
| 14 | - hexString = '0' + hexString; | ||
| 15 | - } | ||
| 16 | - | ||
| 17 | - // 格式化为UUID样式 | ||
| 18 | - let uuid = hexString.substring(0, 8) + '-' + | ||
| 19 | - hexString.substring(8, 12) + '-' + | ||
| 20 | - hexString.substring(12, 16) + '-' + | ||
| 21 | - hexString.substring(16, 20) + '-' + | ||
| 22 | - hexString.substring(20); | ||
| 23 | - | 6 | +function generateUUID() { |
| 7 | + let dt = new Date().getTime(); // 获取当前时间的时间戳(毫秒) | ||
| 8 | + let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { | ||
| 9 | + let r = (dt + Math.random() * 16) % 16 | 0; | ||
| 10 | + dt = Math.floor(dt / 16); | ||
| 11 | + return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); | ||
| 12 | + }); | ||
| 24 | return uuid; | 13 | return uuid; |
| 25 | } | 14 | } |
| 26 | 15 | ||
| @@ -34,15 +23,16 @@ export const enum ActionMode { | @@ -34,15 +23,16 @@ export const enum ActionMode { | ||
| 34 | //ViewBlog意图共享-频道列表 | 23 | //ViewBlog意图共享-频道列表 |
| 35 | export function viewBlogInsightIntentShare(context: common.UIAbilityContext, entityGroupId: string, | 24 | export function viewBlogInsightIntentShare(context: common.UIAbilityContext, entityGroupId: string, |
| 36 | compList: CompDTO[] | CompList[], actionMode: ActionMode) { | 25 | compList: CompDTO[] | CompList[], actionMode: ActionMode) { |
| 37 | - console.log('viewBlogInsightIntentShare',actionMode) | 26 | + console.log('viewBlogInsightIntentShare', actionMode) |
| 38 | let insightIntentArray: insightIntent.InsightIntent [] = [] | 27 | let insightIntentArray: insightIntent.InsightIntent [] = [] |
| 28 | + let identifier = generateUUID() | ||
| 39 | if (compList?.length > 0) { | 29 | if (compList?.length > 0) { |
| 40 | compList?.forEach((item: CompDTO | CompList) => { | 30 | compList?.forEach((item: CompDTO | CompList) => { |
| 41 | item.operDataList.forEach((_item: ContentDTO) => { | 31 | item.operDataList.forEach((_item: ContentDTO) => { |
| 42 | let viewBlogInsightIntentItem: insightIntent.InsightIntent = { | 32 | let viewBlogInsightIntentItem: insightIntent.InsightIntent = { |
| 43 | intentName: 'ViewBlog', | 33 | intentName: 'ViewBlog', |
| 44 | intentVersion: '1.0.1', | 34 | intentVersion: '1.0.1', |
| 45 | - identifier: generateUniqueId(), | 35 | + identifier, |
| 46 | intentActionInfo: { | 36 | intentActionInfo: { |
| 47 | actionMode, | 37 | actionMode, |
| 48 | currentPercentage: 50, | 38 | currentPercentage: 50, |
| @@ -67,7 +57,7 @@ export function viewBlogInsightIntentShare(context: common.UIAbilityContext, ent | @@ -67,7 +57,7 @@ export function viewBlogInsightIntentShare(context: common.UIAbilityContext, ent | ||
| 67 | _item?.newsSummary.substring(0, 20) : _item?.newsSummary, | 57 | _item?.newsSummary.substring(0, 20) : _item?.newsSummary, |
| 68 | blogAuthor: _item?.source, | 58 | blogAuthor: _item?.source, |
| 69 | blogPublishTime: _item?.publishTimestamp, | 59 | blogPublishTime: _item?.publishTimestamp, |
| 70 | - tag: _item?.newTags, | 60 | + tag: _item?.newTags.split(','), |
| 71 | likeCount: _item?.interactData?.likeNum || 0, | 61 | likeCount: _item?.interactData?.likeNum || 0, |
| 72 | forwardCount: _item?.interactData?.shareNum || 0, | 62 | forwardCount: _item?.interactData?.shareNum || 0, |
| 73 | commentCount: _item?.interactData?.commentNum || 0, | 63 | commentCount: _item?.interactData?.commentNum || 0, |
| @@ -82,21 +72,13 @@ export function viewBlogInsightIntentShare(context: common.UIAbilityContext, ent | @@ -82,21 +72,13 @@ export function viewBlogInsightIntentShare(context: common.UIAbilityContext, ent | ||
| 82 | 72 | ||
| 83 | }) | 73 | }) |
| 84 | console.log('yzl', JSON.stringify(insightIntentArray[0])) | 74 | console.log('yzl', JSON.stringify(insightIntentArray[0])) |
| 85 | - try { | ||
| 86 | - // 共享数据 | ||
| 87 | - insightIntent.shareIntent(context, insightIntentArray, (error) => { | ||
| 88 | - if (error?.code) { | ||
| 89 | - // 处理业务逻辑错误 | ||
| 90 | - console.error(`shareIntent failed, error.code: ${error?.code}, error.message: ${error?.message}`); | ||
| 91 | - return; | ||
| 92 | - } | ||
| 93 | - // 执行正常业务 | ||
| 94 | - console.log('shareIntent succeed'); | ||
| 95 | - }); | ||
| 96 | - } catch (error) { | ||
| 97 | - // 处理异常 | ||
| 98 | - console.error(`error.code: ${error?.code}, error.message: ${error?.message}`); | ||
| 99 | - } | 75 | + // 共享数据 |
| 76 | + insightIntent.shareIntent(context, insightIntentArray).then(() => { | ||
| 77 | + console.log('yzl shareIntent success'); | ||
| 78 | + }).catch((err: BusinessError) => { | ||
| 79 | + console.error(`yzl failed because ${err?.message}`); | ||
| 80 | + }); | ||
| 81 | + | ||
| 100 | } | 82 | } |
| 101 | } | 83 | } |
| 102 | 84 | ||
| @@ -108,7 +90,7 @@ export function viewColumInsightIntentShare(context: common.UIAbilityContext, en | @@ -108,7 +90,7 @@ export function viewColumInsightIntentShare(context: common.UIAbilityContext, en | ||
| 108 | let viewBlogInsightIntentItem: insightIntent.InsightIntent = { | 90 | let viewBlogInsightIntentItem: insightIntent.InsightIntent = { |
| 109 | intentName: 'ViewColumn', | 91 | intentName: 'ViewColumn', |
| 110 | intentVersion: '1.0.1', | 92 | intentVersion: '1.0.1', |
| 111 | - identifier: generateUniqueId(), | 93 | + identifier: generateUUID(), |
| 112 | intentActionInfo: { | 94 | intentActionInfo: { |
| 113 | actionMode: ActionMode.EXECUTED, | 95 | actionMode: ActionMode.EXECUTED, |
| 114 | currentPercentage: 50, | 96 | currentPercentage: 50, |
| @@ -116,30 +98,22 @@ export function viewColumInsightIntentShare(context: common.UIAbilityContext, en | @@ -116,30 +98,22 @@ export function viewColumInsightIntentShare(context: common.UIAbilityContext, en | ||
| 116 | intentEntityInfo: { | 98 | intentEntityInfo: { |
| 117 | entityName: 'Column', | 99 | entityName: 'Column', |
| 118 | entityId, | 100 | entityId, |
| 119 | - displayName:pageInfoBean?.topicInfo?.title, | 101 | + displayName: pageInfoBean?.topicInfo?.title, |
| 120 | description: pageInfoBean?.shareSummary, | 102 | description: pageInfoBean?.shareSummary, |
| 121 | - logoURL:pageInfoBean?.shareCoverUrl, | ||
| 122 | - activityType:['RecentViews'], | 103 | + logoURL: pageInfoBean?.shareCoverUrl, |
| 104 | + activityType: ['RecentViews'], | ||
| 123 | columnTitle: pageInfoBean?.topicInfo?.title, | 105 | columnTitle: pageInfoBean?.topicInfo?.title, |
| 124 | columnSubTitle: pageInfoBean?.shareSummary, | 106 | columnSubTitle: pageInfoBean?.shareSummary, |
| 125 | rankingHint: 99, | 107 | rankingHint: 99, |
| 126 | isPublicData: true | 108 | isPublicData: true |
| 127 | } | 109 | } |
| 128 | } | 110 | } |
| 111 | + console.log('yzl viewColumInsightIntentShare', JSON.stringify(viewBlogInsightIntentItem)) | ||
| 129 | 112 | ||
| 130 | - try { | ||
| 131 | - // 共享数据 | ||
| 132 | - insightIntent.shareIntent(context, [viewBlogInsightIntentItem], (error) => { | ||
| 133 | - if (error?.code) { | ||
| 134 | - // 处理业务逻辑错误 | ||
| 135 | - console.error(`shareIntent failed, error.code: ${error?.code}, error.message: ${error?.message}`); | ||
| 136 | - return; | ||
| 137 | - } | ||
| 138 | - // 执行正常业务 | ||
| 139 | - console.log('shareIntent succeed'); | ||
| 140 | - }); | ||
| 141 | - } catch (error) { | ||
| 142 | - // 处理异常 | ||
| 143 | - console.error(`error.code: ${error?.code}, error.message: ${error?.message}`); | ||
| 144 | - } | 113 | + // 共享数据 |
| 114 | + insightIntent.shareIntent(context, [viewBlogInsightIntentItem]).then(() => { | ||
| 115 | + console.log('yzl shareIntent success'); | ||
| 116 | + }).catch((err: BusinessError) => { | ||
| 117 | + console.error(`yzl failed because ${err?.message}`); | ||
| 118 | + }); | ||
| 145 | } | 119 | } |
| @@ -9,11 +9,12 @@ const TAG = 'SpacialTopicPage'; | @@ -9,11 +9,12 @@ const TAG = 'SpacialTopicPage'; | ||
| 9 | @Entry | 9 | @Entry |
| 10 | @Component | 10 | @Component |
| 11 | struct SpacialTopicPage { | 11 | struct SpacialTopicPage { |
| 12 | - action: Action = {} as Action | ||
| 13 | - | 12 | + @State action: Action = {} as Action |
| 13 | + @State reload: number = 0 | ||
| 14 | + @State count: number = 0 | ||
| 14 | build() { | 15 | build() { |
| 15 | Column() { | 16 | Column() { |
| 16 | - SpacialTopicPageComponent({ action: this.action }) | 17 | + SpacialTopicPageComponent({ action: this.action ,reload:this.reload }) |
| 17 | }.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT) | 18 | }.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT) |
| 18 | } | 19 | } |
| 19 | 20 | ||
| @@ -30,8 +31,12 @@ struct SpacialTopicPage { | @@ -30,8 +31,12 @@ struct SpacialTopicPage { | ||
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | aboutToAppear() { | 33 | aboutToAppear() { |
| 33 | - Logger.info(TAG, 'aboutToAppear'); | 34 | + Logger.info(TAG, `aboutToAppearcount:${this.reload}`); |
| 34 | let action: Action = router.getParams() as Action | 35 | let action: Action = router.getParams() as Action |
| 35 | this.action = action | 36 | this.action = action |
| 36 | } | 37 | } |
| 38 | + onPageShow() { | ||
| 39 | + this.reload = this.reload + 1 | ||
| 40 | + Logger.info(TAG, `onPageShowcount:${this.reload}`); | ||
| 41 | + } | ||
| 37 | } | 42 | } |
-
Please register or login to post a comment