王士厅
... ... @@ -24,7 +24,7 @@ interface dataObject {
// 9、活动投稿 视频跳转
// 10、活动投稿 动态跳转
// 11、活动投稿 图集跳转
dataSource: string
dataSource: WDH5WebDataSource
operateType?: string
webViewHeight?: string
dataJson?: string
... ... @@ -68,4 +68,21 @@ export class Message {
toList(jsonStr: string): Array<Message> {
return JSON.parse(jsonStr)
}
}
export enum WDH5WebDataSource {
WDH5WebDataSourceUnknown = 0,
WDH5WebDataSourceImageTextDetail = 1,
WDH5WebDataSourceContentInfo = 2,
WDH5WebDataSourcePictures = 3,
WDH5WebDataSourceTopicPageInfo = 4,
WDH5WebDataSourceCompPositionData = 5,
WDH5WebDataSourceArticleRefDataJump = 6,
WDH5WebDataSourceSharePosterListDatas = 7,
WDH5WebDataSourcePartinActivityPublishArticle = 8,
WDH5WebDataSourcePartinActivityPublishVideo = 9,
WDH5WebDataSourcePartinActivityPublishDynamic = 10,
WDH5WebDataSourcePartinActivityPublishPicture = 11,
}
\ No newline at end of file
... ...
... ... @@ -5,7 +5,8 @@ import { setDefaultNativeWebSettings } from './WebComponentUtil';
import { Action } from 'wdBean';
import { performJSCallNative } from './JsBridgeBiz';
import { H5CallNativeType } from './H5CallNativeType';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
import { Message,WDH5WebDataSource } from 'wdJsBridge/src/main/ets/bean/Message';
import { JSON } from '@kit.ArkTS';
const TAG = 'WdWebComponent';
... ... @@ -14,6 +15,9 @@ export struct WdWebComponent {
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
onWebPrepared: () => void = () => {
}
receiveH5SendToNativeData: (dataString:string | undefined) => void = () =>{
}
@Prop webUrl: string = ''
@Prop @Watch('onReloadStateChanged') reload: number = 0
@Link isPageEnd: boolean
... ... @@ -61,15 +65,25 @@ export struct WdWebComponent {
* 默认【CallNative】逻辑处理
*/
private defaultPerformJSCallNative: (data: Message, f: Callback) => void = (data: Message, f: Callback) => {
// H5内部跳转逻辑(前端调用原生的js方法处理)
performJSCallNative(data, f)
}
/**
* 获取前端返回的数据
*/
private defaultGetReceiveSubjectData: (data: Message, f: Callback) => void = (data: Message, f: Callback) => {
if(data.handlerName === H5CallNativeType.jsCall_receiveSubjectData) {
f('')
return
}
if (data.handlerName === H5CallNativeType.jsCall_receiveH5Data) {
if (data.data?.dataSource === WDH5WebDataSource.WDH5WebDataSourceTopicPageInfo) {
this.receiveH5SendToNativeData(data.data?.dataJson)
return
}
}
}
onPageBegin: (url?: string) => void = () => {
Logger.debug(TAG, 'onPageBegin');
... ...
... ... @@ -175,6 +175,7 @@ export { MasterDetailRes } from './src/main/ets/bean/user/MasterDetailRes';
export { ReserveItemBean } from './src/main/ets/bean/live/ReserveItemBean';
export { PageTrackBean } from './src/main/ets/bean/component/PageTrackBean';
export { TopicDetailData,GroupItem } from './src/main/ets/bean/content/TopicDetailData'
export { FeedbackTypeBean } from './src/main/ets/bean/detail/FeedbackTypeBean';
... ...
import { TopicInfo } from '../morningevening/TopicInfo';
import { ArrayList } from '@kit.ArkTS';
export interface GroupItem {
id: number;
blockDesc: string;
groupStrategy: number;
itemNum: number;
showType: number;
sortValue: number;
}
export interface TopicDetailData {
backIconUrl: string;
shareSummary: string;
id: number;
baselineCopywriting: string;
cornersAdv: string;
backgroundImgUrl: string;
description: string;
imgSize: string;
pageTopType: number;
pushupLogoImgUrl: string;
backgroundColor: string;
shareCoverUrl: string;
shareName: string;
mainLogoImgUrl: string;
titleColor: string;
baselineShow: number;
pageType: number;
shareIconUrl: string;
shareUrl: string;
name: string;
hasAdInfo: number;
hasPopUp: number;
statusBarColor: string;
templateType: number;
topicInfo: TopicInfo;
baselineColor: string;
groups: ArrayList<GroupItem>;
}
\ No newline at end of file
... ...
import { Action, H5ReceiveDetailBean, ContentDetailDTO, InteractDataDTO, TopicInfo } from 'wdBean';
import { Action, H5ReceiveDetailBean, ContentDetailDTO, InteractDataDTO, TopicInfo,TopicDetailData,ShareInfoDTO } from 'wdBean';
import { WdWebComponent } from 'wdWebComponent';
import { CommonConstants } from 'wdConstant'
import { BridgeWebViewControl } from 'wdJsBridge/Index';
... ... @@ -7,7 +7,7 @@ import { OperRowListView } from './view/OperRowListView';
import DetailViewModel from '../viewmodel/DetailViewModel';
import { publishCommentModel } from '../components/comment/model/PublishCommentModel';
import { EmptyComponent } from '../components/view/EmptyComponent';
import { NetworkUtil, WindowModel } from 'wdKit';
import { NetworkUtil, WindowModel,Logger } from 'wdKit';
import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare'
import { common } from '@kit.AbilityKit';
import { PageRepository } from '../repository/PageRepository';
... ... @@ -34,7 +34,7 @@ export struct SpacialTopicPageComponent {
@Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
private h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean
private webPrepared = false;
private dataPrepared = false;
// private dataPrepared = false;
@State publishCommentModel: publishCommentModel = new publishCommentModel()
@State operationButtonList: string[] = ['comment', 'collect', 'share']
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
... ... @@ -42,9 +42,12 @@ export struct SpacialTopicPageComponent {
@Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@State showComment: boolean = false
@State topicInfo: TopicInfo = {} as TopicInfo
@State topicDetail: TopicDetailData = {} as TopicDetailData
@State shareInfo: ShareInfoDTO = {} as ShareInfoDTO
@State showBottomView: boolean = false;
private trySendData2H5() {
if (!this.webPrepared || !this.dataPrepared) {
if (!this.webPrepared) {
return
}
// 数据、web组件,都准备好了,开始塞详情数据
... ... @@ -57,133 +60,93 @@ export struct SpacialTopicPageComponent {
}
private sendContentData2H5(h5ReceiveAppData: H5ReceiveDetailBean) {
Logger.debug('SpacialTopicPageComponent', 'jsCall_receiveAppData',JSON.stringify(h5ReceiveAppData));
this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData,
JSON.stringify(h5ReceiveAppData), (data: string) => {
Logger.debug('SpacialTopicPageComponent', "from js data = " + data);
})
}
//意图上报
private viewBlogInsightIntentShare(){
let context = getContext(this) as common.UIAbilityContext;
viewBlogItemInsightIntentShare(context,this.contentDetailData)
}
async getWebviewPageData (){
let pageId = this.action.params?.extra?.pageId
let relId: string = ''
let relType: string = ''
let contentId: string = ''
if (this.action && this.action.params) {
if (this.action.params.contentID) {
contentId = this.action.params.contentID;
}
if (this.action && this.action.params && this.action.params.extra) {
if (this.action.params.extra.relId) {
relId = this.action.params.extra.relId;
}
if (this.action.params.extra.relType) {
relType = this.action.params.extra.relType
}
}
}
if(pageId){
// let pageInfoMsg = await PageRepository.fetchMorningEveningPageInfo(pageId)
// let pageCompInfoMsg = await PageRepository.fetchMorningEveningCompInfo(Number(pageId), groupId, refreshTime, topicId, 1, 20)
// let res = {
// dataJson: {
// pageInfoResponseMap: pageInfoMsg,
// compInfoResponseMap: pageCompInfoMsg,
// },
// }
private receiveH5SendToNativeData(dataString:string | undefined) {
// this.topicDetail = JSON.parse(dataString);
if (dataString == undefined) {
return
}
}
Logger.debug('SpacialTopicPageComponent111',dataString);
this.topicDetail = JSON.parse(dataString);
this.topicInfo = this.topicDetail.topicInfo;
private async getDetail() {
this.isNetConnected = NetworkUtil.isNetConnected()
let contentId: string = ''
let relId: string = ''
let relType: string = ''
if (this.action && this.action.params) {
if (this.action.params.contentID) {
contentId = this.action.params.contentID;
}
if (this.action && this.action.params && this.action.params.extra) {
if (this.action.params.extra.relId) {
relId = this.action.params.extra.relId;
}
if (this.action.params.extra.relType) {
relType = this.action.params.extra.relType
if(this.topicInfo){
// 转换详情数据
this.contentDetailData.openComment = Number(this.topicInfo.commentFlag)
this.contentDetailData.commentDisplay = Number(this.topicInfo.commentShowFlag)
this.contentDetailData.newsId = Number(this.topicInfo.topicId)
this.contentDetailData.newsType = this.topicInfo.topicType
this.contentDetailData.newsTitle = this.topicInfo.title;
this.contentDetailData.newsType = this.topicInfo.topicType;
this.contentDetailData.visitorComment = this.topicInfo.visitorComment;
//转换分享数据
this.shareInfo.shareCoverUrl = this.topicInfo.shareCoverUrl
this.shareInfo.shareOpen = this.topicInfo.shareOpen
this.shareInfo.sharePosterCoverUrl = this.topicInfo.sharePosterCoverUrl
this.shareInfo.shareSummary = this.topicInfo.shareSummary
this.shareInfo.shareTitle = this.topicInfo.shareTitle
this.shareInfo.shareUrl = this.topicInfo.shareUrl
this.contentDetailData.shareInfo = this.shareInfo
console.log('contentDetailData111', JSON.stringify(this.contentDetailData))
if(this.topicInfo.shareOpen === 1){
if (!this.operationButtonList.includes('share')) {
this.operationButtonList.push('share');
}
} else {
this.operationButtonList = this.operationButtonList.filter(e =>e !== 'share')
}
let pageId = this.action.params.extra?.pageId
console.log('pageIdpageId',pageId)
if(pageId){
let pageInfoMsg = await PageRepository.fetchMorningEveningPageInfo(pageId,contentId)
let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType)
if (detailBeans?.length > 0) {
this.contentDetailData = JSON.parse(JSON.stringify(detailBeans[0]));
this.viewBlogInsightIntentShare()
// if (this.contentDetailData[0]?.openComment) {
this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId || '')
this.publishCommentModel.targetTitle = this.contentDetailData?.newsTitle
this.publishCommentModel.targetRelType = String(this.contentDetailData?.reLInfo?.relType || '')
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId || '')
this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle || '')
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType || '')
this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment || '')
// }
this.subjectData = 'dasdasdadas'
//TODO
// this.trySendData2H5()
}
if(pageInfoMsg && pageInfoMsg.data){
this.contentDetailData.openComment = Number(pageInfoMsg.data.topicInfo?.commentFlag)
this.contentDetailData.commentDisplay = Number(pageInfoMsg.data.topicInfo?.commentShowFlag)
console.log('contentDetailData pageInfoMsg.data', JSON.stringify(pageInfoMsg.data))
this.topicInfo = pageInfoMsg.data.topicInfo
this.contentDetailData.newsId = Number(this.topicInfo.topicId)
this.contentDetailData.newsType = this.topicInfo.topicType
if(this.topicInfo?.shareOpen === 1){
this.contentDetailData.shareInfo.shareOpen = this.topicInfo?.shareOpen
console.log('contentDetailData this.topicInfo', JSON.stringify(this.topicInfo))
if (!this.operationButtonList.includes('share')) {
this.operationButtonList.push('share');
}
} else {
this.operationButtonList = this.operationButtonList.filter(e =>e !== 'share')
}
}
console.log('contentDetailData', JSON.stringify(this.contentDetailData))
}
// 转换评论数据
this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId || '')
this.publishCommentModel.targetTitle = this.contentDetailData?.newsTitle
this.publishCommentModel.targetRelType = String(this.contentDetailData?.reLInfo?.relType || '')
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId || '')
this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle || '')
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType || '')
this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment || '')
this.showBottomView = true
}
// this.viewBlogInsightIntentShare();
}
//意图上报
private viewBlogInsightIntentShare(){
let context = getContext(this) as common.UIAbilityContext;
viewBlogItemInsightIntentShare(context,this.contentDetailData)
}
build() {
Column() {
Stack({ alignContent: Alignment.Bottom }) {
Column() {
Text(this.contentDetailData?.newsTitle)
.backgroundColor(Color.White)
.width('100%')
.height(40)
.fontSize(18)
.textAlign(TextAlign.Center)
.fontWeight(500)
.visibility(this.action?.params?.backVisibility && this.isPageEnd ? Visibility.Visible : Visibility.None)
if(this.subjectData.length > 0){
WdWebComponent({
webviewControl: this.webviewControl,
webUrl: this.webUrl,
reload: this.reload,
onWebPrepared: this.onWebPrepared.bind(this),
isPageEnd: $isPageEnd,
subjectData: this.subjectData
})
}
// Text(this.contentDetailData?.newsTitle)
// .backgroundColor(Color.White)
// .width('100%')
// .height(40)
// .fontSize(18)
// .textAlign(TextAlign.Center)
// .fontWeight(500)
// .visibility(this.action?.params?.backVisibility && this.isPageEnd ? Visibility.Visible : Visibility.None)
WdWebComponent({
webviewControl: this.webviewControl,
webUrl: this.webUrl,
reload: this.reload,
onWebPrepared: this.onWebPrepared.bind(this),
isPageEnd: $isPageEnd,
receiveH5SendToNativeData: this.receiveH5SendToNativeData.bind(this)
})
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
... ... @@ -194,7 +157,8 @@ export struct SpacialTopicPageComponent {
emptyType: 1,
emptyButton: true,
retry: () => {
this.getDetail()
// this.getDetail()
this.reload ++
}
}).padding({ bottom: 200 })
} else {
... ... @@ -203,24 +167,26 @@ export struct SpacialTopicPageComponent {
}
}
//底部交互区
OperRowListView({
contentDetailData: this.contentDetailData,
publishCommentModel: this.publishCommentModel,
operationButtonList: this.operationButtonList,
topicInfo: this.topicInfo,
styleType: 1,
onCommentIconClick:()=>{
this.showCommentList = true
}
})
//全部评论
CommentDialogView({
index: $index,
currentIndex: $currentIndex,
showCommentList: $showCommentList,
publishCommentModel: $publishCommentModel,
interactData: $interactData,
}).visibility(this.showComment?Visibility.Visible:Visibility.Hidden)
if (this.showBottomView){
OperRowListView({
contentDetailData: this.contentDetailData,
publishCommentModel: this.publishCommentModel,
operationButtonList: this.operationButtonList,
topicInfo: this.topicInfo,
styleType: 1,
onCommentIconClick:()=>{
this.showCommentList = true
}
})
//全部评论
CommentDialogView({
index: $index,
currentIndex: $currentIndex,
showCommentList: $showCommentList,
publishCommentModel: $publishCommentModel,
interactData: $interactData,
}).visibility(this.showComment?Visibility.Visible:Visibility.Hidden)
}
}
}.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT)
}
... ... @@ -230,7 +196,8 @@ export struct SpacialTopicPageComponent {
// WindowModel.shared.setWindowLayoutFullScreen(true)
}
this.webUrl = this.action?.params?.url || ''
this.getDetail()
this.isNetConnected = NetworkUtil.isNetConnected()
// this.getDetail()
}
aboutToDisappear() {
... ...
... ... @@ -312,7 +312,7 @@ export class PageRepository {
// 批量查询内容当前用户点赞、收藏状态
static fetchInteractDataStatus(param: object) {
let url = PageRepository.getInteractDataStatusUrl()
return WDHttp.post<ResponseDTO<batchLikeAndCollectResult[]>>(url, param)
return HttpBizUtil.post<ResponseDTO<batchLikeAndCollectResult[]>>(url, param)
};
/**
... ...