From ce439d42224e4fec768c72ceec7d450f1bccfe63 Mon Sep 17 00:00:00 2001 From: xiaoxiao Date: Fri, 30 May 2025 11:45:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A0=8F=E5=8F=B3=E4=BE=A7?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=B7=BB=E5=8A=A0=E6=9E=84=E5=BB=BA=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=92=8C=E5=85=B6=E4=BB=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/components/HdSearchNav.ets | 80 +++++++++++++++++++ .../src/main/ets/constants/BasicConstant.ets | 5 +- .../src/main/ets/components/SwiperComp.ets | 58 ++++++++++---- .../ets/components/VideoDetailsComment.ets | 2 +- .../Home/src/main/ets/pages/PastVideo.ets | 7 +- .../Home/src/main/ets/pages/VideoGandan.ets | 15 ++-- .../src/main/ets/view/PerfectUserDataComp.ets | 8 +- .../main/ets/view/SelectedHospitalComp.ets | 2 +- .../ets/pages/SearchPage/VideoSearchPage.ets | 27 +++++++ .../ets/pages/VideoPage/CommentReplyPage.ets | 16 +--- .../PLVMediaPlayerSingleVideoPage.ets | 4 +- .../resources/base/profile/main_pages.json | 3 +- 12 files changed, 181 insertions(+), 46 deletions(-) create mode 100644 commons/basic/src/main/ets/components/HdSearchNav.ets create mode 100644 products/expert/src/main/ets/pages/SearchPage/VideoSearchPage.ets diff --git a/commons/basic/src/main/ets/components/HdSearchNav.ets b/commons/basic/src/main/ets/components/HdSearchNav.ets new file mode 100644 index 0000000..ee20483 --- /dev/null +++ b/commons/basic/src/main/ets/components/HdSearchNav.ets @@ -0,0 +1,80 @@ +import { router } from '@kit.ArkUI' +import { emitter } from '@kit.BasicServicesKit' +import { BasicConstant } from '../../../../Index' + +@Component +export struct HdSearchNav { + private rightItemAction: (value: string) => void = () => {}; + @StorageProp('topHeight') + topHeight: number = 0 + @Prop + bgColor: ResourceStr = $r('app.color.top_bg') + @Prop + hasBorder: boolean = false + @Prop + leftIcon: ResourceStr = $r('app.media.top_back') + @Prop + showRightIcon: boolean = true + @Prop + rightIcon: ResourceStr + @Prop + showRightText: boolean = false + @Prop + rightText: string = '' + @Prop + rightTextColor: ResourceStr + @Prop + rightbackColor: ResourceStr = $r('app.color.main_color') + + @State textInputContent:string = '' + + build() { + Row() { + Row() { + Image(this.leftIcon) + .size({ width: 24, height: 24 }) + .onClick(() => router.back()) + .fillColor($r('app.color.black')) + }.size({ width: 50, height: 50 }) + + Row({space:10}){ + Image($r('app.media.selected_hospital_ws')) + .width(25).height(25) + .margin({left:15}) + TextInput({placeholder:'搜索视频、过往会议'}) + .fontSize(15) + .margin({left:10}) + .onChange((value:string)=>{ + this.textInputContent = value; + }) + } + .borderWidth(0.5).borderRadius(3).borderColor($r('app.color.main_color')).justifyContent(FlexAlign.Start) + + if (this.showRightIcon) { + Row() { + Image(this.rightIcon) + .size({ width: 24, height: 24 }) + .objectFit(ImageFit.Contain) + .onClick(()=>this.rightItemAction(this.textInputContent)) + } + .size({ width: 50, height: 50 }).justifyContent(FlexAlign.End) + } else if (this.showRightText) { + Text(this.rightText) + .fontSize(16) + .fontColor(this.rightTextColor) + .backgroundColor(this.rightbackColor) + .borderRadius(4) + .onClick(()=>this.rightItemAction(this.textInputContent)) + .width(50) + .textAlign(TextAlign.Center) + } else { + Blank() + .width(50) + } + } + .padding({ left: 16, right: 16, top: this.topHeight }) + .height(56 + this.topHeight) + .width('100%') + .backgroundColor(this.bgColor) + } +} \ No newline at end of file diff --git a/commons/basic/src/main/ets/constants/BasicConstant.ets b/commons/basic/src/main/ets/constants/BasicConstant.ets index d8ef8c3..14c2419 100644 --- a/commons/basic/src/main/ets/constants/BasicConstant.ets +++ b/commons/basic/src/main/ets/constants/BasicConstant.ets @@ -45,4 +45,7 @@ export class BasicConstant { '广西壮族自治区','海南省','重庆市','四川省','贵州省','云南省','西藏自治区', '陕西省','甘肃省','宁夏回族自治区','新疆维吾尔自治区','台湾省','香港特别行政区','澳门特别行政区'] -} \ No newline at end of file + //通知事件ID + static readonly notification_back_refreshData = 250529;//返回上页通知刷新数据 +} + diff --git a/features/Home/src/main/ets/components/SwiperComp.ets b/features/Home/src/main/ets/components/SwiperComp.ets index 7fa2118..26cce57 100644 --- a/features/Home/src/main/ets/components/SwiperComp.ets +++ b/features/Home/src/main/ets/components/SwiperComp.ets @@ -4,18 +4,19 @@ import { promptAction, router } from '@kit.ArkUI' import { BusinessError } from '@kit.BasicServicesKit'; import { HdLoadingDialog } from '@itcast/basic' import HashMap from '@ohos.util.HashMap'; - +import { VideoDetailModel } from '../model/VideoDetailModel' +import { PLVMockMediaResourceData } from '../polyv/PLVMockMediaResourceData' +import { + PLVMediaPlayerSingleVideoPageParam +} from 'media-player-common'; +import { runCatching, seconds } from '@polyvharmony/media-player-sdk'; +import { it } from '@ohos/hypium'; @Component export struct SwiperComp { @State list: VideoRoll[] = [] - - - - hashMap: HashMap = new HashMap(); - dialog: CustomDialogController = new CustomDialogController({ builder: HdLoadingDialog({ message: '加载中...' }), customStyle: true, @@ -26,16 +27,15 @@ export struct SwiperComp { this.initData() } - initData() - { + initData() { + const hashMap: HashMap = new HashMap(); this.dialog.open() - this.hashMap.clear(); - hdHttp.httpReq(BasicConstant.videoRoll,this.hashMap).then(async (res: HdResponse) => { + hashMap.clear(); + hdHttp.httpReq(BasicConstant.videoRoll,hashMap).then(async (res: HdResponse) => { logger.info('Response meetingListV2'+res); let json:VideoRollModel = JSON.parse(res+'') as VideoRollModel; this.dialog.close(); this.list = json.data - }).catch((err: BusinessError) => { this.dialog.close(); }) @@ -61,10 +61,9 @@ export struct SwiperComp { .padding({right:100,left:5}) .margin({ bottom: 0 }) }.onClick(()=>{ - + this.getVideoDetail(item.uuid); }) }, (item: VideoRoll) => JSON.stringify(item)) - } .indicator( Indicator.dot() @@ -82,10 +81,39 @@ export struct SwiperComp { .onChange((index: number) => { }) - - } .width('100%') + } + getVideoDetail(video_uuid:string) { + const hashMap: HashMap = new HashMap(); + hashMap.clear(); + hashMap.set('video_uuid', video_uuid) + hdHttp.httpReq(BasicConstant.videoDetail,hashMap).then(async (res: HdResponse) => { + logger.info('Response videoDetail'+res); + let json:VideoDetailModel = JSON.parse(res+'') as VideoDetailModel; + this.goPLVMediaPlayerSingleVideoPage(json.video.polyv_uuid,video_uuid) + }).catch((err: BusinessError) => { + this.goPLVMediaPlayerSingleVideoPage('','') + }) + } + + async goPLVMediaPlayerSingleVideoPage(vid:string,video_uuid:string) { + const mediaResourcesResult = await runCatching(PLVMockMediaResourceData.getInstance().setupMediaResourcesFromLocal(vid)) + if (mediaResourcesResult.success === false) { + promptAction.showToast({ + message: `'视频数据初始化失败': ${mediaResourcesResult.error}`, + duration: seconds(3).toMillis() + }) + return + } + const mediaResource = mediaResourcesResult.data[0] + router.pushUrl({ + url:'pages/VideoPage/PLVMediaPlayerSingleVideoPage', + params: { + video_uuid:video_uuid, + param:new PLVMediaPlayerSingleVideoPageParam(mediaResource) + } + }) } } \ No newline at end of file diff --git a/features/Home/src/main/ets/components/VideoDetailsComment.ets b/features/Home/src/main/ets/components/VideoDetailsComment.ets index 1388a03..d30beab 100644 --- a/features/Home/src/main/ets/components/VideoDetailsComment.ets +++ b/features/Home/src/main/ets/components/VideoDetailsComment.ets @@ -24,7 +24,7 @@ export struct VideoDetailsComment { .then((response) => { if (response.statusCode == 200) { emitter.emit({ - eventId: 250529, + eventId: BasicConstant.notification_back_refreshData, priority: emitter.EventPriority.HIGH }) promptAction.showToast({ message: '删除评论成功', duration: 1000 }) diff --git a/features/Home/src/main/ets/pages/PastVideo.ets b/features/Home/src/main/ets/pages/PastVideo.ets index 5a21be9..c79370f 100644 --- a/features/Home/src/main/ets/pages/PastVideo.ets +++ b/features/Home/src/main/ets/pages/PastVideo.ets @@ -1,4 +1,4 @@ -import { HdNav } from '@itcast/basic' +import { HdNav, BasicConstant } from '@itcast/basic' import { ListCompPast } from '../components/ListCompPast' import { promptAction } from '@kit.ArkUI' @Entry @@ -25,13 +25,14 @@ export struct PastVideo { } aboutToAppear(): void { this.getYears() - } build() { Column() { - HdNav({ title: '过往会议', showRightIcon: false, showLeftIcon: true}) + HdNav({ title: '过往会议', showRightIcon: false, showLeftIcon: true,showRightText:true,rightIcon:$r('app.media.selected_hospital_ws'),rightItemAction:()=>{ + + }}) Row() { Row() { if(this.timePosition!=-1) diff --git a/features/Home/src/main/ets/pages/VideoGandan.ets b/features/Home/src/main/ets/pages/VideoGandan.ets index c100947..8446dbc 100644 --- a/features/Home/src/main/ets/pages/VideoGandan.ets +++ b/features/Home/src/main/ets/pages/VideoGandan.ets @@ -1,19 +1,22 @@ import { SecondaryLink } from '../components/SecondaryLink'; import router from '@ohos.router'; -import { HdNav } from '@itcast/basic' +import { BasicConstant, HdNav } from '@itcast/basic' import { SwiperComp } from '../components/SwiperComp' - +import { emitter } from '@kit.BasicServicesKit'; @Component export struct VideoGandan { - build() { + build() { Column() { - HdNav({ title: '肝胆视频', showRightIcon: false, showLeftIcon: false }) + HdNav({ title: '肝胆视频', showRightIcon: true, showLeftIcon: false,showRightText:false,rightIcon:$r('app.media.selected_hospital_ws'),rightItemAction:()=>{ + router.pushUrl({ + url:'pages/SearchPage/VideoSearchPage', + params:{'pageName':'视频'} + }) + }}) SwiperComp() SecondaryLink() - - }.width('100%') .height('100%').backgroundColor($r('app.color.top_bg')) } diff --git a/features/register/src/main/ets/view/PerfectUserDataComp.ets b/features/register/src/main/ets/view/PerfectUserDataComp.ets index e91ce4c..450c336 100644 --- a/features/register/src/main/ets/view/PerfectUserDataComp.ets +++ b/features/register/src/main/ets/view/PerfectUserDataComp.ets @@ -97,11 +97,11 @@ export struct PerfectUserDataComp { this.handleState() // logger.info("Response this.photoPath "+this.photoPath) - emitter.on({ eventId: 250516 }, () => { + emitter.on({ eventId: 12 }, () => { this.handleSave() }) // 收到eventId为1的事件后执行回调函数 - emitter.on({ eventId: 250517 }, (eventData: emitter.EventData) => { + emitter.on({ eventId: BasicConstant.notification_back_refreshData }, (eventData: emitter.EventData) => { console.info(`eventData: ${JSON.stringify(eventData)}`); const params =eventData.data as Record; // 获取传递过来的参数对象 this.hospatilName=params.name @@ -114,8 +114,8 @@ export struct PerfectUserDataComp { } aboutToDisappear() { - emitter.off(250516) - emitter.off(250517) + emitter.off(12) + emitter.off(BasicConstant.notification_back_refreshData) } private handleState() diff --git a/features/register/src/main/ets/view/SelectedHospitalComp.ets b/features/register/src/main/ets/view/SelectedHospitalComp.ets index 5d8c093..d2b6b01 100644 --- a/features/register/src/main/ets/view/SelectedHospitalComp.ets +++ b/features/register/src/main/ets/view/SelectedHospitalComp.ets @@ -141,7 +141,7 @@ export struct SelectedHospitalComp { data: item }; // 发送eventId为1的事件,事件内容为eventData。 - emitter.emit({ eventId: 250517 }, eventData); + emitter.emit({ eventId: BasicConstant.notification_back_refreshData }, eventData); router.back({ url: 'pages/LoginPage/LoginSetInfoPage'}) // router.back({ url: 'pages/LoginPage/LoginSetInfoPage',params: item}) diff --git a/products/expert/src/main/ets/pages/SearchPage/VideoSearchPage.ets b/products/expert/src/main/ets/pages/SearchPage/VideoSearchPage.ets new file mode 100644 index 0000000..7cb4a38 --- /dev/null +++ b/products/expert/src/main/ets/pages/SearchPage/VideoSearchPage.ets @@ -0,0 +1,27 @@ +import { HdNav } from '@itcast/basic' + +@Entry +@Component +struct VideoSearchPage { + @State message: string = 'Hello World'; + + build() { + Column() { + // HdNav({showLeftIcon:true,showRightText:true,rightText:'搜索'}) + Text(this.message) + .id('VideoSearchPageHelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + .backgroundColor(Color.White) + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/VideoPage/CommentReplyPage.ets b/products/expert/src/main/ets/pages/VideoPage/CommentReplyPage.ets index 62c1404..cbccf5f 100644 --- a/products/expert/src/main/ets/pages/VideoPage/CommentReplyPage.ets +++ b/products/expert/src/main/ets/pages/VideoPage/CommentReplyPage.ets @@ -13,16 +13,6 @@ struct CommentReplyPage { @State finalContent: string = ''; hashMap: HashMap = new HashMap(); - aboutToAppear() { - emitter.on({ eventId: 250516 }, () => { - this.commitAction() - }) - } - - aboutToDisappear() { - emitter.off(250516) - } - commitAction() { inputMethod.getController().hideTextInput();//关闭键盘 if (this.finalContent.length === 0) { @@ -38,7 +28,7 @@ struct CommentReplyPage { let json:CommentV2Model = JSON.parse(res+'') as CommentV2Model; if(json.code == 200) { emitter.emit({ - eventId: 250529, + eventId: BasicConstant.notification_back_refreshData, priority: emitter.EventPriority.HIGH }) promptAction.showToast({ message: '回复评论成功', duration: 1000 }) @@ -52,7 +42,9 @@ struct CommentReplyPage { build() { Column() { - HdNav({ title: '回复', showRightIcon: false, showLeftIcon: true,showRightText:true,rightText:'确定'}) + HdNav({ title: '回复', showRightIcon: false, showLeftIcon: true,showRightText:true,rightText:'确定',rightItemAction:()=>{ + this.commitAction() + }}) TextArea({placeholder:`回复:${this.params.replyName}`}) .fontSize(14) .width('100%') diff --git a/products/expert/src/main/ets/pages/VideoPage/PLVMediaPlayerSingleVideoPage.ets b/products/expert/src/main/ets/pages/VideoPage/PLVMediaPlayerSingleVideoPage.ets index 7d899cb..55fad95 100644 --- a/products/expert/src/main/ets/pages/VideoPage/PLVMediaPlayerSingleVideoPage.ets +++ b/products/expert/src/main/ets/pages/VideoPage/PLVMediaPlayerSingleVideoPage.ets @@ -56,7 +56,7 @@ export struct PLVMediaPlayerSingleVideoPage { } }) - emitter.on({ eventId: 250529 }, () => { + emitter.on({ eventId: BasicConstant.notification_back_refreshData }, () => { this.getCommentdata(this.params.video_uuid) }) } @@ -184,7 +184,7 @@ export struct PLVMediaPlayerSingleVideoPage { windowInstance.setWindowKeepScreenOn(false) }) - emitter.off(250529) + emitter.off(BasicConstant.notification_back_refreshData) } getVideoDetail(video_uuid:string) { diff --git a/products/expert/src/main/resources/base/profile/main_pages.json b/products/expert/src/main/resources/base/profile/main_pages.json index 6467180..2357591 100644 --- a/products/expert/src/main/resources/base/profile/main_pages.json +++ b/products/expert/src/main/resources/base/profile/main_pages.json @@ -25,6 +25,7 @@ "pages/WebView/LivebroadcastPages", "pages/VideoPage/PastVideoPage", "pages/VideoPage/VideoGandanPage", - "pages/VideoPage/CommentReplyPage" + "pages/VideoPage/CommentReplyPage", + "pages/SearchPage/VideoSearchPage" ] } \ No newline at end of file