AdvertisingMediator.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { _decorator, Component, Node } from 'cc';
  2. import { GUIMediator } from '../../../engines/gui/GUIMediator';
  3. import { SceneManager } from '../../../engines/scenes/SceneManager';
  4. import { LiangLiangSDK } from '../../../libs/liangliangSDK';
  5. import { PlatformManager } from '../../../Platform/PlatformManager';
  6. const { ccclass, property } = _decorator;
  7. @ccclass('AdvertisingMediator')
  8. export class AdvertisingMediator extends GUIMediator {
  9. @property({
  10. type: Node
  11. })
  12. BackButton: Node = null;
  13. start() {
  14. }
  15. OnShow(data?: any): void {
  16. this.BackButton.active = false;
  17. this.scheduleOnce(this.showBackButton.bind(this), 3);
  18. }
  19. OnHide(): void {
  20. this.BackButton.active = false;
  21. }
  22. get LayerIndex() {
  23. return 4;
  24. }
  25. showBackButton(): void {
  26. this.BackButton.active = true;
  27. }
  28. randomCpa():void{
  29. if(this.wx!=null)
  30. {
  31. let adList: any[] = LiangLiangSDK.GetList();
  32. let data = adList[Math.floor(Math.random()*adList.length)]
  33. this.wx.navigateToMiniProgram({
  34. appId: data.app_id,
  35. path: data.app_path,
  36. success: (res) =>
  37. {
  38. LiangLiangSDK.CpaReport(self.data);
  39. },
  40. fail: (res) => {
  41. // GUIManager.single.Show(UIConst.FULL_OUTPUT_UI);
  42. console.log("跳转失败!");
  43. },
  44. complete: (res) => {},
  45. });
  46. }
  47. }
  48. onClickBack(): void {
  49. this.HideSelf();
  50. if (LiangLiangSDK.CanWuChu() == true) {
  51. this.randomCpa();
  52. PlatformManager.showRewardedVideo(()=>{
  53. PlatformManager.showBanner();
  54. }, ()=>{
  55. PlatformManager.showBanner();
  56. })
  57. }
  58. }
  59. private get wx(): any {
  60. return window["wx"];
  61. }
  62. }