Showing
9 changed files
with
330 additions
and
16 deletions
| @@ -9,7 +9,7 @@ export class WDRouterPage { | @@ -9,7 +9,7 @@ export class WDRouterPage { | ||
| 9 | this.pagePath = pagePath | 9 | this.pagePath = pagePath |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | - static getBundleInfo(){ | 12 | + static getBundleInfo() { |
| 13 | let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT) | 13 | let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT) |
| 14 | return `@bundle:${bundleInfo.name}/${"phone"}/${"ets/pages/MainPage"}` | 14 | return `@bundle:${bundleInfo.name}/${"phone"}/${"ets/pages/MainPage"}` |
| 15 | } | 15 | } |
| @@ -35,6 +35,8 @@ export class WDRouterPage { | @@ -35,6 +35,8 @@ export class WDRouterPage { | ||
| 35 | // 短视频详情页 | 35 | // 短视频详情页 |
| 36 | static detailVideoListPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailVideoListPage"); | 36 | static detailVideoListPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailVideoListPage"); |
| 37 | static detailPlayShortVideoPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailPlayShortVideoPage"); | 37 | static detailPlayShortVideoPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailPlayShortVideoPage"); |
| 38 | + static VideoChannelDetail = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/VideoChannelDetail"); | ||
| 39 | + static LottieViewDemo = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/LottieViewDemo"); | ||
| 38 | // 点播详情页 | 40 | // 点播详情页 |
| 39 | static detailPlayVodPage = new WDRouterPage("wdDetailPlayVod", "ets/pages/DetailPlayVodPage"); | 41 | static detailPlayVodPage = new WDRouterPage("wdDetailPlayVod", "ets/pages/DetailPlayVodPage"); |
| 40 | // 直播详情页 | 42 | // 直播详情页 |
| @@ -75,15 +77,12 @@ export class WDRouterPage { | @@ -75,15 +77,12 @@ export class WDRouterPage { | ||
| 75 | //其他普通用户 主页 | 77 | //其他普通用户 主页 |
| 76 | static otherNormalUserHomePagePage = new WDRouterPage("wdComponent", "ets/pages/OtherNormalUserHomePage"); | 78 | static otherNormalUserHomePagePage = new WDRouterPage("wdComponent", "ets/pages/OtherNormalUserHomePage"); |
| 77 | static guidePage = new WDRouterPage("wdLogin", "ets/pages/guide/GuidePages"); | 79 | static guidePage = new WDRouterPage("wdLogin", "ets/pages/guide/GuidePages"); |
| 78 | - | ||
| 79 | //隐私政策页面 | 80 | //隐私政策页面 |
| 80 | static privacyPage = new WDRouterPage("phone", "ets/pages/launchPage/PrivacyPage"); | 81 | static privacyPage = new WDRouterPage("phone", "ets/pages/launchPage/PrivacyPage"); |
| 81 | //启动广告页面 | 82 | //启动广告页面 |
| 82 | static launchAdvertisingPage = new WDRouterPage("phone", "ets/pages/launchPage/LaunchAdvertisingPage"); | 83 | static launchAdvertisingPage = new WDRouterPage("phone", "ets/pages/launchPage/LaunchAdvertisingPage"); |
| 83 | //主页 | 84 | //主页 |
| 84 | static mainPage = new WDRouterPage("phone", "ets/pages/MainPage"); | 85 | static mainPage = new WDRouterPage("phone", "ets/pages/MainPage"); |
| 85 | - | ||
| 86 | - | ||
| 87 | // static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview"); | 86 | // static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview"); |
| 88 | 87 | ||
| 89 | //播报页面 | 88 | //播报页面 |
| @@ -34,7 +34,8 @@ export { ENewspaperItemComponent } from "./src/main/ets/components/ENewspaperIte | @@ -34,7 +34,8 @@ export { ENewspaperItemComponent } from "./src/main/ets/components/ENewspaperIte | ||
| 34 | 34 | ||
| 35 | export { ENewspaperListDialog } from "./src/main/ets/dialog/ENewspaperListDialog" | 35 | export { ENewspaperListDialog } from "./src/main/ets/dialog/ENewspaperListDialog" |
| 36 | 36 | ||
| 37 | -export { MorningEveningPaperComponent } from "./src/main/ets/components/MorningEveningPaper/MorningEveningPaperComponent" | 37 | +export { MorningEveningPaperComponent |
| 38 | +} from "./src/main/ets/components/MorningEveningPaper/MorningEveningPaperComponent" | ||
| 38 | 39 | ||
| 39 | export { ImageAndTextPageComponent } from "./src/main/ets/components/ImageAndTextPageComponent" | 40 | export { ImageAndTextPageComponent } from "./src/main/ets/components/ImageAndTextPageComponent" |
| 40 | 41 | ||
| @@ -62,3 +63,4 @@ export { FirstTabTopSearchComponent } from "./src/main/ets/components/search/Fir | @@ -62,3 +63,4 @@ export { FirstTabTopSearchComponent } from "./src/main/ets/components/search/Fir | ||
| 62 | 63 | ||
| 63 | export { ListHasNoMoreDataUI } from "./src/main/ets/components/reusable/ListHasNoMoreDataUI" | 64 | export { ListHasNoMoreDataUI } from "./src/main/ets/components/reusable/ListHasNoMoreDataUI" |
| 64 | 65 | ||
| 66 | +export { LottieView } from './src/main/ets/lottie/LottieView' |
| 1 | +import lottie, { AnimationSegment } from '@ohos/lottie'; | ||
| 2 | + | ||
| 3 | +@Component | ||
| 4 | +export struct LottieView { | ||
| 5 | + @Prop name: string = '' | ||
| 6 | + @Prop path: string = '' | ||
| 7 | + @Prop lottieWidth?: number = 30 | ||
| 8 | + @Prop lottieHeight?: number = 30 | ||
| 9 | + @Prop autoplay?: boolean = false | ||
| 10 | + @Prop loop?: boolean = false | ||
| 11 | + @Prop initialSegment?: AnimationSegment = [0, 120] // 动画起始帧 | ||
| 12 | + @Prop onReady: (animateItem: ESObject) => void // 动画初始化完成事件 | ||
| 13 | + @Prop onComplete?: () => void // 动画完成事件 | ||
| 14 | + private politeChickyController: CanvasRenderingContext2D = new CanvasRenderingContext2D(); // CanvasRenderingContext2D对象 | ||
| 15 | + private animateItem: ESObject = null; // 初始化loadAnimation接口的返回对象 | ||
| 16 | + | ||
| 17 | + // 页面隐藏销毁动画 | ||
| 18 | + onPageHide(): void { | ||
| 19 | + this.animateItem.destroy() | ||
| 20 | + | ||
| 21 | + if (this.onComplete) { | ||
| 22 | + this.animateItem.removeEventListener('complete', this.onComplete) | ||
| 23 | + } | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 加载动画 | ||
| 28 | + * @param autoplay 控制动画是否自动播放参数 | ||
| 29 | + */ | ||
| 30 | + loadAnimation() { | ||
| 31 | + // 销毁动画,减少缓存 | ||
| 32 | + if (this.animateItem !== null) { | ||
| 33 | + this.animateItem.destroy(); | ||
| 34 | + this.animateItem = null; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + this.animateItem = lottie.loadAnimation({ | ||
| 38 | + container: this.politeChickyController, | ||
| 39 | + renderer: 'canvas', | ||
| 40 | + loop: this.loop, | ||
| 41 | + autoplay: this.autoplay, | ||
| 42 | + name: this.name, // 动画名称 | ||
| 43 | + path: this.path, // hap包内动画资源文件路径,仅支持json格式 | ||
| 44 | + // initialSegment: this.initialSegment | ||
| 45 | + }) | ||
| 46 | + if (this.initialSegment) { | ||
| 47 | + this.animateItem.initialSegment = this.initialSegment | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + if (this.onComplete) { | ||
| 51 | + this.animateItem.addEventListener('complete', this.onComplete) | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + build() { | ||
| 57 | + Stack({ alignContent: Alignment.TopStart }) { | ||
| 58 | + Canvas(this.politeChickyController) | ||
| 59 | + .width(this.lottieWidth) | ||
| 60 | + .height(this.lottieHeight) | ||
| 61 | + .onReady(() => { | ||
| 62 | + this.loadAnimation(); | ||
| 63 | + if (this.onReady) { | ||
| 64 | + this.onReady(this.animateItem) | ||
| 65 | + } | ||
| 66 | + }) | ||
| 67 | + .onClick(() => { | ||
| 68 | + this.animateItem.play() | ||
| 69 | + }) | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | +} |
| 1 | +import lottie, { AnimationItem, AnimationSegment } from '@ohos/lottie'; | ||
| 2 | + | ||
| 3 | +@Component | ||
| 4 | +export struct LottieView { | ||
| 5 | + @Prop name: string | ||
| 6 | + @Prop path: string | ||
| 7 | + @Prop lottieWidth: number = 30 | ||
| 8 | + @Prop lottieHeight: number = 30 | ||
| 9 | + @Prop autoplay: boolean = false | ||
| 10 | + @Prop loop: boolean = false | ||
| 11 | + @Prop initialSegment?: AnimationSegment = [0, 120] // 动画起始帧 | ||
| 12 | + @Prop onReady: (animateItem: AnimationItem | null) => void // 动画初始化完成事件 | ||
| 13 | + @Prop onComplete: () => void = () => { | ||
| 14 | + } // 动画完成事件 | ||
| 15 | + private politeChickyController: CanvasRenderingContext2D = new CanvasRenderingContext2D(); // CanvasRenderingContext2D对象 | ||
| 16 | + private animateItem: AnimationItem | null = null; // 初始化loadAnimation接口的返回对象 | ||
| 17 | + | ||
| 18 | + // 页面隐藏销毁动画 | ||
| 19 | + onPageHide(): void { | ||
| 20 | + this.animateItem?.destroy() | ||
| 21 | + | ||
| 22 | + if (this.onComplete) { | ||
| 23 | + this.animateItem?.removeEventListener('complete', this.onComplete) | ||
| 24 | + } | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 加载动画 | ||
| 29 | + * @param autoplay 控制动画是否自动播放参数 | ||
| 30 | + */ | ||
| 31 | + loadAnimation() { | ||
| 32 | + // 销毁动画,减少缓存 | ||
| 33 | + if (this.animateItem !== null) { | ||
| 34 | + this.animateItem.destroy(); | ||
| 35 | + this.animateItem = null; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + this.animateItem = lottie.loadAnimation({ | ||
| 39 | + container: this.politeChickyController, | ||
| 40 | + renderer: 'canvas', | ||
| 41 | + loop: this.loop, | ||
| 42 | + autoplay: this.autoplay, | ||
| 43 | + name: this.name, // 动画名称 | ||
| 44 | + path: this.path, // hap包内动画资源文件路径,仅支持json格式 | ||
| 45 | + // initialSegment: this.initialSegment | ||
| 46 | + }) | ||
| 47 | + if (this.initialSegment) { | ||
| 48 | + this.animateItem.segments = this.initialSegment | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + if (this.onComplete) { | ||
| 52 | + this.animateItem.addEventListener('complete', this.onComplete) | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + build() { | ||
| 58 | + Stack({ alignContent: Alignment.TopStart }) { | ||
| 59 | + Canvas(this.politeChickyController) | ||
| 60 | + .width(this.lottieWidth) | ||
| 61 | + .height(this.lottieHeight) | ||
| 62 | + .backgroundColor(Color.Black) | ||
| 63 | + .onReady(() => { | ||
| 64 | + this.loadAnimation(); | ||
| 65 | + if (this.onReady) { | ||
| 66 | + this.onReady(this.animateItem) | ||
| 67 | + } | ||
| 68 | + }) | ||
| 69 | + .onClick(() => { | ||
| 70 | + this.animateItem?.play() | ||
| 71 | + }) | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | +} |
| @@ -83,6 +83,9 @@ export struct DetailVideoListPage { | @@ -83,6 +83,9 @@ export struct DetailVideoListPage { | ||
| 83 | 83 | ||
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | + /** | ||
| 87 | + * 查询视频列表用于翻页 | ||
| 88 | + */ | ||
| 86 | async queryVideoList() { | 89 | async queryVideoList() { |
| 87 | await ContentDetailRequest.postRecommendVideoList({ | 90 | await ContentDetailRequest.postRecommendVideoList({ |
| 88 | pageSize: 5, | 91 | pageSize: 5, |
| @@ -110,15 +113,6 @@ export struct DetailVideoListPage { | @@ -110,15 +113,6 @@ export struct DetailVideoListPage { | ||
| 110 | }.width('100%') | 113 | }.width('100%') |
| 111 | .height('100%') | 114 | .height('100%') |
| 112 | }, (item: ContentDetailDTO) => item.newsId + '') | 115 | }, (item: ContentDetailDTO) => item.newsId + '') |
| 113 | - | ||
| 114 | - // ForEach(this.testData, (item: string, index: number) => { | ||
| 115 | - // Column() { | ||
| 116 | - // Test({ currentItem: item, currentIndex: this.currentIndex, index: index }) | ||
| 117 | - // } | ||
| 118 | - // .width('100%') | ||
| 119 | - // .height('100%') | ||
| 120 | - // }, (item: string) => item) | ||
| 121 | - | ||
| 122 | } | 116 | } |
| 123 | .cachedCount(-1) | 117 | .cachedCount(-1) |
| 124 | .indicator(false) | 118 | .indicator(false) |
| @@ -126,7 +120,8 @@ export struct DetailVideoListPage { | @@ -126,7 +120,8 @@ export struct DetailVideoListPage { | ||
| 126 | .loop(false) | 120 | .loop(false) |
| 127 | .width('100%') | 121 | .width('100%') |
| 128 | .height('100%') | 122 | .height('100%') |
| 129 | - | 123 | + // 扩展至所有非安全区域 |
| 124 | + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | ||
| 130 | .onChange((index: number) => { | 125 | .onChange((index: number) => { |
| 131 | this.currentIndex = index | 126 | this.currentIndex = index |
| 132 | console.info('onChange==', index.toString()) | 127 | console.info('onChange==', index.toString()) |
| 1 | +import { AnimationItem } from '@ohos/lottie' | ||
| 2 | +import { LottieView } from 'wdComponent/Index' | ||
| 3 | + | ||
| 4 | + | ||
| 5 | +@Component | ||
| 6 | +export struct LottieViewDemo { | ||
| 7 | + @State | ||
| 8 | + animateItem: AnimationItem | null = null | ||
| 9 | + | ||
| 10 | + build() { | ||
| 11 | + Column() { | ||
| 12 | + Text('点击开始') | ||
| 13 | + .fontSize(30) | ||
| 14 | + .backgroundColor(Color.Blue) | ||
| 15 | + .padding(20) | ||
| 16 | + .fontColor(Color.White) | ||
| 17 | + .borderRadius(10) | ||
| 18 | + .fontWeight(500) | ||
| 19 | + LottieView({ | ||
| 20 | + name: 'lottieDemo', | ||
| 21 | + path: 'common/lottie/politeChicky.json', | ||
| 22 | + onReady: (animateItem: AnimationItem | null) => { | ||
| 23 | + this.animateItem = animateItem | ||
| 24 | + }, | ||
| 25 | + onComplete: () => { | ||
| 26 | + console.log('onComplete===') | ||
| 27 | + } | ||
| 28 | + }) | ||
| 29 | + } | ||
| 30 | + .width(200) | ||
| 31 | + .height(200) | ||
| 32 | + .alignItems(HorizontalAlign.Center) | ||
| 33 | + .backgroundImageSize(ImageSize.Cover) | ||
| 34 | + | ||
| 35 | + } | ||
| 36 | +} |
| 1 | +import { Action, ContentDetailDTO, InteractDataDTO } from 'wdBean/Index'; | ||
| 2 | +import { ContentDetailRequest } from 'wdDetailPlayApi/Index' | ||
| 3 | +import { ResponseDTO } from 'wdNetwork/Index'; | ||
| 4 | +import { DetailPlayShortVideoPage } from './DetailPlayShortVideoPage' | ||
| 5 | +import { Test } from './Test' | ||
| 6 | +import router from '@ohos.router'; | ||
| 7 | +import window from '@ohos.window'; | ||
| 8 | +import { contentListParams } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; | ||
| 9 | + | ||
| 10 | +@Entry | ||
| 11 | +@Component | ||
| 12 | +export struct VideoChannelDetail { | ||
| 13 | + private contentId: string = '' | ||
| 14 | + private relId: string = '' | ||
| 15 | + private relType: string = '' | ||
| 16 | + private swiperController: SwiperController = new SwiperController() | ||
| 17 | + @State data: ContentDetailDTO[] = [] | ||
| 18 | + @State testData: string[] = ['111', '222', '333'] | ||
| 19 | + @State currentIndex: number = 0 | ||
| 20 | + @State interactDataList: InteractDataDTO[] = [] | ||
| 21 | + | ||
| 22 | + async aboutToAppear(): Promise<void> { | ||
| 23 | + let data: ContentDetailDTO[] = [] | ||
| 24 | + let action: Action = router.getParams() as Action | ||
| 25 | + if (action) { | ||
| 26 | + this.contentId = action.params?.contentID || '' | ||
| 27 | + if (action.params && action.params.extra) { | ||
| 28 | + this.relId = action.params.extra.relId || '' | ||
| 29 | + this.relType = action.params.extra.relType || '' | ||
| 30 | + } | ||
| 31 | + await ContentDetailRequest.getContentDetail({ | ||
| 32 | + contentId: this.contentId, | ||
| 33 | + relId: this.relId, | ||
| 34 | + relType: this.relType | ||
| 35 | + }).then((resDTO: ResponseDTO<ContentDetailDTO[]>) => { | ||
| 36 | + console.error('resDTO==', JSON.stringify(resDTO.data)) | ||
| 37 | + if (resDTO.data) { | ||
| 38 | + this.data.push(resDTO.data[0]) | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + }) | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + await this.queryVideoList() | ||
| 45 | + | ||
| 46 | + // await ContentDetailRequest.postRecommendVideoList({ | ||
| 47 | + // pageSize: 5, | ||
| 48 | + // refreshCnt: 1 | ||
| 49 | + // }).then(res => { | ||
| 50 | + // if (res.data) { | ||
| 51 | + // data = data.concat(res.data) | ||
| 52 | + // } | ||
| 53 | + // console.log('res1===', JSON.stringify(res)) | ||
| 54 | + // console.log('res==' + this.data) | ||
| 55 | + // }) | ||
| 56 | + | ||
| 57 | + | ||
| 58 | + if (this.data.length > 0) { | ||
| 59 | + const params: contentListParams = { | ||
| 60 | + contentList: [] | ||
| 61 | + } | ||
| 62 | + this.data.map(item => { | ||
| 63 | + params.contentList.push({ | ||
| 64 | + contentId: item.newsId + '', | ||
| 65 | + contentType: item.newsType | ||
| 66 | + }) | ||
| 67 | + }) | ||
| 68 | + // 批量查询内容当前用户点赞、收藏状态 | ||
| 69 | + await ContentDetailRequest.getContentInteract(params).then(res => { | ||
| 70 | + if (res.data) { | ||
| 71 | + this.interactDataList = res.data || [] | ||
| 72 | + } | ||
| 73 | + console.log('获取互动点赞等数据===', JSON.stringify(res)) | ||
| 74 | + }) | ||
| 75 | + // 查询各类型内容动态数据接口V2 | ||
| 76 | + | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + // this.data = data | ||
| 80 | + console.error('aboutToAppear===', this.data.length) | ||
| 81 | + | ||
| 82 | + | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * 查询视频列表用于翻页 | ||
| 87 | + */ | ||
| 88 | + async queryVideoList() { | ||
| 89 | + await ContentDetailRequest.postRecommendVideoList({ | ||
| 90 | + pageSize: 5, | ||
| 91 | + refreshCnt: 1 | ||
| 92 | + }).then(res => { | ||
| 93 | + if (res.data) { | ||
| 94 | + this.data = this.data.concat(res.data) | ||
| 95 | + } | ||
| 96 | + // console.log('queryVideoList===', JSON.stringify(this.data)) | ||
| 97 | + }) | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + build() { | ||
| 101 | + Column() { | ||
| 102 | + Swiper(this.swiperController) { | ||
| 103 | + | ||
| 104 | + ForEach(this.data, (item: ContentDetailDTO, index: number) => { | ||
| 105 | + Column() { | ||
| 106 | + DetailPlayShortVideoPage({ | ||
| 107 | + contentDetailData: item, | ||
| 108 | + currentIndex: this.currentIndex, | ||
| 109 | + index: index, | ||
| 110 | + interactData: this.interactDataList[index] | ||
| 111 | + }) | ||
| 112 | + }.width('100%') | ||
| 113 | + .height('100%') | ||
| 114 | + }, (item: ContentDetailDTO) => item.newsId + '') | ||
| 115 | + } | ||
| 116 | + .cachedCount(-1) | ||
| 117 | + .indicator(false) | ||
| 118 | + .vertical(true) | ||
| 119 | + .loop(false) | ||
| 120 | + .width('100%') | ||
| 121 | + .height('100%') | ||
| 122 | + // 扩展至所有非安全区域 | ||
| 123 | + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | ||
| 124 | + .onChange((index: number) => { | ||
| 125 | + this.currentIndex = index | ||
| 126 | + console.info('onChange==', index.toString()) | ||
| 127 | + | ||
| 128 | + if (this.currentIndex === this.data.length - 1) { | ||
| 129 | + this.queryVideoList() | ||
| 130 | + } | ||
| 131 | + }) | ||
| 132 | + | ||
| 133 | + }.width('100%').height('100%') | ||
| 134 | + } | ||
| 135 | +} |
sight_harmony/features/wdDetailPlayShortVideo/src/main/resources/base/media/politeChicky.json
0 → 100644
This diff could not be displayed because it is too large.
-
Please register or login to post a comment