FullOutputMediator.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import { _decorator, Component, Node } from 'cc';
  2. import { GUIManager } from '../../../engines/gui/GUIManager';
  3. import { GUIMediator } from '../../../engines/gui/GUIMediator';
  4. import { SceneManager } from '../../../engines/scenes/SceneManager';
  5. import { LiangLiangSDK } from '../../../libs/liangliangSDK';
  6. import { PlatformManager } from '../../../Platform/PlatformManager';
  7. import { UIConst } from '../UIConst';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('FullOutputMediator')
  10. export class FullOutputMediator extends GUIMediator {
  11. continueShowBanner:boolean = true;
  12. @property({
  13. type:Node
  14. })
  15. ContinueButton:Node=null;
  16. @property({
  17. type:Node
  18. })
  19. ButtonDaochuBack:Node=null;
  20. start () {
  21. // Your initialization goes here.
  22. this.ContinueButton.active = false;
  23. this.ButtonDaochuBack.active = false;
  24. }
  25. OnShow(data?:any):void{
  26. console.log("open FullOutputMediator")
  27. PlatformManager.hideBanner();
  28. this.data=data;
  29. this.randomCpa();
  30. this.scheduleOnce(this.showContinueButton.bind(this), 1);
  31. this.scheduleOnce(this.showDaochuButton.bind(this), 3);
  32. }
  33. OnHide():void{
  34. this.ContinueButton.active = false;
  35. this.ButtonDaochuBack.active = false;
  36. this.continueShowBanner = true;
  37. PlatformManager.showBanner();
  38. }
  39. randomCpa():void{
  40. if(this.wx!=null)
  41. {
  42. let adList: any[] = LiangLiangSDK.GetList();
  43. let data = adList[Math.floor(Math.random()*adList.length)]
  44. this.wx.navigateToMiniProgram({
  45. appId: data.app_id,
  46. path: data.app_path,
  47. success: (res) =>
  48. {
  49. LiangLiangSDK.CpaReport(self.data);
  50. },
  51. fail: (res) => {
  52. // GUIManager.single.Show(UIConst.FULL_OUTPUT_UI);
  53. console.log("跳转失败!");
  54. },
  55. complete: (res) => {},
  56. });
  57. }
  58. }
  59. showContinueButton():void{
  60. this.ContinueButton.active = true;
  61. }
  62. showDaochuButton():void{
  63. this.ButtonDaochuBack.active = true;
  64. }
  65. /**
  66. * 返回主界面
  67. */
  68. BackToMain():void{
  69. SceneManager.single.Swicth("PrepareScene");
  70. this.HideSelf();
  71. if(LiangLiangSDK.CanWuChu() == true){
  72. this.randomCpa();
  73. }
  74. }
  75. ContinueGame():void{
  76. if(LiangLiangSDK.CanWuChu() == true){
  77. if(this.continueShowBanner == true){
  78. this.__bannerWuChu();
  79. }else{
  80. this.randomCpa();
  81. }
  82. }else{
  83. SceneManager.single.Swicth("PrepareScene");
  84. this.HideSelf();
  85. }
  86. }
  87. /**
  88. * 误触逻辑
  89. */
  90. private __bannerWuChu():void{
  91. this.scheduleOnce(()=>{
  92. PlatformManager.showBanner();
  93. this.scheduleOnce(()=>{
  94. PlatformManager.hideBanner();
  95. this.continueShowBanner = false;
  96. }, 1)
  97. }, 1)
  98. }
  99. private get wx():any{
  100. return window["wx"];
  101. }
  102. // update (deltaTime: number) {
  103. // // Your update function goes here.
  104. // }
  105. }