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
yuzhilin
2024-04-25 19:37:13 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
43df685a716547d53473236bd896b092df0fb3db
43df685a
1 parent
fa5f8a4c
稿件详情视频播放
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
9 deletions
sight_harmony/commons/wdJsBridge/src/main/ets/bean/Message.ets
sight_harmony/commons/wdWebComponent/src/main/ets/pages/WdWebLocalComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextWebComponent.ets
sight_harmony/commons/wdJsBridge/src/main/ets/bean/Message.ets
View file @
43df685
...
...
@@ -21,6 +21,12 @@ interface dataObject {
method?: string
url?: string
parameters?: object
videoUrl?: string
positionWidth?: string
positionHeight?: string
positionLeft?: string
positionTop?: string
videoLandscape?: string
}
/**
...
...
sight_harmony/commons/wdWebComponent/src/main/ets/pages/WdWebLocalComponent.ets
View file @
43df685
import router from '@ohos.router';
import { Bridge
Handler, Bridge
Util, BridgeWebViewControl, Callback } from 'wdJsBridge';
import { BridgeUtil, BridgeWebViewControl, Callback } from 'wdJsBridge';
import { Logger } from 'wdKit/Index';
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';
...
...
@@ -12,11 +10,18 @@ const TAG = 'WdWebLocalComponent';
@Component
export struct WdWebLocalComponent {
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
onWebPrepared: () => void = () => {}
onWebPrepared: () => void = () => {
}
@Prop backVisibility: boolean = false
@Prop webResource: Resource = {} as Resource
@State webHeight: string | number = '100%'
@Link isPageEnd: boolean
@State videoUrl: string = ''
@State positionWidth: number = 0
@State positionHeight: number = 0
@State positionLeft: number = 0
@State positionTop: number = 0
@State videoLandscape: string = '1'
build() {
Column() {
...
...
@@ -33,6 +38,8 @@ export struct WdWebLocalComponent {
.height(44)
.visibility(this.backVisibility ? Visibility.Visible : Visibility.None)
Row() {
RelativeContainer() {
Web({ src: this.webResource, controller: this.webviewControl })
.domStorageAccess(true)
.databaseAccess(true)
...
...
@@ -64,6 +71,30 @@ export struct WdWebLocalComponent {
}
return this.onLoadIntercept(event.data.getRequestUrl().toString());
})
.id('web')
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
})
if (this.videoUrl) {
Video({ src: this.videoUrl })
.autoPlay(true)
.width(this.positionWidth)
.height(this.positionHeight)
.borderRadius(5)
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
})
.offset({
x: this.positionLeft,
y: this.positionTop
})
.id("video")
}
}
}.width('100%')
.height(this.webHeight)
}
}
...
...
@@ -73,7 +104,8 @@ export struct WdWebLocalComponent {
let handleName = H5CallNativeType.JsCallTypeList[i];
let handle = (data: Message, f: Callback) => {
Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data.data))
this.setCurrentPageOperate(data)
this.setCurrentPageOperate8(data)
this.setCurrentPageOperate9(data)
this.defaultPerformJSCallNative(data, f)
};
this.webviewControl.registerHandler(handleName, { handle: handle });
...
...
@@ -81,7 +113,7 @@ export struct WdWebLocalComponent {
}
//webview 高度设置
private setCurrentPageOperate: (data: Message) => void = (data) => {
private setCurrentPageOperate
8
: (data: Message) => void = (data) => {
if (data.handlerName === H5CallNativeType.jsCall_currentPageOperate && data?.data?.operateType === '8') {
if (typeof this.webHeight === 'number') {
if (Number(data?.data?.webViewHeight) > this.webHeight) {
...
...
@@ -93,6 +125,17 @@ export struct WdWebLocalComponent {
}
}
}
//播放视频
private setCurrentPageOperate9: (data: Message) => void = (data) => {
if (data.handlerName === H5CallNativeType.jsCall_currentPageOperate && data?.data?.operateType === '9') {
this.videoUrl = data?.data?.videoUrl || ''
this.positionWidth = Number(data?.data?.positionWidth) || 0
this.positionHeight = Number(data?.data?.positionHeight) || 0
this.positionLeft = Number(data?.data?.positionLeft) || 0
this.positionTop = Number(data?.data?.positionTop) || 0
this.videoLandscape = data?.data?.videoLandscape || '1'
}
}
/**
* 默认【CallNative】逻辑处理
*/
...
...
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
View file @
43df685
...
...
@@ -20,6 +20,7 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
import { PageRepository } from '../repository/PageRepository';
import { detailedSkeleton } from './skeleton/detailSkeleton';
import { CommentComponent } from '../components/comment/view/CommentComponent'
const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm';
...
...
@@ -76,7 +77,6 @@ export struct ImageAndTextPageComponent {
Column() {
// 点赞
if (this.contentDetailData[0]?.openLikes) {
// 点赞
Row() {
Row() {
if (this.newsStatusOfUser?.likeStatus === '1') {
...
...
@@ -116,13 +116,17 @@ export struct ImageAndTextPageComponent {
if (this.recommendList.length > 0) {
RecommendList({ recommendList: this.recommendList })
}
// 评论
if(this.contentDetailData[0]?.openComment){
}
}
}
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
.padding({ bottom:
7
6 })
.padding({ bottom:
12
6 })
.scrollBar(BarState.Off)
if (!this.isPageEnd) {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextWebComponent.ets
View file @
43df685
...
...
@@ -96,7 +96,6 @@ export struct ImageAndTextWebComponent {
backVisibility: false,
onWebPrepared: this.onWebPrepared.bind(this),
isPageEnd: $isPageEnd
})
}
}
...
...
Please
register
or
login
to post a comment