陈剑华

Merge remote-tracking branch 'origin/main'

1 -import { Callback, BridgeWebViewControl } from 'wdJsBridge'; 1 +import { Callback } from 'wdJsBridge';
2 import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; 2 import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
3 -import { Logger, StringUtils, } from 'wdKit'; 3 +import { Logger } from 'wdKit';
4 import { H5CallNativeType } from './H5CallNativeType'; 4 import { H5CallNativeType } from './H5CallNativeType';
5 import { ContentDTO } from 'wdBean'; 5 import { ContentDTO } from 'wdBean';
6 //TODO 这里引用了 features模块,是否考虑将跳转抽到公共模块 6 //TODO 这里引用了 features模块,是否考虑将跳转抽到公共模块
@@ -27,7 +27,10 @@ export function performJSCallNative(data: Message, call: Callback) { @@ -27,7 +27,10 @@ export function performJSCallNative(data: Message, call: Callback) {
27 case H5CallNativeType.jsCall_callAppService: 27 case H5CallNativeType.jsCall_callAppService:
28 break; 28 break;
29 case H5CallNativeType.jsCall_receiveH5Data: 29 case H5CallNativeType.jsCall_receiveH5Data:
30 - handleH5Data(JSON.parse(data?.data?.dataJson || '{}')) 30 + if(data?.data?.dataSource === 5){
  31 + handleH5Data(JSON.parse(data?.data?.dataJson || '{}'))
  32 +
  33 + }
31 break; 34 break;
32 case 'changeNativeMessage': 35 case 'changeNativeMessage':
33 call("this is change Web Message") 36 call("this is change Web Message")
@@ -59,6 +62,7 @@ function getAppPublicInfo(): string { @@ -59,6 +62,7 @@ function getAppPublicInfo(): string {
59 } 62 }
60 63
61 function handleH5Data(content:ContentDTO) { 64 function handleH5Data(content:ContentDTO) {
  65 + Logger.debug(TAG, 'handleH5Data' + ', content: ' + JSON.stringify(content))
62 ProcessUtils.processPage(content) 66 ProcessUtils.processPage(content)
63 } 67 }
64 68
1 import router from '@ohos.router'; 1 import router from '@ohos.router';
2 -import { BridgeUtil, BridgeWebViewControl, Callback } from 'wdJsBridge'; 2 +import { BridgeHandler, BridgeUtil, BridgeWebViewControl, Callback } from 'wdJsBridge';
3 import { Logger } from 'wdKit/Index'; 3 import { Logger } from 'wdKit/Index';
  4 +import { setDefaultNativeWebSettings } from './WebComponentUtil';
  5 +import { Action } from 'wdBean';
4 import { performJSCallNative } from './JsBridgeBiz'; 6 import { performJSCallNative } from './JsBridgeBiz';
5 import { H5CallNativeType } from './H5CallNativeType'; 7 import { H5CallNativeType } from './H5CallNativeType';
6 import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; 8 import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
@@ -10,9 +12,9 @@ const TAG = 'WdWebLocalComponent'; @@ -10,9 +12,9 @@ const TAG = 'WdWebLocalComponent';
10 @Component 12 @Component
11 export struct WdWebComponent { 13 export struct WdWebComponent {
12 webviewControl: BridgeWebViewControl = new BridgeWebViewControl() 14 webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
  15 + onWebPrepared: () => void = () => {}
13 @Prop backVisibility: boolean = false 16 @Prop backVisibility: boolean = false
14 @Prop webUrl: string = '' 17 @Prop webUrl: string = ''
15 - @Prop @Watch('onReloadStateChanged') reload: number = 0  
16 @Link isPageEnd: boolean 18 @Link isPageEnd: boolean
17 19
18 build() { 20 build() {
@@ -34,9 +36,10 @@ export struct WdWebComponent { @@ -34,9 +36,10 @@ export struct WdWebComponent {
34 .domStorageAccess(true) 36 .domStorageAccess(true)
35 .databaseAccess(true) 37 .databaseAccess(true)
36 .javaScriptAccess(true) 38 .javaScriptAccess(true)
37 - .zoomAccess(false)  
38 - .horizontalScrollBarAccess(false)  
39 - .verticalScrollBarAccess(false) 39 + .imageAccess(true)
  40 + .mixedMode(MixedMode.All)
  41 + .onlineImageAccess(true)
  42 + .enableNativeEmbedMode(true)
40 .onPageBegin((event) => { 43 .onPageBegin((event) => {
41 this.onPageBegin(event?.url); 44 this.onPageBegin(event?.url);
42 }) 45 })
@@ -66,14 +69,13 @@ export struct WdWebComponent { @@ -66,14 +69,13 @@ export struct WdWebComponent {
66 // 注册h5调用js相关 69 // 注册h5调用js相关
67 for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) { 70 for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) {
68 let handleName = H5CallNativeType.JsCallTypeList[i]; 71 let handleName = H5CallNativeType.JsCallTypeList[i];
69 - console.log('handleName:', handleName)  
70 let handle = (data: Message, f: Callback) => { 72 let handle = (data: Message, f: Callback) => {
  73 + Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data))
71 this.defaultPerformJSCallNative(data, f) 74 this.defaultPerformJSCallNative(data, f)
72 }; 75 };
73 this.webviewControl.registerHandler(handleName, { handle: handle }); 76 this.webviewControl.registerHandler(handleName, { handle: handle });
74 } 77 }
75 } 78 }
76 -  
77 /** 79 /**
78 * 默认【CallNative】逻辑处理 80 * 默认【CallNative】逻辑处理
79 */ 81 */
@@ -83,22 +85,18 @@ export struct WdWebComponent { @@ -83,22 +85,18 @@ export struct WdWebComponent {
83 onPageBegin: (url?: string) => void = () => { 85 onPageBegin: (url?: string) => void = () => {
84 Logger.debug(TAG, 'onPageBegin'); 86 Logger.debug(TAG, 'onPageBegin');
85 this.registerHandlers(); 87 this.registerHandlers();
  88 + // setTimeout(() => {
86 BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl) 89 BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)
  90 + // }, 100)
87 } 91 }
88 onPageEnd: (url?: string) => void = () => { 92 onPageEnd: (url?: string) => void = () => {
89 - this.isPageEnd = true  
90 Logger.debug(TAG, 'onPageEnd'); 93 Logger.debug(TAG, 'onPageEnd');
  94 + this.onWebPrepared()
  95 + this.isPageEnd = true
91 } 96 }
92 onLoadIntercept: (url?: string) => boolean = () => { 97 onLoadIntercept: (url?: string) => boolean = () => {
93 Logger.debug(TAG, 'onLoadIntercept return false'); 98 Logger.debug(TAG, 'onLoadIntercept return false');
94 return false 99 return false
95 } 100 }
96 -  
97 - onReloadStateChanged() {  
98 - Logger.info(TAG, `onReloadStateChanged:::refresh, this.reload: ${this.reload}`);  
99 - if (this.reload > 0) {  
100 - this.webviewControl.refresh()  
101 - }  
102 - }  
103 } 101 }
104 102
@@ -12,8 +12,7 @@ const TAG = 'WdWebLocalComponent'; @@ -12,8 +12,7 @@ const TAG = 'WdWebLocalComponent';
12 @Component 12 @Component
13 export struct WdWebLocalComponent { 13 export struct WdWebLocalComponent {
14 webviewControl: BridgeWebViewControl = new BridgeWebViewControl() 14 webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
15 - onWebPrepared: () => void = () => {  
16 - } 15 + onWebPrepared: () => void = () => {}
17 @Prop backVisibility: boolean = false 16 @Prop backVisibility: boolean = false
18 @Prop webResource: Resource = {} as Resource 17 @Prop webResource: Resource = {} as Resource
19 @State webHeight: string | number = '100%' 18 @State webHeight: string | number = '100%'
@@ -73,6 +72,7 @@ export struct WdWebLocalComponent { @@ -73,6 +72,7 @@ export struct WdWebLocalComponent {
73 for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) { 72 for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) {
74 let handleName = H5CallNativeType.JsCallTypeList[i]; 73 let handleName = H5CallNativeType.JsCallTypeList[i];
75 let handle = (data: Message, f: Callback) => { 74 let handle = (data: Message, f: Callback) => {
  75 + Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data.data))
76 this.setCurrentPageOperate(data) 76 this.setCurrentPageOperate(data)
77 this.defaultPerformJSCallNative(data, f) 77 this.defaultPerformJSCallNative(data, f)
78 }; 78 };
@@ -19,7 +19,7 @@ export interface CompDTO { @@ -19,7 +19,7 @@ export interface CompDTO {
19 name: string; 19 name: string;
20 objectId: string; // 跳转页面id? 20 objectId: string; // 跳转页面id?
21 objectTitle: string; // comp标题 21 objectTitle: string; // comp标题
22 - objectType?: string; // 跳转类型,枚举: 22 + // objectType?: string; // 跳转类型,枚举:
23 operDataList: ContentDTO[]; // 运营数据列表【正常运营配置的强运营数据,部分推荐场景的配置(自动源兜底数据)】 23 operDataList: ContentDTO[]; // 运营数据列表【正常运营配置的强运营数据,部分推荐场景的配置(自动源兜底数据)】
24 // pageId?: any; 24 // pageId?: any;
25 posterSize: string; 25 posterSize: string;
1 -import { Action, ContentDetailDTO, } from 'wdBean';  
2 -import DetailViewModel from '../viewmodel/DetailViewModel'; 1 +import { Action, H5ReceiveDetailBean } from 'wdBean';
3 import { WdWebComponent } from 'wdWebComponent'; 2 import { WdWebComponent } from 'wdWebComponent';
4 import router from '@ohos.router'; 3 import router from '@ohos.router';
5 import { CommonConstants } from 'wdConstant' 4 import { CommonConstants } from 'wdConstant'
6 import { BridgeWebViewControl } from 'wdJsBridge/Index'; 5 import { BridgeWebViewControl } from 'wdJsBridge/Index';
7 import { detailedSkeleton } from './skeleton/detailSkeleton' 6 import { detailedSkeleton } from './skeleton/detailSkeleton'
8 - 7 +import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type';
9 const TAG = 'SpacialTopicPageComponent' 8 const TAG = 'SpacialTopicPageComponent'
10 9
11 @Component 10 @Component
@@ -15,6 +14,28 @@ export struct SpacialTopicPageComponent { @@ -15,6 +14,28 @@ export struct SpacialTopicPageComponent {
15 action: Action = {} as Action 14 action: Action = {} as Action
16 @State webUrl: string = ''; 15 @State webUrl: string = '';
17 @State isPageEnd: boolean = false 16 @State isPageEnd: boolean = false
  17 + private h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean
  18 + private webPrepared = false;
  19 + private dataPrepared = false;
  20 +
  21 + private trySendData2H5() {
  22 + if (!this.webPrepared || !this.dataPrepared) {
  23 + return
  24 + }
  25 + // 数据、web组件,都准备好了,开始塞详情数据
  26 + this.sendContentData2H5(this.h5ReceiveAppData)
  27 + }
  28 +
  29 + private onWebPrepared() {
  30 + this.webPrepared = true
  31 + this.trySendData2H5()
  32 + }
  33 +
  34 + private sendContentData2H5(h5ReceiveAppData: H5ReceiveDetailBean) {
  35 + this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData,
  36 + JSON.stringify(h5ReceiveAppData), (data: string) => {
  37 + })
  38 + }
18 39
19 build() { 40 build() {
20 Column() { 41 Column() {
@@ -27,7 +48,8 @@ export struct SpacialTopicPageComponent { @@ -27,7 +48,8 @@ export struct SpacialTopicPageComponent {
27 webviewControl: this.webviewControl, 48 webviewControl: this.webviewControl,
28 webUrl: this.webUrl, 49 webUrl: this.webUrl,
29 backVisibility: false, 50 backVisibility: false,
30 - isPageEnd:$isPageEnd 51 + onWebPrepared: this.onWebPrepared.bind(this),
  52 + isPageEnd: $isPageEnd
31 }) 53 })
32 } 54 }
33 .padding({ bottom: 56 }) 55 .padding({ bottom: 56 })
@@ -72,7 +94,6 @@ export struct SpacialTopicPageComponent { @@ -72,7 +94,6 @@ export struct SpacialTopicPageComponent {
72 .justifyContent(FlexAlign.SpaceBetween) 94 .justifyContent(FlexAlign.SpaceBetween)
73 .backgroundColor(Color.White) 95 .backgroundColor(Color.White)
74 96
75 -  
76 } 97 }
77 }.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT) 98 }.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT)
78 .backgroundColor(Color.White) 99 .backgroundColor(Color.White)
@@ -83,8 +104,10 @@ export struct SpacialTopicPageComponent { @@ -83,8 +104,10 @@ export struct SpacialTopicPageComponent {
83 if (action) { 104 if (action) {
84 this.webUrl = action.params?.url || '' 105 this.webUrl = action.params?.url || ''
85 } 106 }
  107 + this.trySendData2H5()
86 } 108 }
87 109
88 aboutToDisappear() { 110 aboutToDisappear() {
  111 +
89 } 112 }
90 } 113 }
1 import { CompDTO, ContentDTO } from 'wdBean'; 1 import { CompDTO, ContentDTO } from 'wdBean';
2 import { CommonConstants } from 'wdConstant/Index'; 2 import { CommonConstants } from 'wdConstant/Index';
3 -import { CollectionUtils, DateTimeUtils, Logger, StringUtils, ToastUtils } from 'wdKit/Index'; 3 +import { Logger } from 'wdKit/Index';
4 import PageViewModel from '../../viewmodel/PageViewModel'; 4 import PageViewModel from '../../viewmodel/PageViewModel';
5 5
6 const TAG = 'Zh_Grid_Layout-02'; 6 const TAG = 'Zh_Grid_Layout-02';
@@ -31,8 +31,6 @@ export struct ZhGridLayout02 { @@ -31,8 +31,6 @@ export struct ZhGridLayout02 {
31 31
32 build() { 32 build() {
33 Column() { 33 Column() {
34 -  
35 -  
36 Scroll() { 34 Scroll() {
37 Column() { 35 Column() {
38 Row() { 36 Row() {
@@ -46,10 +44,12 @@ export struct ZhGridLayout02 { @@ -46,10 +44,12 @@ export struct ZhGridLayout02 {
46 .fontWeight(600) 44 .fontWeight(600)
47 } 45 }
48 .justifyContent(FlexAlign.Start) 46 .justifyContent(FlexAlign.Start)
  47 +
49 .margin({ top: 8, bottom: 8 }) 48 .margin({ top: 8, bottom: 8 })
50 .width(CommonConstants.FULL_WIDTH) 49 .width(CommonConstants.FULL_WIDTH)
51 50
52 GridRow({ 51 GridRow({
  52 + gutter: { x: 12, y: 22 },
53 columns: { sm: listSize, md: 2 }, 53 columns: { sm: listSize, md: 2 },
54 breakpoints: { value: ['320vp', '520vp', '840vp'] } 54 breakpoints: { value: ['320vp', '520vp', '840vp'] }
55 }) { 55 }) {
@@ -60,7 +60,6 @@ export struct ZhGridLayout02 { @@ -60,7 +60,6 @@ export struct ZhGridLayout02 {
60 }) 60 })
61 } 61 }
62 } 62 }
63 -  
64 } 63 }
65 .width("100%") 64 .width("100%")
66 .height("100%") 65 .height("100%")
@@ -82,12 +81,9 @@ export struct ZhGridLayout02 { @@ -82,12 +81,9 @@ export struct ZhGridLayout02 {
82 .width(CommonConstants.FULL_WIDTH) 81 .width(CommonConstants.FULL_WIDTH)
83 // .width("100%") 82 // .width("100%")
84 .height("100%") 83 .height("100%")
  84 + .padding({ left: 16, right: 16 })
  85 +
85 // .layoutWeight(1) 86 // .layoutWeight(1)
86 - .padding({  
87 - top: 14,  
88 - left: 16,  
89 - right: 16  
90 - })  
91 87
92 } 88 }
93 89
@@ -100,9 +96,9 @@ export struct ZhGridLayout02 { @@ -100,9 +96,9 @@ export struct ZhGridLayout02 {
100 buildItemCard(item: ContentDTO) { 96 buildItemCard(item: ContentDTO) {
101 Column() { 97 Column() {
102 Image(item.fullColumnImgUrls[0].url) 98 Image(item.fullColumnImgUrls[0].url)
103 - .width(170) 99 + .width('100%')
104 .height(95) 100 .height(95)
105 - .margin(16) 101 + .borderRadius(4)
106 Text(item.newsTitle) 102 Text(item.newsTitle)
107 .fontSize(13) 103 .fontSize(13)
108 .maxLines(2) 104 .maxLines(2)
@@ -68,6 +68,7 @@ export struct PeopleShipHomeArticleListComponent { @@ -68,6 +68,7 @@ export struct PeopleShipHomeArticleListComponent {
68 } 68 }
69 if(!this.isLoading && this.hasMore){ 69 if(!this.isLoading && this.hasMore){
70 //加载分页数据 70 //加载分页数据
  71 + this.currentPage++;
71 this.getPeopleShipPageArticleList(resolve) 72 this.getPeopleShipPageArticleList(resolve)
72 }else { 73 }else {
73 if(resolve) { 74 if(resolve) {
@@ -132,7 +133,7 @@ export struct PeopleShipHomeArticleListComponent { @@ -132,7 +133,7 @@ export struct PeopleShipHomeArticleListComponent {
132 } 133 }
133 134
134 onChange() { 135 onChange() {
135 - if (this.currentIndex == this.currentTopSelectedIndex) { 136 + if (this.currentIndex == this.currentTopSelectedIndex && this.arr.length == 0) {
136 this.currentPage = 1 137 this.currentPage = 1
137 this.getPeopleShipPageArticleList() 138 this.getPeopleShipPageArticleList()
138 } 139 }
@@ -163,7 +164,6 @@ export struct PeopleShipHomeArticleListComponent { @@ -163,7 +164,6 @@ export struct PeopleShipHomeArticleListComponent {
163 if (listData && listData.list && listData.list.length > 0) { 164 if (listData && listData.list && listData.list.length > 0) {
164 this.viewType = 3; 165 this.viewType = 3;
165 if (listData.list.length === 20) { 166 if (listData.list.length === 20) {
166 - this.currentPage++;  
167 this.hasMore = true; 167 this.hasMore = true;
168 } else { 168 } else {
169 this.hasMore = false; 169 this.hasMore = false;
@@ -211,6 +211,9 @@ export struct PeopleShipHomeArticleListComponent { @@ -211,6 +211,9 @@ export struct PeopleShipHomeArticleListComponent {
211 private articleListDTOChangeContentDTO(listData: ArticleListData, listCom: InteractDataDTO[]) { 211 private articleListDTOChangeContentDTO(listData: ArticleListData, listCom: InteractDataDTO[]) {
212 this.isLoading = false 212 this.isLoading = false
213 if (listData.list.length) { 213 if (listData.list.length) {
  214 + if (this.currentPage == 1) {
  215 + this.arr = []
  216 + }
214 for (const element of listData.list) { 217 for (const element of listData.list) {
215 let contentDTO = {} as ContentDTO 218 let contentDTO = {} as ContentDTO
216 contentDTO.appStyle = this.changeCommon(element.appStyle) 219 contentDTO.appStyle = this.changeCommon(element.appStyle)
@@ -10,7 +10,7 @@ export struct CustomPullToRefresh { @@ -10,7 +10,7 @@ export struct CustomPullToRefresh {
10 onLoadMore: (resolve?: (value: string | PromiseLike<string>) => void) => void = () => { 10 onLoadMore: (resolve?: (value: string | PromiseLike<string>) => void) => void = () => {
11 } 11 }
12 ///是否存在上拉更多 12 ///是否存在上拉更多
13 - @Prop hasMore: boolean = true 13 + @Prop @Watch('hasMoreChange') hasMore: boolean = true
14 refreshConfigurator: PullToRefreshConfigurator = new PullToRefreshConfigurator().setHasLoadMore(this.hasMore); 14 refreshConfigurator: PullToRefreshConfigurator = new PullToRefreshConfigurator().setHasLoadMore(this.hasMore);
15 build() { 15 build() {
16 Column(){ 16 Column(){
@@ -36,4 +36,8 @@ export struct CustomPullToRefresh { @@ -36,4 +36,8 @@ export struct CustomPullToRefresh {
36 }) 36 })
37 } 37 }
38 } 38 }
  39 +
  40 + hasMoreChange() {
  41 + this.refreshConfigurator.setHasLoadMore(this.hasMore)
  42 + }
39 } 43 }
@@ -25,6 +25,7 @@ export class ProcessUtils { @@ -25,6 +25,7 @@ export class ProcessUtils {
25 return; 25 return;
26 } 26 }
27 let type = content.objectType; 27 let type = content.objectType;
  28 + console.log(TAG,'objectType',`${JSON.stringify(content)}`);
28 switch (type) { 29 switch (type) {
29 case ContentConstants.TYPE_NONE: 30 case ContentConstants.TYPE_NONE:
30 Logger.debug(TAG, "processPage, do nothing"); 31 Logger.debug(TAG, "processPage, do nothing");
@@ -59,7 +60,7 @@ export class ProcessUtils { @@ -59,7 +60,7 @@ export class ProcessUtils {
59 break; 60 break;
60 //动态详情页(动态视频) 61 //动态详情页(动态视频)
61 case ContentConstants.TYPE_FIFTEEN: 62 case ContentConstants.TYPE_FIFTEEN:
62 - ProcessUtils.gotoDynamicDetailPage(content); 63 + ProcessUtils.gotoWeb(content);
63 break; 64 break;
64 default: 65 default:
65 break; 66 break;
@@ -32,7 +32,7 @@ struct DefaultWebPage { @@ -32,7 +32,7 @@ struct DefaultWebPage {
32 WdWebComponent({ 32 WdWebComponent({
33 webUrl: this.url, 33 webUrl: this.url,
34 backVisibility: false, 34 backVisibility: false,
35 - reload: this.reload, 35 + // reload: this.reload,
36 isPageEnd:$isPageEnd 36 isPageEnd:$isPageEnd
37 }) 37 })
38 } 38 }