chengen02

-fix bug修复

@@ -12,6 +12,7 @@ export class H5CallNativeType { @@ -12,6 +12,7 @@ export class H5CallNativeType {
12 static jsCall_receiveH5Data = 'jsCall_receiveH5Data' 12 static jsCall_receiveH5Data = 'jsCall_receiveH5Data'
13 static jsCall_getAppLoginAuthInfo = 'jsCall_getAppLoginAuthInfo' 13 static jsCall_getAppLoginAuthInfo = 'jsCall_getAppLoginAuthInfo'
14 static jsCall_appNotifyEvent = 'jsCall_appNotifyEvent' 14 static jsCall_appNotifyEvent = 'jsCall_appNotifyEvent'
  15 + static jsCall_receiveSubjectData = 'jsCall_receiveSubjectData'
15 16
16 // TODO 业务自行新增类型、自行在JsBridgeBiz#performJSCallNative里添加接收分支处理。 17 // TODO 业务自行新增类型、自行在JsBridgeBiz#performJSCallNative里添加接收分支处理。
17 18
@@ -24,6 +25,7 @@ export class H5CallNativeType { @@ -24,6 +25,7 @@ export class H5CallNativeType {
24 H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_receiveH5Data) 25 H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_receiveH5Data)
25 H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_getAppLoginAuthInfo) 26 H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_getAppLoginAuthInfo)
26 H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_appNotifyEvent) 27 H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_appNotifyEvent)
  28 + H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_receiveSubjectData)
27 } 29 }
28 } 30 }
29 31
@@ -17,6 +17,7 @@ export struct WdWebComponent { @@ -17,6 +17,7 @@ export struct WdWebComponent {
17 @Prop webUrl: string = '' 17 @Prop webUrl: string = ''
18 @Prop @Watch('onReloadStateChanged') reload: number = 0 18 @Prop @Watch('onReloadStateChanged') reload: number = 0
19 @Link isPageEnd: boolean 19 @Link isPageEnd: boolean
  20 + @State subjectData : string = ''
20 21
21 build() { 22 build() {
22 Column() { 23 Column() {
@@ -48,6 +49,10 @@ export struct WdWebComponent { @@ -48,6 +49,10 @@ export struct WdWebComponent {
48 this.webviewControl.flushMessageQueue() 49 this.webviewControl.flushMessageQueue()
49 return true 50 return true
50 } 51 }
  52 + if (url.includes('__bridge_loaded__')) {
  53 + BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)
  54 + return true
  55 + }
51 return this.onLoadIntercept(event.data.getRequestUrl().toString()); 56 return this.onLoadIntercept(event.data.getRequestUrl().toString());
52 }) 57 })
53 } 58 }
@@ -60,6 +65,7 @@ export struct WdWebComponent { @@ -60,6 +65,7 @@ export struct WdWebComponent {
60 let handle = (data: Message, f: Callback) => { 65 let handle = (data: Message, f: Callback) => {
61 Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data)) 66 Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data))
62 this.defaultPerformJSCallNative(data, f) 67 this.defaultPerformJSCallNative(data, f)
  68 + this.defaultGetReceiveSubjectData(data, f)
63 }; 69 };
64 this.webviewControl.registerHandler(handleName, { handle: handle }); 70 this.webviewControl.registerHandler(handleName, { handle: handle });
65 } 71 }
@@ -71,13 +77,21 @@ export struct WdWebComponent { @@ -71,13 +77,21 @@ export struct WdWebComponent {
71 private defaultPerformJSCallNative: (data: Message, f: Callback) => void = (data: Message, f: Callback) => { 77 private defaultPerformJSCallNative: (data: Message, f: Callback) => void = (data: Message, f: Callback) => {
72 performJSCallNative(data, f) 78 performJSCallNative(data, f)
73 } 79 }
  80 +
  81 + /**
  82 + */
  83 + private defaultGetReceiveSubjectData: (data: Message, f: Callback) => void = (data: Message, f: Callback) => {
  84 + if(data.handlerName === H5CallNativeType.jsCall_receiveSubjectData){
  85 + f('')
  86 + }
  87 + }
74 onPageBegin: (url?: string) => void = () => { 88 onPageBegin: (url?: string) => void = () => {
75 Logger.debug(TAG, 'onPageBegin'); 89 Logger.debug(TAG, 'onPageBegin');
76 this.registerHandlers(); 90 this.registerHandlers();
77 //有时序问题 必须延时执行 91 //有时序问题 必须延时执行
78 - setTimeout(() => {  
79 - BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)  
80 - }, 200) 92 + // setTimeout(() => {
  93 + // BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)
  94 + // }, 200)
81 } 95 }
82 onPageEnd: (url?: string) => void = () => { 96 onPageEnd: (url?: string) => void = () => {
83 Logger.debug(TAG, 'onPageEnd'); 97 Logger.debug(TAG, 'onPageEnd');
@@ -22,6 +22,7 @@ export struct SpacialTopicPageComponent { @@ -22,6 +22,7 @@ export struct SpacialTopicPageComponent {
22 scroller: Scroller = new Scroller(); 22 scroller: Scroller = new Scroller();
23 action: Action = {} as Action 23 action: Action = {} as Action
24 @State webUrl: string = ''; 24 @State webUrl: string = '';
  25 + @State subjectData: string = '';
25 @State isPageEnd: boolean = false 26 @State isPageEnd: boolean = false
26 @Prop reload: number = 0; 27 @Prop reload: number = 0;
27 @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO 28 @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@@ -57,6 +58,36 @@ export struct SpacialTopicPageComponent { @@ -57,6 +58,36 @@ export struct SpacialTopicPageComponent {
57 let context = getContext(this) as common.UIAbilityContext; 58 let context = getContext(this) as common.UIAbilityContext;
58 viewBlogItemInsightIntentShare(context,this.contentDetailData) 59 viewBlogItemInsightIntentShare(context,this.contentDetailData)
59 } 60 }
  61 + async getWebviewPageData (){
  62 + let pageId = this.action.params?.extra?.pageId
  63 + let relId: string = ''
  64 + let relType: string = ''
  65 + let contentId: string = ''
  66 + if (this.action && this.action.params) {
  67 + if (this.action.params.contentID) {
  68 + contentId = this.action.params.contentID;
  69 + }
  70 + if (this.action && this.action.params && this.action.params.extra) {
  71 + if (this.action.params.extra.relId) {
  72 + relId = this.action.params.extra.relId;
  73 + }
  74 + if (this.action.params.extra.relType) {
  75 + relType = this.action.params.extra.relType
  76 + }
  77 + }
  78 + }
  79 + if(pageId){
  80 + // let pageInfoMsg = await PageRepository.fetchMorningEveningPageInfo(pageId)
  81 + // let pageCompInfoMsg = await PageRepository.fetchMorningEveningCompInfo(Number(pageId), groupId, refreshTime, topicId, 1, 20)
  82 + // let res = {
  83 + // dataJson: {
  84 + // pageInfoResponseMap: pageInfoMsg,
  85 + // compInfoResponseMap: pageCompInfoMsg,
  86 + // },
  87 + // }
  88 + }
  89 + }
  90 +
60 91
61 private async getDetail() { 92 private async getDetail() {
62 this.isNetConnected = NetworkUtil.isNetConnected() 93 this.isNetConnected = NetworkUtil.isNetConnected()
@@ -93,12 +124,17 @@ export struct SpacialTopicPageComponent { @@ -93,12 +124,17 @@ export struct SpacialTopicPageComponent {
93 this.publishCommentModel.targetType = String(this.contentDetailData?.newsType || '') 124 this.publishCommentModel.targetType = String(this.contentDetailData?.newsType || '')
94 this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment || '') 125 this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment || '')
95 // } 126 // }
96 - this.trySendData2H5() 127 + this.subjectData = 'dasdasdadas'
  128 +
  129 + //todo
  130 + // this.trySendData2H5()
97 } 131 }
98 if(pageInfoMsg && pageInfoMsg.data){ 132 if(pageInfoMsg && pageInfoMsg.data){
99 this.contentDetailData.openComment = Number(pageInfoMsg.data.topicInfo.commentFlag) 133 this.contentDetailData.openComment = Number(pageInfoMsg.data.topicInfo.commentFlag)
100 this.contentDetailData.commentDisplay = Number(pageInfoMsg.data.topicInfo.commentShowFlag) 134 this.contentDetailData.commentDisplay = Number(pageInfoMsg.data.topicInfo.commentShowFlag)
101 } 135 }
  136 +
  137 + console.log('contentDetailData',this.contentDetailData)
102 } 138 }
103 } 139 }
104 } 140 }
@@ -115,14 +151,16 @@ export struct SpacialTopicPageComponent { @@ -115,14 +151,16 @@ export struct SpacialTopicPageComponent {
115 .textAlign(TextAlign.Center) 151 .textAlign(TextAlign.Center)
116 .fontWeight(500) 152 .fontWeight(500)
117 .visibility(this.action?.params?.backVisibility && this.isPageEnd ? Visibility.Visible : Visibility.None) 153 .visibility(this.action?.params?.backVisibility && this.isPageEnd ? Visibility.Visible : Visibility.None)
118 -  
119 - WdWebComponent({  
120 - webviewControl: this.webviewControl,  
121 - webUrl: this.webUrl,  
122 - reload: this.reload,  
123 - onWebPrepared: this.onWebPrepared.bind(this),  
124 - isPageEnd: $isPageEnd,  
125 - }) 154 + if(this.subjectData.length > 0){
  155 + WdWebComponent({
  156 + webviewControl: this.webviewControl,
  157 + webUrl: this.webUrl,
  158 + reload: this.reload,
  159 + onWebPrepared: this.onWebPrepared.bind(this),
  160 + isPageEnd: $isPageEnd,
  161 + subjectData: this.subjectData
  162 + })
  163 + }
126 } 164 }
127 .width(CommonConstants.FULL_WIDTH) 165 .width(CommonConstants.FULL_WIDTH)
128 .height(CommonConstants.FULL_HEIGHT) 166 .height(CommonConstants.FULL_HEIGHT)
1 import { Action } from 'wdBean'; 1 import { Action } from 'wdBean';
2 import { SpacialTopicPageComponent } from 'wdComponent' 2 import { SpacialTopicPageComponent } from 'wdComponent'
3 -import { CommonConstants } from 'wdConstant'  
4 -import { Logger } from 'wdKit' 3 +import { CommonConstants, SpConstants } from 'wdConstant'
  4 +import { Logger, SPHelper, StringUtils } from 'wdKit'
5 import router from '@ohos.router'; 5 import router from '@ohos.router';
  6 +import dataPreferences from '@ohos.data.preferences';
6 7
7 const TAG = 'SpacialTopicPage'; 8 const TAG = 'SpacialTopicPage';
8 9
@@ -12,6 +13,18 @@ struct SpacialTopicPage { @@ -12,6 +13,18 @@ struct SpacialTopicPage {
12 @State action: Action = {} as Action 13 @State action: Action = {} as Action
13 @State reload: number = 0 14 @State reload: number = 0
14 @State count: number = 0 15 @State count: number = 0
  16 + preferences: dataPreferences.Preferences | null = null;
  17 + observer = (key: string) => {
  18 + if(key == SpConstants.USER_ID){
  19 + if(StringUtils.isEmpty(SPHelper.default.getSync(SpConstants.USER_ID,""))){
  20 + // 未登录
  21 + }else {
  22 + // 登录
  23 + this.reload = this.reload + 1
  24 + }
  25 + }
  26 + }
  27 +
15 build() { 28 build() {
16 Column() { 29 Column() {
17 SpacialTopicPageComponent({ action: this.action ,reload:this.reload }) 30 SpacialTopicPageComponent({ action: this.action ,reload:this.reload })
@@ -34,9 +47,16 @@ struct SpacialTopicPage { @@ -34,9 +47,16 @@ struct SpacialTopicPage {
34 Logger.info(TAG, `aboutToAppearcount:${this.reload}`); 47 Logger.info(TAG, `aboutToAppearcount:${this.reload}`);
35 let action: Action = router.getParams() as Action 48 let action: Action = router.getParams() as Action
36 this.action = action 49 this.action = action
  50 + this.addLoginStatusObserver()
  51 + }
  52 +
  53 + async addLoginStatusObserver(){
  54 + this.preferences = await SPHelper.default.getPreferences();
  55 + this.preferences.on('change', this.observer);
37 } 56 }
38 onPageShow() { 57 onPageShow() {
39 - this.reload = this.reload + 1 58 + // this.reload = this.reload + 1
40 Logger.info(TAG, `onPageShowcount:${this.reload}`); 59 Logger.info(TAG, `onPageShowcount:${this.reload}`);
  60 +
41 } 61 }
42 } 62 }