Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
chengen02
2024-05-31 18:04:03 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9354241bf615b90404d301f7afdc7613edde3177
9354241b
1 parent
cddfe21b
-fix bug修复
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
8 deletions
sight_harmony/commons/wdWebComponent/src/main/ets/pages/H5CallNativeType.ets
sight_harmony/commons/wdWebComponent/src/main/ets/pages/WdWebComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/SpacialTopicPageComponent.ets
sight_harmony/products/phone/src/main/ets/pages/SpacialTopicPage.ets
sight_harmony/commons/wdWebComponent/src/main/ets/pages/H5CallNativeType.ets
View file @
9354241
...
...
@@ -12,6 +12,7 @@ export class H5CallNativeType {
static jsCall_receiveH5Data = 'jsCall_receiveH5Data'
static jsCall_getAppLoginAuthInfo = 'jsCall_getAppLoginAuthInfo'
static jsCall_appNotifyEvent = 'jsCall_appNotifyEvent'
static jsCall_receiveSubjectData = 'jsCall_receiveSubjectData'
// TODO 业务自行新增类型、自行在JsBridgeBiz#performJSCallNative里添加接收分支处理。
...
...
@@ -24,6 +25,7 @@ export class H5CallNativeType {
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_receiveH5Data)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_getAppLoginAuthInfo)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_appNotifyEvent)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_receiveSubjectData)
}
}
...
...
sight_harmony/commons/wdWebComponent/src/main/ets/pages/WdWebComponent.ets
View file @
9354241
...
...
@@ -17,6 +17,7 @@ export struct WdWebComponent {
@Prop webUrl: string = ''
@Prop @Watch('onReloadStateChanged') reload: number = 0
@Link isPageEnd: boolean
@State subjectData : string = ''
build() {
Column() {
...
...
@@ -48,6 +49,10 @@ export struct WdWebComponent {
this.webviewControl.flushMessageQueue()
return true
}
if (url.includes('__bridge_loaded__')) {
BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)
return true
}
return this.onLoadIntercept(event.data.getRequestUrl().toString());
})
}
...
...
@@ -60,6 +65,7 @@ export struct WdWebComponent {
let handle = (data: Message, f: Callback) => {
Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data))
this.defaultPerformJSCallNative(data, f)
this.defaultGetReceiveSubjectData(data, f)
};
this.webviewControl.registerHandler(handleName, { handle: handle });
}
...
...
@@ -71,13 +77,21 @@ export struct WdWebComponent {
private defaultPerformJSCallNative: (data: Message, f: Callback) => void = (data: Message, f: Callback) => {
performJSCallNative(data, f)
}
/**
*/
private defaultGetReceiveSubjectData: (data: Message, f: Callback) => void = (data: Message, f: Callback) => {
if(data.handlerName === H5CallNativeType.jsCall_receiveSubjectData){
f('')
}
}
onPageBegin: (url?: string) => void = () => {
Logger.debug(TAG, 'onPageBegin');
this.registerHandlers();
//有时序问题 必须延时执行
setTimeout(() => {
BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)
}, 200)
// setTimeout(() => {
// BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)
// }, 200)
}
onPageEnd: (url?: string) => void = () => {
Logger.debug(TAG, 'onPageEnd');
...
...
sight_harmony/features/wdComponent/src/main/ets/components/SpacialTopicPageComponent.ets
View file @
9354241
...
...
@@ -22,6 +22,7 @@ export struct SpacialTopicPageComponent {
scroller: Scroller = new Scroller();
action: Action = {} as Action
@State webUrl: string = '';
@State subjectData: string = '';
@State isPageEnd: boolean = false
@Prop reload: number = 0;
@Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
...
...
@@ -57,6 +58,36 @@ export struct SpacialTopicPageComponent {
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 async getDetail() {
this.isNetConnected = NetworkUtil.isNetConnected()
...
...
@@ -93,12 +124,17 @@ export struct SpacialTopicPageComponent {
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType || '')
this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment || '')
// }
this.trySendData2H5()
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',this.contentDetailData)
}
}
}
...
...
@@ -115,15 +151,17 @@ export struct SpacialTopicPageComponent {
.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
})
}
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
.padding({ bottom: this.action?.params?.backVisibility ? 115 : 75 })
...
...
sight_harmony/products/phone/src/main/ets/pages/SpacialTopicPage.ets
View file @
9354241
import { Action } from 'wdBean';
import { SpacialTopicPageComponent } from 'wdComponent'
import { CommonConstants } from 'wdConstant'
import { Logger } from 'wdKit'
import { CommonConstants, SpConstants } from 'wdConstant'
import { Logger, SPHelper, StringUtils } from 'wdKit'
import router from '@ohos.router';
import dataPreferences from '@ohos.data.preferences';
const TAG = 'SpacialTopicPage';
...
...
@@ -12,6 +13,18 @@ struct SpacialTopicPage {
@State action: Action = {} as Action
@State reload: number = 0
@State count: number = 0
preferences: dataPreferences.Preferences | null = null;
observer = (key: string) => {
if(key == SpConstants.USER_ID){
if(StringUtils.isEmpty(SPHelper.default.getSync(SpConstants.USER_ID,""))){
// 未登录
}else {
// 登录
this.reload = this.reload + 1
}
}
}
build() {
Column() {
SpacialTopicPageComponent({ action: this.action ,reload:this.reload })
...
...
@@ -34,9 +47,16 @@ struct SpacialTopicPage {
Logger.info(TAG, `aboutToAppearcount:${this.reload}`);
let action: Action = router.getParams() as Action
this.action = action
this.addLoginStatusObserver()
}
async addLoginStatusObserver(){
this.preferences = await SPHelper.default.getPreferences();
this.preferences.on('change', this.observer);
}
onPageShow() {
this.reload = this.reload + 1
//
this.reload = this.reload + 1
Logger.info(TAG, `onPageShowcount:${this.reload}`);
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment