ShowJHRewardAd.ets 528 B

123456789101112131415161718192021222324
  1. import { common } from '@kit.AbilityKit';
  2. import { RewardAd } from '../../ads/jhAd/RewardAd';
  3. import { emitter } from '@kit.BasicServicesKit';
  4. @Component
  5. export struct ShowJHRewardAd {
  6. @BuilderParam showAdStruct: () => void
  7. private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
  8. aboutToAppear(): void {
  9. emitter.on('showJHAd', () => {
  10. new RewardAd(this.context)
  11. })
  12. }
  13. aboutToDisappear(): void {
  14. emitter.off('showJHAd')
  15. }
  16. build() {
  17. this.showAdStruct()
  18. }
  19. }