Showing
4 changed files
with
20 additions
and
48 deletions
| @@ -186,8 +186,8 @@ export struct CardParser { | @@ -186,8 +186,8 @@ export struct CardParser { | ||
| 186 | contentDTO: contentDTO, | 186 | contentDTO: contentDTO, |
| 187 | compDTO: this.compDTO, | 187 | compDTO: this.compDTO, |
| 188 | pageId: this.pageId, | 188 | pageId: this.pageId, |
| 189 | - pageName: this.pageName | ||
| 190 | - | 189 | + pageName: this.pageName, |
| 190 | + index:this.compIndex | ||
| 191 | }) | 191 | }) |
| 192 | } else { | 192 | } else { |
| 193 | // todo:组件未实现 / Component Not Implemented | 193 | // todo:组件未实现 / Component Not Implemented |
| @@ -19,7 +19,7 @@ export struct LiveBigImage02Component { | @@ -19,7 +19,7 @@ export struct LiveBigImage02Component { | ||
| 19 | @State contentDTO: ContentDTO = new ContentDTO(); | 19 | @State contentDTO: ContentDTO = new ContentDTO(); |
| 20 | @State loadImg: boolean = false; | 20 | @State loadImg: boolean = false; |
| 21 | @State clicked: boolean = false; | 21 | @State clicked: boolean = false; |
| 22 | - | 22 | + index: number = 0 |
| 23 | async aboutToAppear() { | 23 | async aboutToAppear() { |
| 24 | const curRouter = router.getState().name; | 24 | const curRouter = router.getState().name; |
| 25 | this.clicked = hasClicked(this.contentDTO.objectId,curRouter) | 25 | this.clicked = hasClicked(this.contentDTO.objectId,curRouter) |
| @@ -102,8 +102,7 @@ export struct LiveBigImage02Component { | @@ -102,8 +102,7 @@ export struct LiveBigImage02Component { | ||
| 102 | lottieWidth: 14, | 102 | lottieWidth: 14, |
| 103 | lottieHeight: 14, | 103 | lottieHeight: 14, |
| 104 | autoplay: true, | 104 | autoplay: true, |
| 105 | - loop: true, | ||
| 106 | - title: item.newsTitle | 105 | + loop: true |
| 107 | }) | 106 | }) |
| 108 | .margin({ | 107 | .margin({ |
| 109 | right: '2vp' | 108 | right: '2vp' |
| @@ -14,28 +14,16 @@ export struct LottieView { | @@ -14,28 +14,16 @@ export struct LottieView { | ||
| 14 | private politeChickyController: CanvasRenderingContext2D = | 14 | private politeChickyController: CanvasRenderingContext2D = |
| 15 | new CanvasRenderingContext2D(); // CanvasRenderingContext2D对象 | 15 | new CanvasRenderingContext2D(); // CanvasRenderingContext2D对象 |
| 16 | private animateItem: AnimationItem | null = null; // 初始化loadAnimation接口的返回对象 | 16 | private animateItem: AnimationItem | null = null; // 初始化loadAnimation接口的返回对象 |
| 17 | - @Prop title: string | ||
| 18 | 17 | ||
| 19 | - // 页面隐藏销毁动画 | ||
| 20 | - // onPageHide(): void { | ||
| 21 | - // this.animateItem?.destroy() | ||
| 22 | - // | ||
| 23 | - // if (this.onComplete) { | ||
| 24 | - // this.animateItem?.removeEventListener('complete', this.onComplete) | ||
| 25 | - // } | ||
| 26 | - // } | 18 | + |
| 27 | 19 | ||
| 28 | /** | 20 | /** |
| 29 | * 加载动画 | 21 | * 加载动画 |
| 30 | * @param autoplay 控制动画是否自动播放参数 | 22 | * @param autoplay 控制动画是否自动播放参数 |
| 31 | */ | 23 | */ |
| 32 | loadAnimation() { | 24 | loadAnimation() { |
| 33 | - // 销毁动画,减少缓存 | ||
| 34 | - if (this.animateItem !== null) { | ||
| 35 | - this.animateItem.destroy(this.name); | ||
| 36 | - this.animateItem = null; | ||
| 37 | - } | ||
| 38 | 25 | ||
| 26 | + this.onDestroyAnimation() | ||
| 39 | this.animateItem = lottie.loadAnimation({ | 27 | this.animateItem = lottie.loadAnimation({ |
| 40 | container: this.politeChickyController, | 28 | container: this.politeChickyController, |
| 41 | renderer: 'canvas', | 29 | renderer: 'canvas', |
| @@ -55,31 +43,18 @@ export struct LottieView { | @@ -55,31 +43,18 @@ export struct LottieView { | ||
| 55 | 43 | ||
| 56 | } | 44 | } |
| 57 | 45 | ||
| 58 | - aboutToAppear(): void { | ||
| 59 | - // console.error('XXXXZZZZ', '-------aboutToAppear-------' + this.title) | ||
| 60 | - //lottie?.play() | ||
| 61 | - | ||
| 62 | - // if(this.init){ | ||
| 63 | - // if(this.animateItem = null){ | ||
| 64 | - // this.loadAnimation(); | ||
| 65 | - // } | ||
| 66 | - // } | ||
| 67 | - | 46 | + /** |
| 47 | + * 摧毁动画 | ||
| 48 | + */ | ||
| 49 | + onDestroyAnimation(){ | ||
| 50 | + // 销毁动画,减少缓存 | ||
| 51 | + if (this.animateItem !== null) { | ||
| 52 | + this.animateItem.destroy(this.name); | ||
| 53 | + this.animateItem = null; | ||
| 54 | + } | ||
| 68 | 55 | ||
| 69 | } | 56 | } |
| 70 | 57 | ||
| 71 | - aboutToDisappear(): void { | ||
| 72 | - // console.error('XXXXZZZZ', '-------aboutToDisappear-------' + this.title) | ||
| 73 | - // if(this.init){ | ||
| 74 | - // lottie?.destroy(this.name) | ||
| 75 | - // | ||
| 76 | - // if (this.onComplete) { | ||
| 77 | - // this.animateItem?.removeEventListener('complete', this.onComplete) | ||
| 78 | - // } | ||
| 79 | - // this.animateItem = null; | ||
| 80 | - // // } | ||
| 81 | - | ||
| 82 | - } | ||
| 83 | 58 | ||
| 84 | build() { | 59 | build() { |
| 85 | Stack({ alignContent: Alignment.TopStart }) { | 60 | Stack({ alignContent: Alignment.TopStart }) { |
| @@ -92,10 +67,10 @@ export struct LottieView { | @@ -92,10 +67,10 @@ export struct LottieView { | ||
| 92 | this.onReady(this.animateItem) | 67 | this.onReady(this.animateItem) |
| 93 | } | 68 | } |
| 94 | }) | 69 | }) |
| 95 | - .onDisAppear(() => { | ||
| 96 | - lottie.destroy(this.name) | ||
| 97 | - this.animateItem = null; | ||
| 98 | - }).onAppear(()=>{ | 70 | + .onDisAppear(()=>{ |
| 71 | + this.onDestroyAnimation() | ||
| 72 | + }) | ||
| 73 | + .onAppear(()=>{ | ||
| 99 | this.loadAnimation(); | 74 | this.loadAnimation(); |
| 100 | }) | 75 | }) |
| 101 | 76 |
| @@ -41,6 +41,7 @@ export default struct TemplatePageComponent { | @@ -41,6 +41,7 @@ export default struct TemplatePageComponent { | ||
| 41 | 41 | ||
| 42 | extra: string = '' | 42 | extra: string = '' |
| 43 | 43 | ||
| 44 | + | ||
| 44 | async aboutToAppear() { | 45 | async aboutToAppear() { |
| 45 | Logger.debug(TAG, 'aboutToAppear') | 46 | Logger.debug(TAG, 'aboutToAppear') |
| 46 | this.requestPageData() | 47 | this.requestPageData() |
| @@ -78,9 +79,6 @@ export default struct TemplatePageComponent { | @@ -78,9 +79,6 @@ export default struct TemplatePageComponent { | ||
| 78 | }) | 79 | }) |
| 79 | } | 80 | } |
| 80 | 81 | ||
| 81 | - aboutToDisappear(): void { | ||
| 82 | - | ||
| 83 | - } | ||
| 84 | 82 | ||
| 85 | build() { | 83 | build() { |
| 86 | if (this.templatePage.pageCompType === TemplatePageStateType.LOADING) { | 84 | if (this.templatePage.pageCompType === TemplatePageStateType.LOADING) { |
-
Please register or login to post a comment