yuzhilin

稿件详情视频播放

@@ -21,6 +21,12 @@ interface dataObject { @@ -21,6 +21,12 @@ interface dataObject {
21 method?: string 21 method?: string
22 url?: string 22 url?: string
23 parameters?: object 23 parameters?: object
  24 + videoUrl?: string
  25 + positionWidth?: string
  26 + positionHeight?: string
  27 + positionLeft?: string
  28 + positionTop?: string
  29 + videoLandscape?: string
24 } 30 }
25 31
26 /** 32 /**
1 import router from '@ohos.router'; 1 import router from '@ohos.router';
2 -import { BridgeHandler, BridgeUtil, BridgeWebViewControl, Callback } from 'wdJsBridge'; 2 +import { 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';  
6 import { performJSCallNative } from './JsBridgeBiz'; 4 import { performJSCallNative } from './JsBridgeBiz';
7 import { H5CallNativeType } from './H5CallNativeType'; 5 import { H5CallNativeType } from './H5CallNativeType';
8 import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; 6 import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
@@ -12,11 +10,18 @@ const TAG = 'WdWebLocalComponent'; @@ -12,11 +10,18 @@ const TAG = 'WdWebLocalComponent';
12 @Component 10 @Component
13 export struct WdWebLocalComponent { 11 export struct WdWebLocalComponent {
14 webviewControl: BridgeWebViewControl = new BridgeWebViewControl() 12 webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
15 - onWebPrepared: () => void = () => {} 13 + onWebPrepared: () => void = () => {
  14 + }
16 @Prop backVisibility: boolean = false 15 @Prop backVisibility: boolean = false
17 @Prop webResource: Resource = {} as Resource 16 @Prop webResource: Resource = {} as Resource
18 @State webHeight: string | number = '100%' 17 @State webHeight: string | number = '100%'
19 @Link isPageEnd: boolean 18 @Link isPageEnd: boolean
  19 + @State videoUrl: string = ''
  20 + @State positionWidth: number = 0
  21 + @State positionHeight: number = 0
  22 + @State positionLeft: number = 0
  23 + @State positionTop: number = 0
  24 + @State videoLandscape: string = '1'
20 25
21 build() { 26 build() {
22 Column() { 27 Column() {
@@ -33,37 +38,63 @@ export struct WdWebLocalComponent { @@ -33,37 +38,63 @@ export struct WdWebLocalComponent {
33 .height(44) 38 .height(44)
34 .visibility(this.backVisibility ? Visibility.Visible : Visibility.None) 39 .visibility(this.backVisibility ? Visibility.Visible : Visibility.None)
35 40
36 - Web({ src: this.webResource, controller: this.webviewControl })  
37 - .domStorageAccess(true)  
38 - .databaseAccess(true)  
39 - .javaScriptAccess(true)  
40 - .imageAccess(true)  
41 - .mixedMode(MixedMode.All)  
42 - .onlineImageAccess(true)  
43 - .enableNativeEmbedMode(true)  
44 - .height(this.webHeight)  
45 - .onPageBegin((event) => {  
46 - this.onPageBegin(event?.url);  
47 - })  
48 - .onPageEnd((event) => {  
49 - this.onPageEnd(event?.url)  
50 - })  
51 - .onLoadIntercept((event) => {  
52 - let url: string = event.data.getRequestUrl().toString()  
53 - url = url.replace("%(?![0-9a-fA-F]{2})", "%25")  
54 - .replace("\\+", "%2B");  
55 - url = decodeURIComponent(url)  
56 - if (url.startsWith(BridgeUtil.YY_RETURN_DATA)) {  
57 - this.webviewControl.handlerReturnData(url)  
58 - return true  
59 - }  
60 - if (url.startsWith(BridgeUtil.YY_OVERRIDE_SCHEMA)) {  
61 - Logger.debug(TAG, 'flushMessageQueue');  
62 - this.webviewControl.flushMessageQueue()  
63 - return true 41 + Row() {
  42 + RelativeContainer() {
  43 + Web({ src: this.webResource, controller: this.webviewControl })
  44 + .domStorageAccess(true)
  45 + .databaseAccess(true)
  46 + .javaScriptAccess(true)
  47 + .imageAccess(true)
  48 + .mixedMode(MixedMode.All)
  49 + .onlineImageAccess(true)
  50 + .enableNativeEmbedMode(true)
  51 + .height(this.webHeight)
  52 + .onPageBegin((event) => {
  53 + this.onPageBegin(event?.url);
  54 + })
  55 + .onPageEnd((event) => {
  56 + this.onPageEnd(event?.url)
  57 + })
  58 + .onLoadIntercept((event) => {
  59 + let url: string = event.data.getRequestUrl().toString()
  60 + url = url.replace("%(?![0-9a-fA-F]{2})", "%25")
  61 + .replace("\\+", "%2B");
  62 + url = decodeURIComponent(url)
  63 + if (url.startsWith(BridgeUtil.YY_RETURN_DATA)) {
  64 + this.webviewControl.handlerReturnData(url)
  65 + return true
  66 + }
  67 + if (url.startsWith(BridgeUtil.YY_OVERRIDE_SCHEMA)) {
  68 + Logger.debug(TAG, 'flushMessageQueue');
  69 + this.webviewControl.flushMessageQueue()
  70 + return true
  71 + }
  72 + return this.onLoadIntercept(event.data.getRequestUrl().toString());
  73 + })
  74 + .id('web')
  75 + .alignRules({
  76 + top: { anchor: "__container__", align: VerticalAlign.Top },
  77 + })
  78 +
  79 + if (this.videoUrl) {
  80 + Video({ src: this.videoUrl })
  81 + .autoPlay(true)
  82 + .width(this.positionWidth)
  83 + .height(this.positionHeight)
  84 + .borderRadius(5)
  85 + .alignRules({
  86 + top: { anchor: "__container__", align: VerticalAlign.Top },
  87 + })
  88 + .offset({
  89 + x: this.positionLeft,
  90 + y: this.positionTop
  91 + })
  92 + .id("video")
64 } 93 }
65 - return this.onLoadIntercept(event.data.getRequestUrl().toString());  
66 - }) 94 +
  95 + }
  96 + }.width('100%')
  97 + .height(this.webHeight)
67 } 98 }
68 } 99 }
69 100
@@ -73,7 +104,8 @@ export struct WdWebLocalComponent { @@ -73,7 +104,8 @@ export struct WdWebLocalComponent {
73 let handleName = H5CallNativeType.JsCallTypeList[i]; 104 let handleName = H5CallNativeType.JsCallTypeList[i];
74 let handle = (data: Message, f: Callback) => { 105 let handle = (data: Message, f: Callback) => {
75 Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data.data)) 106 Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data.data))
76 - this.setCurrentPageOperate(data) 107 + this.setCurrentPageOperate8(data)
  108 + this.setCurrentPageOperate9(data)
77 this.defaultPerformJSCallNative(data, f) 109 this.defaultPerformJSCallNative(data, f)
78 }; 110 };
79 this.webviewControl.registerHandler(handleName, { handle: handle }); 111 this.webviewControl.registerHandler(handleName, { handle: handle });
@@ -81,7 +113,7 @@ export struct WdWebLocalComponent { @@ -81,7 +113,7 @@ export struct WdWebLocalComponent {
81 } 113 }
82 114
83 //webview 高度设置 115 //webview 高度设置
84 - private setCurrentPageOperate: (data: Message) => void = (data) => { 116 + private setCurrentPageOperate8: (data: Message) => void = (data) => {
85 if (data.handlerName === H5CallNativeType.jsCall_currentPageOperate && data?.data?.operateType === '8') { 117 if (data.handlerName === H5CallNativeType.jsCall_currentPageOperate && data?.data?.operateType === '8') {
86 if (typeof this.webHeight === 'number') { 118 if (typeof this.webHeight === 'number') {
87 if (Number(data?.data?.webViewHeight) > this.webHeight) { 119 if (Number(data?.data?.webViewHeight) > this.webHeight) {
@@ -93,6 +125,17 @@ export struct WdWebLocalComponent { @@ -93,6 +125,17 @@ export struct WdWebLocalComponent {
93 } 125 }
94 } 126 }
95 } 127 }
  128 + //播放视频
  129 + private setCurrentPageOperate9: (data: Message) => void = (data) => {
  130 + if (data.handlerName === H5CallNativeType.jsCall_currentPageOperate && data?.data?.operateType === '9') {
  131 + this.videoUrl = data?.data?.videoUrl || ''
  132 + this.positionWidth = Number(data?.data?.positionWidth) || 0
  133 + this.positionHeight = Number(data?.data?.positionHeight) || 0
  134 + this.positionLeft = Number(data?.data?.positionLeft) || 0
  135 + this.positionTop = Number(data?.data?.positionTop) || 0
  136 + this.videoLandscape = data?.data?.videoLandscape || '1'
  137 + }
  138 + }
96 /** 139 /**
97 * 默认【CallNative】逻辑处理 140 * 默认【CallNative】逻辑处理
98 */ 141 */
@@ -20,6 +20,7 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; @@ -20,6 +20,7 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
20 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; 20 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
21 import { PageRepository } from '../repository/PageRepository'; 21 import { PageRepository } from '../repository/PageRepository';
22 import { detailedSkeleton } from './skeleton/detailSkeleton'; 22 import { detailedSkeleton } from './skeleton/detailSkeleton';
  23 +import { CommentComponent } from '../components/comment/view/CommentComponent'
23 24
24 const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; 25 const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm';
25 26
@@ -76,7 +77,6 @@ export struct ImageAndTextPageComponent { @@ -76,7 +77,6 @@ export struct ImageAndTextPageComponent {
76 Column() { 77 Column() {
77 // 点赞 78 // 点赞
78 if (this.contentDetailData[0]?.openLikes) { 79 if (this.contentDetailData[0]?.openLikes) {
79 - // 点赞  
80 Row() { 80 Row() {
81 Row() { 81 Row() {
82 if (this.newsStatusOfUser?.likeStatus === '1') { 82 if (this.newsStatusOfUser?.likeStatus === '1') {
@@ -116,13 +116,17 @@ export struct ImageAndTextPageComponent { @@ -116,13 +116,17 @@ export struct ImageAndTextPageComponent {
116 if (this.recommendList.length > 0) { 116 if (this.recommendList.length > 0) {
117 RecommendList({ recommendList: this.recommendList }) 117 RecommendList({ recommendList: this.recommendList })
118 } 118 }
  119 + // 评论
  120 + if(this.contentDetailData[0]?.openComment){
  121 +
  122 + }
119 } 123 }
120 } 124 }
121 125
122 } 126 }
123 .width(CommonConstants.FULL_WIDTH) 127 .width(CommonConstants.FULL_WIDTH)
124 .height(CommonConstants.FULL_HEIGHT) 128 .height(CommonConstants.FULL_HEIGHT)
125 - .padding({ bottom: 76 }) 129 + .padding({ bottom: 126 })
126 .scrollBar(BarState.Off) 130 .scrollBar(BarState.Off)
127 131
128 if (!this.isPageEnd) { 132 if (!this.isPageEnd) {
@@ -96,7 +96,6 @@ export struct ImageAndTextWebComponent { @@ -96,7 +96,6 @@ export struct ImageAndTextWebComponent {
96 backVisibility: false, 96 backVisibility: false,
97 onWebPrepared: this.onWebPrepared.bind(this), 97 onWebPrepared: this.onWebPrepared.bind(this),
98 isPageEnd: $isPageEnd 98 isPageEnd: $isPageEnd
99 -  
100 }) 99 })
101 } 100 }
102 } 101 }