导航栏右侧按钮添加构建函数和其他

This commit is contained in:
xiaoxiao 2025-05-30 11:45:04 +08:00
parent e31432bc3a
commit ce439d4222
12 changed files with 181 additions and 46 deletions

View File

@ -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)
}
}

View File

@ -45,4 +45,7 @@ export class BasicConstant {
'广西壮族自治区','海南省','重庆市','四川省','贵州省','云南省','西藏自治区',
'陕西省','甘肃省','宁夏回族自治区','新疆维吾尔自治区','台湾省','香港特别行政区','澳门特别行政区']
}
//通知事件ID
static readonly notification_back_refreshData = 250529;//返回上页通知刷新数据
}

View File

@ -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<string, string> = 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<string, string> = new HashMap();
this.dialog.open()
this.hashMap.clear();
hdHttp.httpReq<string>(BasicConstant.videoRoll,this.hashMap).then(async (res: HdResponse<string>) => {
hashMap.clear();
hdHttp.httpReq<string>(BasicConstant.videoRoll,hashMap).then(async (res: HdResponse<string>) => {
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<string, string> = new HashMap();
hashMap.clear();
hashMap.set('video_uuid', video_uuid)
hdHttp.httpReq<string>(BasicConstant.videoDetail,hashMap).then(async (res: HdResponse<string>) => {
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)
}
})
}
}

View File

@ -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 })

View File

@ -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)

View File

@ -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'))
}

View File

@ -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<string, string>; // 获取传递过来的参数对象
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()

View File

@ -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})

View File

@ -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)
}
}

View File

@ -13,16 +13,6 @@ struct CommentReplyPage {
@State finalContent: string = '';
hashMap: HashMap<string, string> = 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%')

View File

@ -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) {

View File

@ -25,6 +25,7 @@
"pages/WebView/LivebroadcastPages",
"pages/VideoPage/PastVideoPage",
"pages/VideoPage/VideoGandanPage",
"pages/VideoPage/CommentReplyPage"
"pages/VideoPage/CommentReplyPage",
"pages/SearchPage/VideoSearchPage"
]
}