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

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